aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-watcher/test
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-05-23 00:04:50 +0800
committerGitHub <noreply@github.com>2018-05-23 00:04:50 +0800
commitcc840a6911850856c3254f7ac73cd70c527e1a5c (patch)
treec7435ac7ce09541a67f0106a85f391dc48921e10 /packages/order-watcher/test
parenta26cc7c14d4e59102d5f84d534f75c42b8683cad (diff)
parentc4a2f700172e8be367225d90a1c51cef8cf0d7dd (diff)
downloaddexon-0x-contracts-cc840a6911850856c3254f7ac73cd70c527e1a5c.tar.gz
dexon-0x-contracts-cc840a6911850856c3254f7ac73cd70c527e1a5c.tar.zst
dexon-0x-contracts-cc840a6911850856c3254f7ac73cd70c527e1a5c.zip
Merge pull request #594 from 0xProject/improvement/addCustomTslintRules
Add more tslint rules
Diffstat (limited to 'packages/order-watcher/test')
-rw-r--r--packages/order-watcher/test/expiration_watcher_test.ts33
-rw-r--r--packages/order-watcher/test/global_hooks.ts3
-rw-r--r--packages/order-watcher/test/order_watcher_test.ts4
3 files changed, 27 insertions, 13 deletions
diff --git a/packages/order-watcher/test/expiration_watcher_test.ts b/packages/order-watcher/test/expiration_watcher_test.ts
index 8b006f58a..ef15bf006 100644
--- a/packages/order-watcher/test/expiration_watcher_test.ts
+++ b/packages/order-watcher/test/expiration_watcher_test.ts
@@ -22,6 +22,7 @@ import { provider, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
+const MILISECONDS_IN_SECOND = 1000;
describe('ExpirationWatcher', () => {
let contractWrappers: ContractWrappers;
@@ -84,13 +85,13 @@ describe('ExpirationWatcher', () => {
expirationUnixTimestampSec,
);
const orderHash = getOrderHashHex(signedOrder);
- expirationWatcher.addOrder(orderHash, signedOrder.expirationUnixTimestampSec.times(1000));
+ expirationWatcher.addOrder(orderHash, signedOrder.expirationUnixTimestampSec.times(MILISECONDS_IN_SECOND));
const callbackAsync = callbackErrorReporter.reportNoErrorCallbackErrors(done)((hash: string) => {
expect(hash).to.be.equal(orderHash);
expect(utils.getCurrentUnixTimestampSec()).to.be.bignumber.gte(expirationUnixTimestampSec);
});
expirationWatcher.subscribe(callbackAsync);
- timer.tick(orderLifetimeSec * 1000);
+ timer.tick(orderLifetimeSec * MILISECONDS_IN_SECOND);
})().catch(done);
});
it("doesn't emit events before order expires", (done: DoneCallback) => {
@@ -106,13 +107,13 @@ describe('ExpirationWatcher', () => {
expirationUnixTimestampSec,
);
const orderHash = getOrderHashHex(signedOrder);
- expirationWatcher.addOrder(orderHash, signedOrder.expirationUnixTimestampSec.times(1000));
+ expirationWatcher.addOrder(orderHash, signedOrder.expirationUnixTimestampSec.times(MILISECONDS_IN_SECOND));
const callbackAsync = callbackErrorReporter.reportNoErrorCallbackErrors(done)(async (hash: string) => {
done(new Error('Emitted expiration went before the order actually expired'));
});
expirationWatcher.subscribe(callbackAsync);
const notEnoughTime = orderLifetimeSec - 1;
- timer.tick(notEnoughTime * 1000);
+ timer.tick(notEnoughTime * MILISECONDS_IN_SECOND);
done();
})().catch(done);
});
@@ -140,8 +141,14 @@ describe('ExpirationWatcher', () => {
);
const orderHash1 = getOrderHashHex(signedOrder1);
const orderHash2 = getOrderHashHex(signedOrder2);
- expirationWatcher.addOrder(orderHash2, signedOrder2.expirationUnixTimestampSec.times(1000));
- expirationWatcher.addOrder(orderHash1, signedOrder1.expirationUnixTimestampSec.times(1000));
+ expirationWatcher.addOrder(
+ orderHash2,
+ signedOrder2.expirationUnixTimestampSec.times(MILISECONDS_IN_SECOND),
+ );
+ expirationWatcher.addOrder(
+ orderHash1,
+ signedOrder1.expirationUnixTimestampSec.times(MILISECONDS_IN_SECOND),
+ );
const expirationOrder = [orderHash1, orderHash2];
const expectToBeCalledOnce = false;
const callbackAsync = callbackErrorReporter.reportNoErrorCallbackErrors(done, expectToBeCalledOnce)(
@@ -154,7 +161,7 @@ describe('ExpirationWatcher', () => {
},
);
expirationWatcher.subscribe(callbackAsync);
- timer.tick(order2Lifetime * 1000);
+ timer.tick(order2Lifetime * MILISECONDS_IN_SECOND);
})().catch(done);
});
it('emits events in correct order when expirations are equal', (done: DoneCallback) => {
@@ -181,8 +188,14 @@ describe('ExpirationWatcher', () => {
);
const orderHash1 = getOrderHashHex(signedOrder1);
const orderHash2 = getOrderHashHex(signedOrder2);
- expirationWatcher.addOrder(orderHash1, signedOrder1.expirationUnixTimestampSec.times(1000));
- expirationWatcher.addOrder(orderHash2, signedOrder2.expirationUnixTimestampSec.times(1000));
+ expirationWatcher.addOrder(
+ orderHash1,
+ signedOrder1.expirationUnixTimestampSec.times(MILISECONDS_IN_SECOND),
+ );
+ expirationWatcher.addOrder(
+ orderHash2,
+ signedOrder2.expirationUnixTimestampSec.times(MILISECONDS_IN_SECOND),
+ );
const expirationOrder = orderHash1 < orderHash2 ? [orderHash1, orderHash2] : [orderHash2, orderHash1];
const expectToBeCalledOnce = false;
const callbackAsync = callbackErrorReporter.reportNoErrorCallbackErrors(done, expectToBeCalledOnce)(
@@ -195,7 +208,7 @@ describe('ExpirationWatcher', () => {
},
);
expirationWatcher.subscribe(callbackAsync);
- timer.tick(order2Lifetime * 1000);
+ timer.tick(order2Lifetime * MILISECONDS_IN_SECOND);
})().catch(done);
});
});
diff --git a/packages/order-watcher/test/global_hooks.ts b/packages/order-watcher/test/global_hooks.ts
index 03eab0e13..d4d033dd4 100644
--- a/packages/order-watcher/test/global_hooks.ts
+++ b/packages/order-watcher/test/global_hooks.ts
@@ -9,7 +9,8 @@ import { provider } from './utils/web3_wrapper';
before('migrate contracts', async function(): Promise<void> {
// HACK: Since the migrations take longer then our global mocha timeout limit
// we manually increase it for this before hook.
- this.timeout(20000);
+ const mochaTestTimeoutMs = 20000;
+ this.timeout(mochaTestTimeoutMs);
const txDefaults = {
gas: devConstants.GAS_ESTIMATE,
from: devConstants.TESTRPC_FIRST_ADDRESS,
diff --git a/packages/order-watcher/test/order_watcher_test.ts b/packages/order-watcher/test/order_watcher_test.ts
index dc8e544b1..0d33e7ea2 100644
--- a/packages/order-watcher/test/order_watcher_test.ts
+++ b/packages/order-watcher/test/order_watcher_test.ts
@@ -269,8 +269,8 @@ describe('OrderWatcher', () => {
});
it('should trigger the callback when orders backing ZRX allowance changes', (done: DoneCallback) => {
(async () => {
- const makerFee = Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18);
- const takerFee = Web3Wrapper.toBaseUnitAmount(new BigNumber(0), 18);
+ const makerFee = Web3Wrapper.toBaseUnitAmount(new BigNumber(2), decimals);
+ const takerFee = Web3Wrapper.toBaseUnitAmount(new BigNumber(0), decimals);
signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
makerToken.address,
takerToken.address,