diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-07-18 21:27:38 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-07-18 21:27:38 +0800 |
commit | dad557164ea4ccc012243d43df013078a7c37eb6 (patch) | |
tree | 88e8477941dc0c98273fcb054086b2e89d034e19 /packages/order-watcher/test | |
parent | acff177c547dee049b97e4b051fe22e1efaf992c (diff) | |
parent | f3241ff86a0d99f4291c5a5f4eaaa5ebe1736da0 (diff) | |
download | dexon-0x-contracts-dad557164ea4ccc012243d43df013078a7c37eb6.tar dexon-0x-contracts-dad557164ea4ccc012243d43df013078a7c37eb6.tar.gz dexon-0x-contracts-dad557164ea4ccc012243d43df013078a7c37eb6.tar.bz2 dexon-0x-contracts-dad557164ea4ccc012243d43df013078a7c37eb6.tar.lz dexon-0x-contracts-dad557164ea4ccc012243d43df013078a7c37eb6.tar.xz dexon-0x-contracts-dad557164ea4ccc012243d43df013078a7c37eb6.tar.zst dexon-0x-contracts-dad557164ea4ccc012243d43df013078a7c37eb6.zip |
Merge branch 'v2-prototype' into feature/order-watcher-v2
Diffstat (limited to 'packages/order-watcher/test')
-rw-r--r-- | packages/order-watcher/test/global_hooks.ts | 2 | ||||
-rw-r--r-- | packages/order-watcher/test/order_watcher_test.ts | 4 | ||||
-rw-r--r-- | packages/order-watcher/test/utils/token_utils.ts | 34 |
3 files changed, 37 insertions, 3 deletions
diff --git a/packages/order-watcher/test/global_hooks.ts b/packages/order-watcher/test/global_hooks.ts index 4552e01b0..f64f1df78 100644 --- a/packages/order-watcher/test/global_hooks.ts +++ b/packages/order-watcher/test/global_hooks.ts @@ -7,7 +7,7 @@ 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. const mochaTestTimeoutMs = 25000; - this.timeout(mochaTestTimeoutMs); + this.timeout(mochaTestTimeoutMs); // tslint:disable-line:no-invalid-this const txDefaults = { gas: devConstants.GAS_LIMIT, 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 6339505ce..1281d11c2 100644 --- a/packages/order-watcher/test/order_watcher_test.ts +++ b/packages/order-watcher/test/order_watcher_test.ts @@ -136,8 +136,8 @@ describe('OrderWatcher', () => { orderWatcher.unsubscribe(); }); it('should fail when trying to subscribe twice', async () => { - orderWatcher.subscribe(_.noop); - expect(() => orderWatcher.subscribe(_.noop)).to.throw(OrderWatcherError.SubscriptionAlreadyPresent); + orderWatcher.subscribe(_.noop.bind(_)); + expect(() => orderWatcher.subscribe(_.noop.bind(_))).to.throw(OrderWatcherError.SubscriptionAlreadyPresent); }); }); describe('tests with cleanup', async () => { diff --git a/packages/order-watcher/test/utils/token_utils.ts b/packages/order-watcher/test/utils/token_utils.ts new file mode 100644 index 000000000..f91b3797f --- /dev/null +++ b/packages/order-watcher/test/utils/token_utils.ts @@ -0,0 +1,34 @@ +import { Token } from '@0xproject/types'; +import * as _ from 'lodash'; + +import { InternalOrderWatcherError } from '../../src/types'; + +const PROTOCOL_TOKEN_SYMBOL = 'ZRX'; +const WETH_TOKEN_SYMBOL = 'WETH'; + +export class TokenUtils { + private readonly _tokens: Token[]; + constructor(tokens: Token[]) { + this._tokens = tokens; + } + public getProtocolTokenOrThrow(): Token { + const zrxToken = _.find(this._tokens, { symbol: PROTOCOL_TOKEN_SYMBOL }); + if (_.isUndefined(zrxToken)) { + throw new Error(InternalOrderWatcherError.ZrxNotInTokenRegistry); + } + return zrxToken; + } + public getWethTokenOrThrow(): Token { + const wethToken = _.find(this._tokens, { symbol: WETH_TOKEN_SYMBOL }); + if (_.isUndefined(wethToken)) { + throw new Error(InternalOrderWatcherError.WethNotInTokenRegistry); + } + return wethToken; + } + public getDummyTokens(): Token[] { + const dummyTokens = _.filter(this._tokens, token => { + return !_.includes([PROTOCOL_TOKEN_SYMBOL, WETH_TOKEN_SYMBOL], token.symbol); + }); + return dummyTokens; + } +} |