aboutsummaryrefslogtreecommitdiffstats
path: root/test/exchange_wrapper_test.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-10-13 17:52:59 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-10-13 17:52:59 +0800
commit0eaca6c691d92a10b08c0e69306291aa8de06bfb (patch)
treeffa00109b4115025b8be35822abbbbd4ddb05155 /test/exchange_wrapper_test.ts
parentba654c04a086b8c4ce4330b3d6064716a4090599 (diff)
downloaddexon-sol-tools-0eaca6c691d92a10b08c0e69306291aa8de06bfb.tar
dexon-sol-tools-0eaca6c691d92a10b08c0e69306291aa8de06bfb.tar.gz
dexon-sol-tools-0eaca6c691d92a10b08c0e69306291aa8de06bfb.tar.bz2
dexon-sol-tools-0eaca6c691d92a10b08c0e69306291aa8de06bfb.tar.lz
dexon-sol-tools-0eaca6c691d92a10b08c0e69306291aa8de06bfb.tar.xz
dexon-sol-tools-0eaca6c691d92a10b08c0e69306291aa8de06bfb.tar.zst
dexon-sol-tools-0eaca6c691d92a10b08c0e69306291aa8de06bfb.zip
Make logs fetching and sunscriptions more type-safe
Diffstat (limited to 'test/exchange_wrapper_test.ts')
-rw-r--r--test/exchange_wrapper_test.ts16
1 files changed, 9 insertions, 7 deletions
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts
index afc33f1f4..1bedfc4da 100644
--- a/test/exchange_wrapper_test.ts
+++ b/test/exchange_wrapper_test.ts
@@ -18,6 +18,7 @@ import {
OrderCancellationRequest,
OrderFillRequest,
LogFillContractEventArgs,
+ LogCancelContractEventArgs,
OrderFillOrKillRequest,
LogEvent,
} from '../src';
@@ -651,7 +652,7 @@ describe('ExchangeWrapper', () => {
// Source: https://github.com/mochajs/mocha/issues/2407
it('Should receive the LogFill event when an order is filled', (done: DoneCallback) => {
(async () => {
- const callback = (logEvent: LogEvent) => {
+ const callback = (logEvent: LogEvent<LogFillContractEventArgs>) => {
expect(logEvent.event).to.be.equal(ExchangeEvents.LogFill);
done();
};
@@ -665,7 +666,7 @@ describe('ExchangeWrapper', () => {
});
it('Should receive the LogCancel event when an order is cancelled', (done: DoneCallback) => {
(async () => {
- const callback = (logEvent: LogEvent) => {
+ const callback = (logEvent: LogEvent<LogCancelContractEventArgs>) => {
expect(logEvent.event).to.be.equal(ExchangeEvents.LogCancel);
done();
};
@@ -677,7 +678,7 @@ describe('ExchangeWrapper', () => {
});
it('Outstanding subscriptions are cancelled when zeroEx.setProviderAsync called', (done: DoneCallback) => {
(async () => {
- const callbackNeverToBeCalled = (logEvent: LogEvent) => {
+ const callbackNeverToBeCalled = (logEvent: LogEvent<LogFillContractEventArgs>) => {
done(new Error('Expected this subscription to have been cancelled'));
};
await zeroEx.exchange.subscribeAsync(
@@ -687,7 +688,7 @@ describe('ExchangeWrapper', () => {
const newProvider = web3Factory.getRpcProvider();
await zeroEx.setProviderAsync(newProvider);
- const callback = (logEvent: LogEvent) => {
+ const callback = (logEvent: LogEvent<LogFillContractEventArgs>) => {
expect(logEvent.event).to.be.equal(ExchangeEvents.LogFill);
done();
};
@@ -701,7 +702,7 @@ describe('ExchangeWrapper', () => {
});
it('Should cancel subscription when unsubscribe called', (done: DoneCallback) => {
(async () => {
- const callbackNeverToBeCalled = (logEvent: LogEvent) => {
+ const callbackNeverToBeCalled = (logEvent: LogEvent<LogFillContractEventArgs>) => {
done(new Error('Expected this subscription to have been cancelled'));
};
const subscriptionToken = await zeroEx.exchange.subscribeAsync(
@@ -811,11 +812,12 @@ describe('ExchangeWrapper', () => {
const indexFilterValues = {
maker: differentMakerAddress,
};
- const logs = await zeroEx.exchange.getLogsAsync(
+ const logs = await zeroEx.exchange.getLogsAsync<LogFillContractEventArgs>(
eventName, subscriptionOpts, indexFilterValues,
);
expect(logs).to.have.length(1);
- expect(logs[0].args.maker).to.be.equal(differentMakerAddress);
+ const args = logs[0].args;
+ expect(args.maker).to.be.equal(differentMakerAddress);
});
});
});