diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-05-30 23:35:17 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-05-30 23:35:17 +0800 |
commit | be13cf127c00c762d03c5eaf17a11c2775701530 (patch) | |
tree | cda26032d212f7c08c72965813e17de8ed1c03d4 /test/0x.js_test.ts | |
parent | 843ec2d4cf4bbc9061ba6dc5a09fc6d694c3083a (diff) | |
download | dexon-sol-tools-be13cf127c00c762d03c5eaf17a11c2775701530.tar dexon-sol-tools-be13cf127c00c762d03c5eaf17a11c2775701530.tar.gz dexon-sol-tools-be13cf127c00c762d03c5eaf17a11c2775701530.tar.bz2 dexon-sol-tools-be13cf127c00c762d03c5eaf17a11c2775701530.tar.lz dexon-sol-tools-be13cf127c00c762d03c5eaf17a11c2775701530.tar.xz dexon-sol-tools-be13cf127c00c762d03c5eaf17a11c2775701530.tar.zst dexon-sol-tools-be13cf127c00c762d03c5eaf17a11c2775701530.zip |
Refactor getOrderHash to accept order as an object
Diffstat (limited to 'test/0x.js_test.ts')
-rw-r--r-- | test/0x.js_test.ts | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/test/0x.js_test.ts b/test/0x.js_test.ts index 5d23d7094..a84785f4b 100644 --- a/test/0x.js_test.ts +++ b/test/0x.js_test.ts @@ -7,6 +7,7 @@ import * as Sinon from 'sinon'; import {ZeroEx} from '../src/0x.js'; import {constants} from './utils/constants'; import {web3Factory} from './utils/web3_factory'; +import {Order} from '../src/types'; // Use BigNumber chai add-on chai.use(ChaiBigNumber()); @@ -43,38 +44,28 @@ describe('ZeroEx library', () => { }); describe('#getOrderHash', () => { const expectedOrderHash = '0x103a5e97dab5dbeb8f385636f86a7d1e458a7ccbe1bd194727f0b2f85ab116c7'; + const order: Order = { + maker: constants.NULL_ADDRESS, + feeRecipient: constants.NULL_ADDRESS, + makerTokenAddress: constants.NULL_ADDRESS, + takerTokenAddress: constants.NULL_ADDRESS, + salt: new BigNumber(0), + makerFee: new BigNumber(0), + takerFee: new BigNumber(0), + makerTokenAmount: new BigNumber(0), + takerTokenAmount: new BigNumber(0), + expirationUnixTimestampSec: new BigNumber(0), + }; + const exchangeAddress = constants.NULL_ADDRESS; it('defaults takerAddress to NULL address', () => { - const orderHash = ZeroEx.getOrderHashHex( - constants.NULL_ADDRESS, - constants.NULL_ADDRESS, - '', - constants.NULL_ADDRESS, - constants.NULL_ADDRESS, - constants.NULL_ADDRESS, - new BigNumber(0), - new BigNumber(0), - new BigNumber(0), - new BigNumber(0), - new BigNumber(0), - new BigNumber(0), - ); + const orderHash = ZeroEx.getOrderHashHex(exchangeAddress, order); expect(orderHash).to.be.equal(expectedOrderHash); }); it('calculates the order hash', () => { - const orderHash = ZeroEx.getOrderHashHex( - constants.NULL_ADDRESS, - constants.NULL_ADDRESS, - constants.NULL_ADDRESS, - constants.NULL_ADDRESS, - constants.NULL_ADDRESS, - constants.NULL_ADDRESS, - new BigNumber(0), - new BigNumber(0), - new BigNumber(0), - new BigNumber(0), - new BigNumber(0), - new BigNumber(0), - ); + const orderWithZeroTaker = _.assign(order, { + taker: constants.NULL_ADDRESS, + }); + const orderHash = ZeroEx.getOrderHashHex(exchangeAddress, orderWithZeroTaker); expect(orderHash).to.be.equal(expectedOrderHash); }); }); |