diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-21 06:39:34 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-21 06:39:34 +0800 |
commit | 3e0371685fe16b7dc96f5f900c0d4531b16370d4 (patch) | |
tree | 4f8bb59af73309efd9676aeb680ee09bac8fb157 /packages/0x.js/test/expiration_watcher_test.ts | |
parent | 3bc3666215d4fdaa6d9db87e065ca5e762df9b25 (diff) | |
download | dexon-sol-tools-3e0371685fe16b7dc96f5f900c0d4531b16370d4.tar.gz dexon-sol-tools-3e0371685fe16b7dc96f5f900c0d4531b16370d4.tar.zst dexon-sol-tools-3e0371685fe16b7dc96f5f900c0d4531b16370d4.zip |
Fix async callbacks
Diffstat (limited to 'packages/0x.js/test/expiration_watcher_test.ts')
-rw-r--r-- | packages/0x.js/test/expiration_watcher_test.ts | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/packages/0x.js/test/expiration_watcher_test.ts b/packages/0x.js/test/expiration_watcher_test.ts index 31e01dba6..a384658e7 100644 --- a/packages/0x.js/test/expiration_watcher_test.ts +++ b/packages/0x.js/test/expiration_watcher_test.ts @@ -10,10 +10,9 @@ import {utils} from '../src/utils/utils'; import {Web3Wrapper} from '../src/web3_wrapper'; import {TokenUtils} from './utils/token_utils'; import {ExpirationWatcher} from '../src/order_watcher/expiration_watcher'; -import {Token} from '../src/types'; +import {Token, DoneCallback} from '../src/types'; import {ZeroEx} from '../src'; import {FillScenarios} from './utils/fill_scenarios'; -import {DoneCallback} from '../src/types'; import {reportCallbackErrors} from './utils/report_callback_errors'; chaiSetup.configure(); @@ -57,7 +56,7 @@ describe('ExpirationWatcher', () => { const sinonTimerConfig = {shouldAdvanceTime: true} as any; // This constructor has incorrect types timer = Sinon.useFakeTimers(sinonTimerConfig); - currentUnixTimestampSec = utils.getCurrentUnixTimestamp(); + currentUnixTimestampSec = utils.getCurrentUnixTimestampSec(); expirationWatcher = new ExpirationWatcher(); }); afterEach(() => { @@ -74,12 +73,12 @@ describe('ExpirationWatcher', () => { ); const orderHash = ZeroEx.getOrderHashHex(signedOrder); expirationWatcher.addOrder(orderHash, signedOrder.expirationUnixTimestampSec); - const callback = reportCallbackErrors(done)((hash: string) => { + const callbackAsync = reportCallbackErrors(done)(async (hash: string) => { expect(hash).to.be.equal(orderHash); - expect(utils.getCurrentUnixTimestamp()).to.be.bignumber.above(expirationUnixTimestampSec); + expect(utils.getCurrentUnixTimestampSec()).to.be.bignumber.above(expirationUnixTimestampSec); done(); }); - expirationWatcher.subscribe(callback); + expirationWatcher.subscribe(callbackAsync); timer.tick(orderLifetimeS * 1000); })().catch(done); }); @@ -93,10 +92,10 @@ describe('ExpirationWatcher', () => { ); const orderHash = ZeroEx.getOrderHashHex(signedOrder); expirationWatcher.addOrder(orderHash, signedOrder.expirationUnixTimestampSec); - const callback = reportCallbackErrors(done)((hash: string) => { + const callbackAsync = reportCallbackErrors(done)(async (hash: string) => { done(new Error('Emitted expiration went before the order actually expired')); }); - expirationWatcher.subscribe(callback); + expirationWatcher.subscribe(callbackAsync); const notEnoughTime = orderLifetimeS - 1; timer.tick(notEnoughTime * 1000); done(); @@ -121,14 +120,14 @@ describe('ExpirationWatcher', () => { expirationWatcher.addOrder(orderHash2, signedOrder2.expirationUnixTimestampSec); expirationWatcher.addOrder(orderHash1, signedOrder1.expirationUnixTimestampSec); const expirationOrder = [orderHash1, orderHash2]; - const callback = reportCallbackErrors(done)((hash: string) => { + const callbackAsync = reportCallbackErrors(done)(async (hash: string) => { const orderHash = expirationOrder.shift(); expect(hash).to.be.equal(orderHash); if (_.isEmpty(expirationOrder)) { done(); } }); - expirationWatcher.subscribe(callback); + expirationWatcher.subscribe(callbackAsync); timer.tick(order2Lifetime * 1000); })().catch(done); }); |