diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-07-05 01:19:03 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-07-05 01:26:43 +0800 |
commit | 5611df82f9f276fb161fa268f7ab468a6c1d7784 (patch) | |
tree | f65656f97027193acb941a13e42bf14735aeda43 | |
parent | f39a2134b946ab2c7f24b9fcc49f95156e7682d5 (diff) | |
download | dexon-sol-tools-5611df82f9f276fb161fa268f7ab468a6c1d7784.tar dexon-sol-tools-5611df82f9f276fb161fa268f7ab468a6c1d7784.tar.gz dexon-sol-tools-5611df82f9f276fb161fa268f7ab468a6c1d7784.tar.bz2 dexon-sol-tools-5611df82f9f276fb161fa268f7ab468a6c1d7784.tar.lz dexon-sol-tools-5611df82f9f276fb161fa268f7ab468a6c1d7784.tar.xz dexon-sol-tools-5611df82f9f276fb161fa268f7ab468a6c1d7784.tar.zst dexon-sol-tools-5611df82f9f276fb161fa268f7ab468a6c1d7784.zip |
Refactor event tests
-rw-r--r-- | src/contract_wrappers/token_wrapper.ts | 4 | ||||
-rw-r--r-- | test/token_wrapper_test.ts | 25 |
2 files changed, 12 insertions, 17 deletions
diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts index 1e087e8b0..d3ef5d6cf 100644 --- a/src/contract_wrappers/token_wrapper.ts +++ b/src/contract_wrappers/token_wrapper.ts @@ -205,10 +205,6 @@ export class TokenWrapper extends ContractWrapper { */ public async subscribeAsync(tokenAddress: string, eventName: TokenEvents, subscriptionOpts: SubscriptionOpts, indexFilterValues: IndexedFilterValues): Promise<ContractEventEmitter> { - assert.isETHAddressHex('tokenAddress', tokenAddress); - // assert.isEventName('eventName', eventName); - assert.doesConformToSchema('subscriptionOpts', subscriptionOpts, subscriptionOptsSchema); - assert.doesConformToSchema('indexFilterValues', indexFilterValues, indexFilterValuesSchema); const tokenContract = await this._getTokenContractAsync(tokenAddress); let createLogEvent: CreateContractEvent; switch (eventName) { diff --git a/test/token_wrapper_test.ts b/test/token_wrapper_test.ts index c5a08dc43..6ac1beb43 100644 --- a/test/token_wrapper_test.ts +++ b/test/token_wrapper_test.ts @@ -13,6 +13,7 @@ import { TokenEvents, ContractEvent, TransferContractEventArgs, + ApprovalContractEventArgs, } from '../src'; import {BlockchainLifecycle} from './utils/blockchain_lifecycle'; import {DoneCallback} from '../src/types'; @@ -269,11 +270,10 @@ describe('TokenWrapper', () => { zeroExEvent.watch((err: Error, event: ContractEvent) => { expect(err).to.be.null(); expect(event).to.not.be.undefined(); - expect(event.args as TransferContractEventArgs).to.be.deep.equal({ - _from: coinbase, - _to: addressWithoutFunds, - _value: transferAmount, - }); + const args = event.args as TransferContractEventArgs; + expect(args._from).to.be.equal(coinbase); + expect(args._to).to.be.equal(addressWithoutFunds); + expect(args._value).to.be.equal(transferAmount); done(); }); await zeroEx.token.transferAsync(tokenAddress, coinbase, addressWithoutFunds, transferAmount); @@ -284,14 +284,13 @@ describe('TokenWrapper', () => { const zeroExEvent = await zeroEx.token.subscribeAsync( tokenAddress, TokenEvents.Approval, subscriptionOpts, indexFilterValues); zeroExEvent.watch((err: Error, event: ContractEvent) => { - expect(err).to.be.null(); - expect(event).to.not.be.undefined(); - expect(event.args as TransferContractEventArgs).to.be.deep.equal({ - _owner: coinbase, - _spender: addressWithoutFunds, - _value: allowanceAmount, - }); - done(); + expect(err).to.be.null(); + expect(event).to.not.be.undefined(); + const args = event.args as ApprovalContractEventArgs; + expect(args._owner).to.be.equal(coinbase); + expect(args._spender).to.be.equal(addressWithoutFunds); + expect(args._value).to.be.equal(allowanceAmount); + done(); }); await zeroEx.token.setAllowanceAsync(tokenAddress, coinbase, addressWithoutFunds, allowanceAmount); })().catch(done); |