aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/test/subscription_test.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-01-05 22:33:00 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-01-10 18:24:37 +0800
commitc8c86c44f8b978d74e03c11d4bb1813e76574af3 (patch)
tree3caa7b2613496052ca90176822ace79fc28dcc44 /packages/0x.js/test/subscription_test.ts
parentf917a4a34a9d7b25de85f9ce5adafa0f16ea6618 (diff)
downloaddexon-sol-tools-c8c86c44f8b978d74e03c11d4bb1813e76574af3.tar
dexon-sol-tools-c8c86c44f8b978d74e03c11d4bb1813e76574af3.tar.gz
dexon-sol-tools-c8c86c44f8b978d74e03c11d4bb1813e76574af3.tar.bz2
dexon-sol-tools-c8c86c44f8b978d74e03c11d4bb1813e76574af3.tar.lz
dexon-sol-tools-c8c86c44f8b978d74e03c11d4bb1813e76574af3.tar.xz
dexon-sol-tools-c8c86c44f8b978d74e03c11d4bb1813e76574af3.tar.zst
dexon-sol-tools-c8c86c44f8b978d74e03c11d4bb1813e76574af3.zip
Fix callback types
Diffstat (limited to 'packages/0x.js/test/subscription_test.ts')
-rw-r--r--packages/0x.js/test/subscription_test.ts20
1 files changed, 4 insertions, 16 deletions
diff --git a/packages/0x.js/test/subscription_test.ts b/packages/0x.js/test/subscription_test.ts
index d6269f15f..f44bfecf6 100644
--- a/packages/0x.js/test/subscription_test.ts
+++ b/packages/0x.js/test/subscription_test.ts
@@ -11,7 +11,7 @@ import { DoneCallback } from '../src/types';
import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
-import { reportCallbackErrors } from './utils/report_callback_errors';
+import { assertNodeCallbackError } from './utils/report_callback_errors';
import { web3Factory } from './utils/web3_factory';
chaiSetup.configure();
@@ -59,13 +59,7 @@ describe('SubscriptionTest', () => {
it('Should receive the Error when an error occurs while fetching the block', (done: DoneCallback) => {
(async () => {
const errMsg = 'Error fetching block';
- const callback = reportCallbackErrors(done)(
- (err: Error, logEvent: DecodedLogEvent<ApprovalContractEventArgs>) => {
- expect(err.message).to.be.equal(errMsg);
- expect(logEvent).to.be.undefined();
- done();
- },
- );
+ const callback = assertNodeCallbackError(done, errMsg);
stubs = [Sinon.stub((zeroEx as any)._web3Wrapper, 'getBlockAsync').throws(new Error(errMsg))];
zeroEx.token.subscribe(tokenAddress, TokenEvents.Approval, indexFilterValues, callback);
await zeroEx.token.setAllowanceAsync(tokenAddress, coinbase, addressWithoutFunds, allowanceAmount);
@@ -74,13 +68,7 @@ describe('SubscriptionTest', () => {
it('Should receive the Error when an error occurs while reconciling the new block', (done: DoneCallback) => {
(async () => {
const errMsg = 'Error fetching logs';
- const callback = reportCallbackErrors(done)(
- (err: Error, logEvent: DecodedLogEvent<ApprovalContractEventArgs>) => {
- expect(err.message).to.be.equal(errMsg);
- expect(logEvent).to.be.undefined();
- done();
- },
- );
+ const callback = assertNodeCallbackError(done, errMsg);
stubs = [Sinon.stub((zeroEx as any)._web3Wrapper, 'getLogsAsync').throws(new Error(errMsg))];
zeroEx.token.subscribe(tokenAddress, TokenEvents.Approval, indexFilterValues, callback);
await zeroEx.token.setAllowanceAsync(tokenAddress, coinbase, addressWithoutFunds, allowanceAmount);
@@ -88,7 +76,7 @@ describe('SubscriptionTest', () => {
});
it('Should allow unsubscribeAll to be called successfully after an error', (done: DoneCallback) => {
(async () => {
- const callback = (err: Error, logEvent: DecodedLogEvent<ApprovalContractEventArgs>) => _.noop;
+ const callback = (err: Error | null, logEvent?: DecodedLogEvent<ApprovalContractEventArgs>) => _.noop;
zeroEx.token.subscribe(tokenAddress, TokenEvents.Approval, indexFilterValues, callback);
stubs = [Sinon.stub((zeroEx as any)._web3Wrapper, 'getBlockAsync').throws(new Error('JSON RPC error'))];
zeroEx.token.unsubscribeAll();