diff options
author | Fabio Berger <me@fabioberger.com> | 2018-05-23 00:25:02 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-05-23 00:25:02 +0800 |
commit | 4a0c8d72b05152ee2fd71245873d5a70f7281058 (patch) | |
tree | 2c28ad8214aaaa10913a621509d0ae4020ee4d3d /packages/order-watcher/test/expiration_watcher_test.ts | |
parent | d460c0e8b9c6f4081803fff4e2d2347be8cd5ce3 (diff) | |
parent | ab9cfd293b3ccc2aacb4238aebe2b033e55b7935 (diff) | |
download | dexon-0x-contracts-4a0c8d72b05152ee2fd71245873d5a70f7281058.tar.gz dexon-0x-contracts-4a0c8d72b05152ee2fd71245873d5a70f7281058.tar.zst dexon-0x-contracts-4a0c8d72b05152ee2fd71245873d5a70f7281058.zip |
merge development
Diffstat (limited to 'packages/order-watcher/test/expiration_watcher_test.ts')
-rw-r--r-- | packages/order-watcher/test/expiration_watcher_test.ts | 33 |
1 files changed, 23 insertions, 10 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); }); }); |