aboutsummaryrefslogtreecommitdiffstats
path: root/test/token_wrapper_test.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-10-03 20:53:37 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-10-04 16:14:19 +0800
commit087645e59fb78a1ce20bbbcabe12317f11324e93 (patch)
treedbc62150782675bde989c2ba25056f1fc9c95024 /test/token_wrapper_test.ts
parent0a12fa7f4e83562d48e143c30cb59645aa6b9b7a (diff)
downloaddexon-sol-tools-087645e59fb78a1ce20bbbcabe12317f11324e93.tar
dexon-sol-tools-087645e59fb78a1ce20bbbcabe12317f11324e93.tar.gz
dexon-sol-tools-087645e59fb78a1ce20bbbcabe12317f11324e93.tar.bz2
dexon-sol-tools-087645e59fb78a1ce20bbbcabe12317f11324e93.tar.lz
dexon-sol-tools-087645e59fb78a1ce20bbbcabe12317f11324e93.tar.xz
dexon-sol-tools-087645e59fb78a1ce20bbbcabe12317f11324e93.tar.zst
dexon-sol-tools-087645e59fb78a1ce20bbbcabe12317f11324e93.zip
Add tests for zeroEx.token.getLogsAsync
Diffstat (limited to 'test/token_wrapper_test.ts')
-rw-r--r--test/token_wrapper_test.ts37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/token_wrapper_test.ts b/test/token_wrapper_test.ts
index 68dca0769..aacd9de40 100644
--- a/test/token_wrapper_test.ts
+++ b/test/token_wrapper_test.ts
@@ -14,6 +14,7 @@ import {
ContractEvent,
TransferContractEventArgs,
ApprovalContractEventArgs,
+ LogWithDecodedArgs,
} from '../src';
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
import {TokenUtils} from './utils/token_utils';
@@ -435,4 +436,40 @@ describe('TokenWrapper', () => {
})().catch(done);
});
});
+ describe('#getLogsAsync', () => {
+ let tokenAddress: string;
+ let tokenTransferProxyAddress: string;
+ const subscriptionOpts: SubscriptionOpts = {
+ fromBlock: 0,
+ toBlock: 'latest',
+ };
+ const indexFilterValues = {};
+ before(async () => {
+ const token = tokens[0];
+ tokenAddress = token.address;
+ tokenTransferProxyAddress = await zeroEx.proxy.getContractAddressAsync();
+ });
+ it('should get logs with decoded args emitted by Approval', async () => {
+ const txHash = await zeroEx.token.setUnlimitedProxyAllowanceAsync(tokenAddress, coinbase);
+ await zeroEx.awaitTransactionMinedAsync(txHash);
+ const eventName = TokenEvents.Approval;
+ const logs = await zeroEx.token.getLogsAsync(
+ tokenAddress, eventName, subscriptionOpts, indexFilterValues,
+ ) as LogWithDecodedArgs[];
+ expect(logs).to.have.length(1);
+ expect(logs[0].event).to.be.equal(eventName);
+ expect(logs[0].args._owner).to.be.equal(coinbase);
+ expect(logs[0].args._spender).to.be.equal(tokenTransferProxyAddress);
+ expect(logs[0].args._value).to.be.bignumber.equal(zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS);
+ });
+ it('should only get the logs with the correct event name', async () => {
+ const txHash = await zeroEx.token.setUnlimitedProxyAllowanceAsync(tokenAddress, coinbase);
+ await zeroEx.awaitTransactionMinedAsync(txHash);
+ const differentEventName = TokenEvents.Transfer;
+ const logs = await zeroEx.token.getLogsAsync(
+ tokenAddress, differentEventName, subscriptionOpts, indexFilterValues,
+ ) as LogWithDecodedArgs[];
+ expect(logs).to.have.length(0);
+ });
+ });
});