From 332cc14dcde97d760d0115aefa0845f82e23cc26 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 5 Feb 2019 13:07:40 +0000 Subject: Add preSigned isValidSignature test for success case using smart contract & TS implementation --- .../contract-wrappers/test/exchange_wrapper_test.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'packages/contract-wrappers/test/exchange_wrapper_test.ts') 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', () => { -- cgit