aboutsummaryrefslogtreecommitdiffstats
path: root/test/exchange_wrapper_test.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-13 21:52:50 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-13 21:52:50 +0800
commit6ad1900ada799eec18e870f48de785af14780a60 (patch)
tree25c064c33816a7da818079b08c19a523061d70ee /test/exchange_wrapper_test.ts
parenta045eb7bbb76cee83d26b1ca18074d3b1961e084 (diff)
downloaddexon-sol-tools-6ad1900ada799eec18e870f48de785af14780a60.tar
dexon-sol-tools-6ad1900ada799eec18e870f48de785af14780a60.tar.gz
dexon-sol-tools-6ad1900ada799eec18e870f48de785af14780a60.tar.bz2
dexon-sol-tools-6ad1900ada799eec18e870f48de785af14780a60.tar.lz
dexon-sol-tools-6ad1900ada799eec18e870f48de785af14780a60.tar.xz
dexon-sol-tools-6ad1900ada799eec18e870f48de785af14780a60.tar.zst
dexon-sol-tools-6ad1900ada799eec18e870f48de785af14780a60.zip
Refactor subscription to return zeroExSignature object
Diffstat (limited to 'test/exchange_wrapper_test.ts')
-rw-r--r--test/exchange_wrapper_test.ts26
1 files changed, 16 insertions, 10 deletions
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts
index f9cf9651f..b9ac374dd 100644
--- a/test/exchange_wrapper_test.ts
+++ b/test/exchange_wrapper_test.ts
@@ -619,7 +619,7 @@ describe('ExchangeWrapper', () => {
);
});
afterEach(async () => {
- await (zeroEx.exchange as any)._stopWatchingExchangeLogEventsAsync();
+ await zeroEx.exchange.stopWatchingAllEventsAsync();
});
// Hack: Mocha does not allow a test to be both async and have a `done` callback
// Since we need to await the receipt of the event in the `subscribeAsync` callback,
@@ -632,8 +632,9 @@ describe('ExchangeWrapper', () => {
fromBlock: 0,
toBlock: 'latest',
};
- await zeroEx.exchange.subscribeAsync(ExchangeEvents.LogFill, subscriptionOpts,
- indexFilterValues, (err: Error, event: ContractEvent) => {
+ const zeroExEvent = await zeroEx.exchange.subscribeAsync(ExchangeEvents.LogFill, subscriptionOpts,
+ indexFilterValues);
+ zeroExEvent.watch((err: Error, event: ContractEvent) => {
expect(err).to.be.null();
expect(event).to.not.be.undefined();
done();
@@ -650,12 +651,13 @@ describe('ExchangeWrapper', () => {
fromBlock: 0,
toBlock: 'latest',
};
- await zeroEx.exchange.subscribeAsync(ExchangeEvents.LogCancel, subscriptionOpts,
- indexFilterValues, (err: Error, event: ContractEvent) => {
+ const zeroExEvent = await zeroEx.exchange.subscribeAsync(ExchangeEvents.LogCancel, subscriptionOpts,
+ indexFilterValues);
+ zeroExEvent.watch((err: Error, event: ContractEvent) => {
expect(err).to.be.null();
expect(event).to.not.be.undefined();
done();
- });
+ });
const cancelTakerAmountInBaseUnits = new BigNumber(1);
await zeroEx.exchange.cancelOrderAsync(signedOrder, cancelTakerAmountInBaseUnits);
})();
@@ -666,16 +668,20 @@ describe('ExchangeWrapper', () => {
fromBlock: 0,
toBlock: 'latest',
};
- await zeroEx.exchange.subscribeAsync(ExchangeEvents.LogFill, subscriptionOpts,
- indexFilterValues, (err: Error, event: ContractEvent) => {
+ const eventSubscriptionToBeCancelled = await zeroEx.exchange.subscribeAsync(
+ ExchangeEvents.LogFill, subscriptionOpts, indexFilterValues,
+ );
+ eventSubscriptionToBeCancelled.watch((err: Error, event: ContractEvent) => {
done(new Error('Expected this subscription to have been cancelled'));
});
const newProvider = web3Factory.getRpcProvider();
await zeroEx.setProviderAsync(newProvider);
- await zeroEx.exchange.subscribeAsync(ExchangeEvents.LogFill, subscriptionOpts,
- indexFilterValues, (err: Error, event: ContractEvent) => {
+ const eventSubscriptionToStay = await zeroEx.exchange.subscribeAsync(
+ ExchangeEvents.LogFill, subscriptionOpts, indexFilterValues,
+ );
+ eventSubscriptionToStay.watch((err: Error, event: ContractEvent) => {
expect(err).to.be.null();
expect(event).to.not.be.undefined();
done();