diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-09-05 18:22:17 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-09-06 16:33:34 +0800 |
commit | 501f054d5115ffe923cfc2b21393e36674097a82 (patch) | |
tree | e43c846efe2a151b9809bcf00a155956f51e48e6 /test | |
parent | 0275ac9dada35648ffb3b543f6ba2546117a3b63 (diff) | |
download | dexon-sol-tools-501f054d5115ffe923cfc2b21393e36674097a82.tar dexon-sol-tools-501f054d5115ffe923cfc2b21393e36674097a82.tar.gz dexon-sol-tools-501f054d5115ffe923cfc2b21393e36674097a82.tar.bz2 dexon-sol-tools-501f054d5115ffe923cfc2b21393e36674097a82.tar.lz dexon-sol-tools-501f054d5115ffe923cfc2b21393e36674097a82.tar.xz dexon-sol-tools-501f054d5115ffe923cfc2b21393e36674097a82.tar.zst dexon-sol-tools-501f054d5115ffe923cfc2b21393e36674097a82.zip |
Add signature verification as a part of order validation and tests for it
Diffstat (limited to 'test')
-rw-r--r-- | test/order_validation_test.ts | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/test/order_validation_test.ts b/test/order_validation_test.ts index 93bcfcce0..9a621555c 100644 --- a/test/order_validation_test.ts +++ b/test/order_validation_test.ts @@ -4,7 +4,7 @@ import * as BigNumber from 'bignumber.js'; import promisify = require('es6-promisify'); import {chaiSetup} from './utils/chai_setup'; import {web3Factory} from './utils/web3_factory'; -import {ZeroEx, SignedOrder, Token, ExchangeContractErrs} from '../src'; +import {ZeroEx, SignedOrder, Token, ExchangeContractErrs, ZeroExError} from '../src'; import {TokenUtils} from './utils/token_utils'; import {BlockchainLifecycle} from './utils/blockchain_lifecycle'; import {FillScenarios} from './utils/fill_scenarios'; @@ -64,6 +64,16 @@ describe('OrderValidation', () => { signedOrder, zeroFillAmount, takerAddress, )).to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero); }); + it('should throw when the signature is invalid', async () => { + const signedOrder = await fillScenarios.createFillableSignedOrderAsync( + makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount, + ); + // 27 <--> 28 + signedOrder.ecSignature.v = 27 + (28 - signedOrder.ecSignature.v); + return expect(zeroEx.exchange.validateFillOrderThrowIfInvalidAsync( + signedOrder, fillableAmount, takerAddress, + )).to.be.rejectedWith(ZeroExError.InvalidSignature); + }); it('should throw when the order is fully filled or cancelled', async () => { const signedOrder = await fillScenarios.createFillableSignedOrderAsync( makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount, |