aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/exchange_wrapper_test.ts42
-rw-r--r--test/token_wrapper_test.ts4
2 files changed, 44 insertions, 2 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);
+ });
+ });
});
diff --git a/test/token_wrapper_test.ts b/test/token_wrapper_test.ts
index aacd9de40..7cd33057b 100644
--- a/test/token_wrapper_test.ts
+++ b/test/token_wrapper_test.ts
@@ -455,7 +455,7 @@ describe('TokenWrapper', () => {
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);
@@ -468,7 +468,7 @@ describe('TokenWrapper', () => {
const differentEventName = TokenEvents.Transfer;
const logs = await zeroEx.token.getLogsAsync(
tokenAddress, differentEventName, subscriptionOpts, indexFilterValues,
- ) as LogWithDecodedArgs[];
+ );
expect(logs).to.have.length(0);
});
});