diff options
author | Alex Browne <stephenalexbrowne@gmail.com> | 2018-05-23 02:48:41 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-23 02:48:41 +0800 |
commit | cde85243d6eaf9376f499aa1cc28bd393130c2b9 (patch) | |
tree | 168bde1ea63c4c5c3c4741ca486a2f43c58fab4e /packages/contracts/test/exchange/wrapper.ts | |
parent | c579db1a7bec0b5fdec8d120121375224de46d5d (diff) | |
parent | e26c0c58aeb435e4fbec1b111b77d51b67dacdbe (diff) | |
download | dexon-sol-tools-cde85243d6eaf9376f499aa1cc28bd393130c2b9.tar dexon-sol-tools-cde85243d6eaf9376f499aa1cc28bd393130c2b9.tar.gz dexon-sol-tools-cde85243d6eaf9376f499aa1cc28bd393130c2b9.tar.bz2 dexon-sol-tools-cde85243d6eaf9376f499aa1cc28bd393130c2b9.tar.lz dexon-sol-tools-cde85243d6eaf9376f499aa1cc28bd393130c2b9.tar.xz dexon-sol-tools-cde85243d6eaf9376f499aa1cc28bd393130c2b9.tar.zst dexon-sol-tools-cde85243d6eaf9376f499aa1cc28bd393130c2b9.zip |
Merge pull request #601 from 0xProject/contracts-test-fixes
Contracts test fixes
Diffstat (limited to 'packages/contracts/test/exchange/wrapper.ts')
-rw-r--r-- | packages/contracts/test/exchange/wrapper.ts | 60 |
1 files changed, 42 insertions, 18 deletions
diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts index 0b79308dd..caaceb460 100644 --- a/packages/contracts/test/exchange/wrapper.ts +++ b/packages/contracts/test/exchange/wrapper.ts @@ -57,6 +57,12 @@ describe('Exchange wrappers', () => { let zeroEx: ZeroEx; before(async () => { + await blockchainLifecycle.startAsync(); + }); + after(async () => { + await blockchainLifecycle.revertAsync(); + }); + before(async () => { const accounts = await web3Wrapper.getAvailableAddressesAsync(); const usedAddresses = ([owner, makerAddress, takerAddress, feeRecipientAddress] = accounts); @@ -88,12 +94,18 @@ describe('Exchange wrappers', () => { await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC20, erc20Proxy.address, owner); await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC721, erc721Proxy.address, owner); - await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { - from: owner, - }); - await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { - from: owner, - }); + await web3Wrapper.awaitTransactionMinedAsync( + await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { + from: owner, + }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); + await web3Wrapper.awaitTransactionMinedAsync( + await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { + from: owner, + }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); defaultMakerAssetAddress = erc20TokenA.address; defaultTakerAssetAddress = erc20TokenB.address; @@ -251,13 +263,19 @@ describe('Exchange wrappers', () => { it('should not change erc20Balances if maker allowances are too low to fill order', async () => { const signedOrder = orderFactory.newSignedOrder(); - await erc20TokenA.approve.sendTransactionAsync(erc20Proxy.address, new BigNumber(0), { - from: makerAddress, - }); + await web3Wrapper.awaitTransactionMinedAsync( + await erc20TokenA.approve.sendTransactionAsync(erc20Proxy.address, new BigNumber(0), { + from: makerAddress, + }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); await exchangeWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress); - await erc20TokenA.approve.sendTransactionAsync(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE, { - from: makerAddress, - }); + await web3Wrapper.awaitTransactionMinedAsync( + await erc20TokenA.approve.sendTransactionAsync(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE, { + from: makerAddress, + }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); const newBalances = await erc20Wrapper.getBalancesAsync(); expect(newBalances).to.be.deep.equal(erc20Balances); @@ -265,13 +283,19 @@ describe('Exchange wrappers', () => { it('should not change erc20Balances if taker allowances are too low to fill order', async () => { const signedOrder = orderFactory.newSignedOrder(); - await erc20TokenB.approve.sendTransactionAsync(erc20Proxy.address, new BigNumber(0), { - from: takerAddress, - }); + await web3Wrapper.awaitTransactionMinedAsync( + await erc20TokenB.approve.sendTransactionAsync(erc20Proxy.address, new BigNumber(0), { + from: takerAddress, + }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); await exchangeWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress); - await erc20TokenB.approve.sendTransactionAsync(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE, { - from: takerAddress, - }); + await web3Wrapper.awaitTransactionMinedAsync( + await erc20TokenB.approve.sendTransactionAsync(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE, { + from: takerAddress, + }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); const newBalances = await erc20Wrapper.getBalancesAsync(); expect(newBalances).to.be.deep.equal(erc20Balances); |