diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-10-04 00:05:44 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-10-04 16:14:20 +0800 |
commit | 451ded4963aaaa40ff4d00bcb0d589b06b45ce24 (patch) | |
tree | d7c0a8aee987531fddf45f78c0309559acc73a33 /test/exchange_wrapper_test.ts | |
parent | 837618c7a016b9b66d70f3c0e9682c97a9d4cf8a (diff) | |
download | dexon-sol-tools-451ded4963aaaa40ff4d00bcb0d589b06b45ce24.tar dexon-sol-tools-451ded4963aaaa40ff4d00bcb0d589b06b45ce24.tar.gz dexon-sol-tools-451ded4963aaaa40ff4d00bcb0d589b06b45ce24.tar.bz2 dexon-sol-tools-451ded4963aaaa40ff4d00bcb0d589b06b45ce24.tar.lz dexon-sol-tools-451ded4963aaaa40ff4d00bcb0d589b06b45ce24.tar.xz dexon-sol-tools-451ded4963aaaa40ff4d00bcb0d589b06b45ce24.tar.zst dexon-sol-tools-451ded4963aaaa40ff4d00bcb0d589b06b45ce24.zip |
Add tests for zeroEx.exchange.getLogsAsync
Diffstat (limited to 'test/exchange_wrapper_test.ts')
-rw-r--r-- | test/exchange_wrapper_test.ts | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts index 45a2d3907..ab709a446 100644 --- a/test/exchange_wrapper_test.ts +++ b/test/exchange_wrapper_test.ts @@ -771,4 +771,46 @@ describe('ExchangeWrapper', () => { expect(zrxAddress).to.equal(zrxToken.address); }); }); + describe('#getLogsAsync', () => { + let makerTokenAddress: string; + let takerTokenAddress: string; + let makerAddress: string; + let takerAddress: string; + const fillableAmount = new BigNumber(5); + const shouldThrowOnInsufficientBalanceOrAllowance = true; + const subscriptionOpts: SubscriptionOpts = { + fromBlock: 0, + toBlock: 'latest', + }; + const indexFilterValues = {}; + before(async () => { + [, makerAddress, takerAddress] = userAddresses; + const [makerToken, takerToken] = tokenUtils.getNonProtocolTokens(); + makerTokenAddress = makerToken.address; + takerTokenAddress = takerToken.address; + }); + it('should get logs with decoded args emitted by LogFill', async () => { + const signedOrder = await fillScenarios.createFillableSignedOrderAsync( + makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount, + ); + await zeroEx.exchange.fillOrderAsync( + signedOrder, fillableAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress, + ); + const eventName = ExchangeEvents.LogFill; + const logs = await zeroEx.exchange.getLogsAsync(eventName, subscriptionOpts, indexFilterValues); + expect(logs).to.have.length(1); + expect(logs[0].event).to.be.equal(eventName); + }); + it('should only get the logs with the correct event name', async () => { + const signedOrder = await fillScenarios.createFillableSignedOrderAsync( + makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount, + ); + await zeroEx.exchange.fillOrderAsync( + signedOrder, fillableAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress, + ); + const differentEventName = ExchangeEvents.LogCancel; + const logs = await zeroEx.exchange.getLogsAsync(differentEventName, subscriptionOpts, indexFilterValues); + expect(logs).to.have.length(0); + }); + }); }); |