aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/0x.js_test.ts43
-rw-r--r--test/utils/order_factory.ts4
2 files changed, 23 insertions, 24 deletions
diff --git a/test/0x.js_test.ts b/test/0x.js_test.ts
index f2bb40d75..8c5e9c929 100644
--- a/test/0x.js_test.ts
+++ b/test/0x.js_test.ts
@@ -43,27 +43,6 @@ describe('ZeroEx library', () => {
expect((tokenRegistryWeb3WrapperProvider as any).zeroExTestId).to.be.a('number');
});
});
- describe('#getOrderHash', () => {
- const expectedOrderHash = '0x103a5e97dab5dbeb8f385636f86a7d1e458a7ccbe1bd194727f0b2f85ab116c7';
- const order: Order = {
- maker: constants.NULL_ADDRESS,
- taker: 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('calculates the order hash', () => {
- const orderHash = ZeroEx.getOrderHashHex(exchangeAddress, order);
- expect(orderHash).to.be.equal(expectedOrderHash);
- });
- });
describe('#isValidSignature', () => {
// This test data was borrowed from the JSON RPC documentation
// Source: https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign
@@ -174,6 +153,28 @@ describe('ZeroEx library', () => {
expect(baseUnitAmount).to.be.bignumber.equal(expectedUnitAmount);
});
});
+ describe('#getOrderHashAsync', () => {
+ const expectedOrderHash = '0x103a5e97dab5dbeb8f385636f86a7d1e458a7ccbe1bd194727f0b2f85ab116c7';
+ const order: Order = {
+ maker: constants.NULL_ADDRESS,
+ taker: 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),
+ };
+ it('calculates the order hash', async () => {
+ const web3 = web3Factory.create();
+ const zeroEx = new ZeroEx(web3);
+ const orderHash = await zeroEx.getOrderHashHexAsync(order);
+ expect(orderHash).to.be.equal(expectedOrderHash);
+ });
+ });
describe('#signOrderHashAsync', () => {
let stubs: Sinon.SinonStub[] = [];
afterEach(() => {
diff --git a/test/utils/order_factory.ts b/test/utils/order_factory.ts
index 3195803ad..941056c7e 100644
--- a/test/utils/order_factory.ts
+++ b/test/utils/order_factory.ts
@@ -16,8 +16,6 @@ export const orderFactory = {
takerTokenAmount: BigNumber.BigNumber|number,
takerTokenAddress: string,
expirationUnixTimestampSec?: BigNumber.BigNumber): Promise<SignedOrder> {
- // TODO refactor and check
- const exchangeAddress: string = (ExchangeArtifacts as any).networks[networkId].address;
const INF_TIMESTAMP = new BigNumber(2524604400);
expirationUnixTimestampSec = _.isUndefined(expirationUnixTimestampSec) ?
INF_TIMESTAMP :
@@ -35,7 +33,7 @@ export const orderFactory = {
feeRecipient: constants.NULL_ADDRESS,
expirationUnixTimestampSec,
};
- const orderHash = ZeroEx.getOrderHashHex(exchangeAddress, order);
+ const orderHash = await zeroEx.getOrderHashHexAsync(order);
const ecSignature = await zeroEx.signOrderHashAsync(orderHash);
const signedOrder: SignedOrder = _.assign(order, {ecSignature});
return signedOrder;