diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-06-20 09:45:57 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2018-06-21 04:54:39 +0800 |
commit | 4a136cafda2621b2d539b0d7b406db878586f2ff (patch) | |
tree | e9a4884d41c698486d6bb80bf248d580ce9b1a72 /packages/contracts/test | |
parent | d0df25d9e2ced5593a0718ee174eeb833f6599d3 (diff) | |
download | dexon-sol-tools-4a136cafda2621b2d539b0d7b406db878586f2ff.tar dexon-sol-tools-4a136cafda2621b2d539b0d7b406db878586f2ff.tar.gz dexon-sol-tools-4a136cafda2621b2d539b0d7b406db878586f2ff.tar.bz2 dexon-sol-tools-4a136cafda2621b2d539b0d7b406db878586f2ff.tar.lz dexon-sol-tools-4a136cafda2621b2d539b0d7b406db878586f2ff.tar.xz dexon-sol-tools-4a136cafda2621b2d539b0d7b406db878586f2ff.tar.zst dexon-sol-tools-4a136cafda2621b2d539b0d7b406db878586f2ff.zip |
Minor improvements to MixinSignatureValidator tests
Diffstat (limited to 'packages/contracts/test')
-rw-r--r-- | packages/contracts/test/exchange/signature_validator.ts | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/packages/contracts/test/exchange/signature_validator.ts b/packages/contracts/test/exchange/signature_validator.ts index 5937dee12..483099c10 100644 --- a/packages/contracts/test/exchange/signature_validator.ts +++ b/packages/contracts/test/exchange/signature_validator.ts @@ -181,7 +181,7 @@ describe('MixinSignatureValidator', () => { expect(isValidSignature).to.be.true(); }); - it('should return true when SignatureType=EIP712 and signature is valid', async () => { + it('should return false when SignatureType=EIP712 and signature is invalid', async () => { // Create EIP712 signature const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); const orderHashBuffer = ethUtil.toBuffer(orderHashHex); @@ -194,7 +194,8 @@ describe('MixinSignatureValidator', () => { ethUtil.toBuffer(`0x${SignatureType.EIP712}`), ]); const signatureHex = ethUtil.bufferToHex(signature); - // Validate signature + // Validate signature. + // This will fail because `signerAddress` signed the message, but we're passing in `notSignerAddress` const isValidSignature = await signatureValidator.publicIsValidSignature.callAsync( orderHashHex, notSignerAddress, @@ -226,7 +227,7 @@ describe('MixinSignatureValidator', () => { expect(isValidSignature).to.be.true(); }); - it('should return true when SignatureType=EthSign and signature is invalid', async () => { + it('should return false when SignatureType=EthSign and signature is invalid', async () => { // Create EthSign signature const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); const orderHashWithEthSignPrefixHex = addSignedMessagePrefix(orderHashHex, MessagePrefixType.EthSign); @@ -341,6 +342,8 @@ describe('MixinSignatureValidator', () => { const signature = Buffer.concat([validatorAddress, signatureType]); const signatureHex = ethUtil.bufferToHex(signature); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); + // This will return false because we signed the message with `signerAddress`, but + // are validating against `notSignerAddress` const isValidSignature = await signatureValidator.publicIsValidSignature.callAsync( orderHashHex, notSignerAddress, @@ -371,15 +374,6 @@ describe('MixinSignatureValidator', () => { signatureHex, ); expect(isValidSignature).to.be.false(); - // Set approval of signature validator back to true - await web3Wrapper.awaitTransactionSuccessAsync( - await signatureValidator.setSignatureValidatorApproval.sendTransactionAsync( - testValidator.address, - true, - { from: signerAddress }, - ), - constants.AWAIT_TRANSACTION_MINED_MS, - ); }); it('should return true when SignatureType=Trezor and signature is valid', async () => { @@ -405,7 +399,7 @@ describe('MixinSignatureValidator', () => { expect(isValidSignature).to.be.true(); }); - it('should return true when SignatureType=Trezor and signature is invalid', async () => { + it('should return false when SignatureType=Trezor and signature is invalid', async () => { // Create Trezor signature const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); const orderHashWithTrezorPrefixHex = addSignedMessagePrefix(orderHashHex, MessagePrefixType.Trezor); @@ -451,7 +445,7 @@ describe('MixinSignatureValidator', () => { expect(isValidSignature).to.be.true(); }); - it('should return false when SignatureType=Presigned has not presigned hash', async () => { + it('should return false when SignatureType=Presigned and signer has not presigned hash', async () => { const signature = ethUtil.toBuffer(`0x${SignatureType.PreSigned}`); const signatureHex = ethUtil.bufferToHex(signature); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); |