From df904f80e323376ff8dd6aabca445fa9f0be9c1b Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 6 Sep 2017 00:18:07 +0200 Subject: Add test for logs decoding in awaitTransactionMinedAsync --- test/0x.js_test.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/0x.js_test.ts') diff --git a/test/0x.js_test.ts b/test/0x.js_test.ts index 2b4e80ea3..c545b3fbe 100644 --- a/test/0x.js_test.ts +++ b/test/0x.js_test.ts @@ -6,6 +6,7 @@ import * as BigNumber from 'bignumber.js'; import * as Sinon from 'sinon'; import {ZeroEx, Order} from '../src'; import {constants} from './utils/constants'; +import {TokenUtils} from './utils/token_utils'; import {web3Factory} from './utils/web3_factory'; chaiSetup.configure(); @@ -204,4 +205,23 @@ describe('ZeroEx library', () => { expect(ecSignature).to.deep.equal(expectedECSignature); }); }); + describe('#awaitTransactionMinedAsync', () => { + it('return transaction receipt with decoded logs', async () => { + const availableAddresses = await zeroEx.getAvailableAddressesAsync(); + const coinbase = availableAddresses[0]; + const tokens = await zeroEx.tokenRegistry.getTokensAsync(); + const tokenUtils = new TokenUtils(tokens); + const zrxTokenAddress = tokenUtils.getProtocolTokenOrThrow().address; + const proxyAddress = await zeroEx.proxy.getContractAddressAsync(); + const txHash = await zeroEx.token.setUnlimitedProxyAllowanceAsync(zrxTokenAddress, coinbase); + const txReceiptWithDecodedLogs = await zeroEx.awaitTransactionMinedAsync(txHash); + const log = txReceiptWithDecodedLogs.logs[0]; + expect(log.event).to.be.equal('Approval'); + expect(log.args).to.be.deep.equal({ + _owner: coinbase, + _spender: proxyAddress, + _value: zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS.toString(), + }); + }); + }); }); -- cgit v1.2.3 From 8ebc724379ad9047ad3f546985ed5a4c013ac7dd Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 6 Sep 2017 00:40:22 +0200 Subject: Add lifecycle methods --- test/0x.js_test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/0x.js_test.ts') diff --git a/test/0x.js_test.ts b/test/0x.js_test.ts index c545b3fbe..d9c08d2c5 100644 --- a/test/0x.js_test.ts +++ b/test/0x.js_test.ts @@ -8,7 +8,9 @@ import {ZeroEx, Order} from '../src'; import {constants} from './utils/constants'; import {TokenUtils} from './utils/token_utils'; import {web3Factory} from './utils/web3_factory'; +import {BlockchainLifecycle} from './utils/blockchain_lifecycle'; +const blockchainLifecycle = new BlockchainLifecycle(); chaiSetup.configure(); const expect = chai.expect; @@ -206,6 +208,12 @@ describe('ZeroEx library', () => { }); }); describe('#awaitTransactionMinedAsync', () => { + beforeEach(async () => { + await blockchainLifecycle.startAsync(); + }); + afterEach(async () => { + await blockchainLifecycle.revertAsync(); + }); it('return transaction receipt with decoded logs', async () => { const availableAddresses = await zeroEx.getAvailableAddressesAsync(); const coinbase = availableAddresses[0]; -- cgit v1.2.3 From 258b4fac31aee1bc0c26e42d62b10bd22c69c1b8 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 6 Sep 2017 10:26:22 +0200 Subject: Fix a typo in test name --- test/0x.js_test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/0x.js_test.ts') diff --git a/test/0x.js_test.ts b/test/0x.js_test.ts index d9c08d2c5..c453b8dab 100644 --- a/test/0x.js_test.ts +++ b/test/0x.js_test.ts @@ -214,7 +214,7 @@ describe('ZeroEx library', () => { afterEach(async () => { await blockchainLifecycle.revertAsync(); }); - it('return transaction receipt with decoded logs', async () => { + it('returns transaction receipt with decoded logs', async () => { const availableAddresses = await zeroEx.getAvailableAddressesAsync(); const coinbase = availableAddresses[0]; const tokens = await zeroEx.tokenRegistry.getTokensAsync(); -- cgit v1.2.3