diff options
author | Fabio Berger <me@fabioberger.com> | 2019-02-05 21:07:40 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2019-02-05 21:07:40 +0800 |
commit | 332cc14dcde97d760d0115aefa0845f82e23cc26 (patch) | |
tree | c60da29c126587b5bbb96fef56075a926d74b540 /packages/contract-wrappers | |
parent | 7885b2e3f8094c957ca1c1e851c4bc368dda5bdf (diff) | |
download | dexon-0x-contracts-332cc14dcde97d760d0115aefa0845f82e23cc26.tar.gz dexon-0x-contracts-332cc14dcde97d760d0115aefa0845f82e23cc26.tar.zst dexon-0x-contracts-332cc14dcde97d760d0115aefa0845f82e23cc26.zip |
Add preSigned isValidSignature test for success case using smart contract & TS implementation
Diffstat (limited to 'packages/contract-wrappers')
-rw-r--r-- | packages/contract-wrappers/test/exchange_wrapper_test.ts | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/packages/contract-wrappers/test/exchange_wrapper_test.ts b/packages/contract-wrappers/test/exchange_wrapper_test.ts index a1d60dc6e..f8fa25491 100644 --- a/packages/contract-wrappers/test/exchange_wrapper_test.ts +++ b/packages/contract-wrappers/test/exchange_wrapper_test.ts @@ -1,6 +1,6 @@ import { BlockchainLifecycle, callbackErrorReporter } from '@0x/dev-utils'; import { FillScenarios } from '@0x/fill-scenarios'; -import { assetDataUtils, orderHashUtils } from '@0x/order-utils'; +import { assetDataUtils, orderHashUtils, signatureUtils } from '@0x/order-utils'; import { DoneCallback, RevertReason, SignedOrder } from '@0x/types'; import { BigNumber } from '@0x/utils'; import * as chai from 'chai'; @@ -353,7 +353,7 @@ describe('ExchangeWrapper', () => { }); }); describe('#preSignAsync/isPreSignedAsync', () => { - it('should preSign the hash', async () => { + it.only('should preSign the hash', async () => { const senderAddress = takerAddress; const hash = orderHashUtils.getOrderHashHex(signedOrder); const signerAddress = signedOrder.makerAddress; @@ -368,6 +368,23 @@ describe('ExchangeWrapper', () => { await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); isPreSigned = await contractWrappers.exchange.isPreSignedAsync(hash, signerAddress); expect(isPreSigned).to.be.true(); + + const preSignedSignature = '0x06'; + const isValidSignature = await contractWrappers.exchange.isValidSignatureAsync( + hash, + signerAddress, + preSignedSignature, + ); + expect(isValidSignature).to.be.true(); + + // Test our TS implementation of signature validation + const isValidSignatureInTs = await signatureUtils.isValidSignatureAsync( + provider, + hash, + preSignedSignature, + signerAddress, + ); + expect(isValidSignatureInTs).to.be.true(); }); }); describe('#getVersionAsync', () => { |