diff options
author | Fabio Berger <me@fabioberger.com> | 2018-05-23 04:02:21 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-05-23 04:02:21 +0800 |
commit | 2b793f372abc444702406539588f2101d9dc5307 (patch) | |
tree | 5d407c63d4fc5ebaa9537bf0bca2346c684a1a82 /packages/contracts/test/asset_proxy/proxies.ts | |
parent | 9119ee14b6d49b2c339b786f92913ff8a93ff610 (diff) | |
parent | 4cfeb6b8ace9c1613ac0581bd6ea52ff183701f9 (diff) | |
download | dexon-sol-tools-2b793f372abc444702406539588f2101d9dc5307.tar.gz dexon-sol-tools-2b793f372abc444702406539588f2101d9dc5307.tar.zst dexon-sol-tools-2b793f372abc444702406539588f2101d9dc5307.zip |
Merge branch 'v2-prototype' into refactor/contracts/remove0xjsDep
* v2-prototype:
Fix tslint issues
Add `are` to boolean naming conventions
Fix tslint
Fix the tsutils version, fixing ts typings issue
Rename some variables in multi_sig_with_time_lock.ts
Remove extra awaitTransactionMinedAsync calls
Update artifacts
Update yarn.lock
Fix warnings in Metacoin
Upgrade UglifyJS to include ES6 support
Add CancelOrder and MatchOrder types
Add missing return types
Ignore classnames linter rule
Apply changes to test/exchange/match_orders.ts
Fix some unhandled promise rejections
Add awaitTransactionMinedAsync after every sent transaction
Add missing blockchainLifecycle calls to contracts tests
# Conflicts:
# packages/contracts/src/utils/exchange_wrapper.ts
# packages/contracts/test/asset_proxy/proxies.ts
# packages/contracts/test/exchange/dispatcher.ts
# packages/contracts/test/multi_sig_with_time_lock.ts
Diffstat (limited to 'packages/contracts/test/asset_proxy/proxies.ts')
-rw-r--r-- | packages/contracts/test/asset_proxy/proxies.ts | 95 |
1 files changed, 61 insertions, 34 deletions
diff --git a/packages/contracts/test/asset_proxy/proxies.ts b/packages/contracts/test/asset_proxy/proxies.ts index 3c72968d3..4ee38db80 100644 --- a/packages/contracts/test/asset_proxy/proxies.ts +++ b/packages/contracts/test/asset_proxy/proxies.ts @@ -37,6 +37,12 @@ describe('Asset Transfer Proxies', () => { let erc721MakerTokenId: BigNumber; before(async () => { + await blockchainLifecycle.startAsync(); + }); + after(async () => { + await blockchainLifecycle.revertAsync(); + }); + before(async () => { const accounts = await web3Wrapper.getAvailableAddressesAsync(); const usedAddresses = ([owner, notAuthorized, exchangeAddress, makerAddress, takerAddress] = accounts); @@ -46,18 +52,24 @@ describe('Asset Transfer Proxies', () => { [zrxToken] = await erc20Wrapper.deployDummyTokensAsync(); erc20Proxy = await erc20Wrapper.deployProxyAsync(); await erc20Wrapper.setBalancesAndAllowancesAsync(); - await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeAddress, { - from: owner, - }); + await web3Wrapper.awaitTransactionMinedAsync( + await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeAddress, { + from: owner, + }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); [erc721Token] = await erc721Wrapper.deployDummyTokensAsync(); erc721Proxy = await erc721Wrapper.deployProxyAsync(); await erc721Wrapper.setBalancesAndAllowancesAsync(); const erc721Balances = await erc721Wrapper.getBalancesAsync(); erc721MakerTokenId = erc721Balances[makerAddress][erc721Token.address][0]; - await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeAddress, { - from: owner, - }); + await web3Wrapper.awaitTransactionMinedAsync( + await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeAddress, { + from: owner, + }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); }); beforeEach(async () => { await blockchainLifecycle.startAsync(); @@ -73,12 +85,15 @@ describe('Asset Transfer Proxies', () => { // Perform a transfer from makerAddress to takerAddress const erc20Balances = await erc20Wrapper.getBalancesAsync(); const amount = new BigNumber(10); - await erc20Proxy.transferFrom.sendTransactionAsync( - encodedProxyMetadata, - makerAddress, - takerAddress, - amount, - { from: exchangeAddress }, + await web3Wrapper.awaitTransactionMinedAsync( + await erc20Proxy.transferFrom.sendTransactionAsync( + encodedProxyMetadata, + makerAddress, + takerAddress, + amount, + { from: exchangeAddress }, + ), + constants.AWAIT_TRANSACTION_MINED_MS, ); // Verify transfer was successful const newBalances = await erc20Wrapper.getBalancesAsync(); @@ -96,12 +111,15 @@ describe('Asset Transfer Proxies', () => { // Perform a transfer from makerAddress to takerAddress const erc20Balances = await erc20Wrapper.getBalancesAsync(); const amount = new BigNumber(0); - await erc20Proxy.transferFrom.sendTransactionAsync( - encodedProxyMetadata, - makerAddress, - takerAddress, - amount, - { from: exchangeAddress }, + await web3Wrapper.awaitTransactionMinedAsync( + await erc20Proxy.transferFrom.sendTransactionAsync( + encodedProxyMetadata, + makerAddress, + takerAddress, + amount, + { from: exchangeAddress }, + ), + constants.AWAIT_TRANSACTION_MINED_MS, ); // Verify transfer was successful const newBalances = await erc20Wrapper.getBalancesAsync(); @@ -119,9 +137,12 @@ describe('Asset Transfer Proxies', () => { // Create allowance less than transfer amount. Set allowance on proxy. const allowance = new BigNumber(0); const transferAmount = new BigNumber(10); - await zrxToken.approve.sendTransactionAsync(erc20Proxy.address, allowance, { - from: makerAddress, - }); + await web3Wrapper.awaitTransactionMinedAsync( + await zrxToken.approve.sendTransactionAsync(erc20Proxy.address, allowance, { + from: makerAddress, + }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); // Perform a transfer; expect this to fail. return expect( erc20Proxy.transferFrom.sendTransactionAsync( @@ -172,7 +193,7 @@ describe('Asset Transfer Proxies', () => { amounts, { from: exchangeAddress }, ); - const res = await web3Wrapper.awaitTransactionMinedAsync(txHash); + const res = await web3Wrapper.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); const newBalances = await erc20Wrapper.getBalancesAsync(); expect(res.logs.length).to.equal(numTransfers); @@ -193,7 +214,7 @@ describe('Asset Transfer Proxies', () => { const toAddresses = _.times(numTransfers, () => takerAddress); const amounts = _.times(numTransfers, () => amount); - expect( + return expect( erc20Proxy.batchTransferFrom.sendTransactionAsync( assetMetadata, fromAddresses, @@ -225,12 +246,15 @@ describe('Asset Transfer Proxies', () => { // Perform a transfer from makerAddress to takerAddress const erc20Balances = await erc20Wrapper.getBalancesAsync(); const amount = new BigNumber(1); - await erc721Proxy.transferFrom.sendTransactionAsync( - encodedProxyMetadata, - makerAddress, - takerAddress, - amount, - { from: exchangeAddress }, + await web3Wrapper.awaitTransactionMinedAsync( + await erc721Proxy.transferFrom.sendTransactionAsync( + encodedProxyMetadata, + makerAddress, + takerAddress, + amount, + { from: exchangeAddress }, + ), + constants.AWAIT_TRANSACTION_MINED_MS, ); // Verify transfer was successful const newOwnerMakerAsset = await erc721Token.ownerOf.callAsync(erc721MakerTokenId); @@ -290,9 +314,12 @@ describe('Asset Transfer Proxies', () => { erc721MakerTokenId, ); // Remove transfer approval for makerAddress. - await erc721Token.setApprovalForAll.sendTransactionAsync(erc721Proxy.address, false, { - from: makerAddress, - }); + await web3Wrapper.awaitTransactionMinedAsync( + await erc721Token.setApprovalForAll.sendTransactionAsync(erc721Proxy.address, false, { + from: makerAddress, + }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); // Perform a transfer; expect this to fail. const amount = new BigNumber(1); return expect( @@ -349,7 +376,7 @@ describe('Asset Transfer Proxies', () => { amounts, { from: exchangeAddress }, ); - const res = await web3Wrapper.awaitTransactionMinedAsync(txHash); + const res = await web3Wrapper.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); expect(res.logs.length).to.equal(numTransfers); const newOwnerMakerAssetA = await erc721Token.ownerOf.callAsync(makerTokenIdA); @@ -371,7 +398,7 @@ describe('Asset Transfer Proxies', () => { const toAddresses = _.times(numTransfers, () => takerAddress); const amounts = _.times(numTransfers, () => new BigNumber(1)); - expect( + return expect( erc721Proxy.batchTransferFrom.sendTransactionAsync( assetMetadata, fromAddresses, |