aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-utils/test/order_hash_test.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-05-30 07:58:30 +0800
committerFabio Berger <me@fabioberger.com>2018-05-30 07:58:30 +0800
commit4874d55d03918b47967024777194d88a5f2bc1fc (patch)
tree4a53834e9424a8b33aa7d0edaf13de11f2e807a3 /packages/order-utils/test/order_hash_test.ts
parent10faa474950a902af943b3c51f3703491afa6520 (diff)
downloaddexon-0x-contracts-4874d55d03918b47967024777194d88a5f2bc1fc.tar
dexon-0x-contracts-4874d55d03918b47967024777194d88a5f2bc1fc.tar.gz
dexon-0x-contracts-4874d55d03918b47967024777194d88a5f2bc1fc.tar.bz2
dexon-0x-contracts-4874d55d03918b47967024777194d88a5f2bc1fc.tar.lz
dexon-0x-contracts-4874d55d03918b47967024777194d88a5f2bc1fc.tar.xz
dexon-0x-contracts-4874d55d03918b47967024777194d88a5f2bc1fc.tar.zst
dexon-0x-contracts-4874d55d03918b47967024777194d88a5f2bc1fc.zip
Initial refactor of order-utils. Move many utils from contracts into this package.
Diffstat (limited to 'packages/order-utils/test/order_hash_test.ts')
-rw-r--r--packages/order-utils/test/order_hash_test.ts30
1 files changed, 16 insertions, 14 deletions
diff --git a/packages/order-utils/test/order_hash_test.ts b/packages/order-utils/test/order_hash_test.ts
index db5489509..7cb87c8ab 100644
--- a/packages/order-utils/test/order_hash_test.ts
+++ b/packages/order-utils/test/order_hash_test.ts
@@ -1,10 +1,11 @@
import { web3Factory } from '@0xproject/dev-utils';
+import { Order } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import 'make-promises-safe';
import 'mocha';
-import { constants, getOrderHashHex } from '../src';
+import { constants, orderHashUtils } from '../src';
import { chaiSetup } from './utils/chai_setup';
import { web3Wrapper } from './utils/web3_wrapper';
@@ -14,24 +15,25 @@ const expect = chai.expect;
describe('Order hashing', () => {
describe('#getOrderHashHex', () => {
- const expectedOrderHash = '0x39da987067a3c9e5f1617694f1301326ba8c8b0498ebef5df4863bed394e3c83';
+ const expectedOrderHash = '0x367ad7730eb8b5feab8a9c9f47c6fcba77a2d4df125ee6a59cc26ac955710f7e';
const fakeExchangeContractAddress = '0xb69e673309512a9d726f87304c6984054f87a93b';
- const order = {
- maker: constants.NULL_ADDRESS,
- taker: constants.NULL_ADDRESS,
- feeRecipient: constants.NULL_ADDRESS,
- makerTokenAddress: constants.NULL_ADDRESS,
- takerTokenAddress: constants.NULL_ADDRESS,
- exchangeContractAddress: fakeExchangeContractAddress,
+ const order: Order = {
+ makerAddress: constants.NULL_ADDRESS,
+ takerAddress: constants.NULL_ADDRESS,
+ senderAddress: constants.NULL_ADDRESS,
+ feeRecipientAddress: constants.NULL_ADDRESS,
+ makerAssetData: constants.NULL_ADDRESS,
+ takerAssetData: constants.NULL_ADDRESS,
+ exchangeAddress: fakeExchangeContractAddress,
salt: new BigNumber(0),
makerFee: new BigNumber(0),
takerFee: new BigNumber(0),
- makerTokenAmount: new BigNumber(0),
- takerTokenAmount: new BigNumber(0),
- expirationUnixTimestampSec: new BigNumber(0),
+ makerAssetAmount: new BigNumber(0),
+ takerAssetAmount: new BigNumber(0),
+ expirationTimeSeconds: new BigNumber(0),
};
it('calculates the order hash', async () => {
- const orderHash = getOrderHashHex(order);
+ const orderHash = orderHashUtils.getOrderHashHex(order);
expect(orderHash).to.be.equal(expectedOrderHash);
});
it('throws a readable error message if taker format is invalid', async () => {
@@ -41,7 +43,7 @@ describe('Order hashing', () => {
};
const expectedErrorMessage =
'Order taker must be of type string. If you want anyone to be able to fill an order - pass ZeroEx.NULL_ADDRESS';
- expect(() => getOrderHashHex(orderWithInvalidtakerFormat)).to.throw(expectedErrorMessage);
+ expect(() => orderHashUtils.getOrderHashHex(orderWithInvalidtakerFormat)).to.throw(expectedErrorMessage);
});
});
});