diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2017-12-12 14:47:47 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2017-12-13 07:05:30 +0800 |
commit | b97f140b78a0420943291af57d122bc90a488112 (patch) | |
tree | 29a3dfac4f8fecddba716171432270bbc53cfff4 /packages/contracts | |
parent | 1dda4d5f78705d96934a08f00000e9a98a3bbc3d (diff) | |
download | dexon-0x-contracts-b97f140b78a0420943291af57d122bc90a488112.tar.gz dexon-0x-contracts-b97f140b78a0420943291af57d122bc90a488112.tar.zst dexon-0x-contracts-b97f140b78a0420943291af57d122bc90a488112.zip |
Add gas limits to failing tests
Diffstat (limited to 'packages/contracts')
-rw-r--r-- | packages/contracts/test/ts/ether_token.ts | 3 | ||||
-rw-r--r-- | packages/contracts/test/ts/ether_token_v2.ts | 6 | ||||
-rw-r--r-- | packages/contracts/test/ts/unlimited_allowance_token.ts | 9 | ||||
-rw-r--r-- | packages/contracts/test/ts/unlimited_allowance_token_v2.ts | 9 | ||||
-rw-r--r-- | packages/contracts/test/ts/zrx_token.ts | 15 | ||||
-rw-r--r-- | packages/contracts/util/constants.ts | 3 |
6 files changed, 31 insertions, 14 deletions
diff --git a/packages/contracts/test/ts/ether_token.ts b/packages/contracts/test/ts/ether_token.ts index 79c618ec2..db281e511 100644 --- a/packages/contracts/test/ts/ether_token.ts +++ b/packages/contracts/test/ts/ether_token.ts @@ -81,7 +81,8 @@ contract('EtherToken', (accounts: string[]) => { const initEthBalance = await getEthBalanceAsync(account); const ethTokensToWithdraw = initEthTokenBalance; expect(ethTokensToWithdraw).to.not.be.bignumber.equal(0); - const txHash = await zeroEx.etherToken.withdrawAsync(ethTokensToWithdraw, account); + const txHash = await zeroEx.etherToken.withdrawAsync(ethTokensToWithdraw, account, + {gasLimit: constants.MAX_ETHERTOKEN_WITHDRAW_GAS}); const receipt = await zeroEx.awaitTransactionMinedAsync(txHash); const ethSpentOnGas = gasPrice.times(receipt.gasUsed); diff --git a/packages/contracts/test/ts/ether_token_v2.ts b/packages/contracts/test/ts/ether_token_v2.ts index 4931eb798..174403445 100644 --- a/packages/contracts/test/ts/ether_token_v2.ts +++ b/packages/contracts/test/ts/ether_token_v2.ts @@ -104,7 +104,8 @@ contract('EtherTokenV2', (accounts: string[]) => { const initEthBalance = await getEthBalanceAsync(account); const ethTokensToWithdraw = initEthTokenBalance; expect(ethTokensToWithdraw).to.not.be.bignumber.equal(0); - const txHash = await zeroEx.etherToken.withdrawAsync(ethTokensToWithdraw, account); + const txHash = await zeroEx.etherToken.withdrawAsync(ethTokensToWithdraw, account, + {gasLimit: constants.MAX_ETHERTOKEN_WITHDRAW_GAS}); const receipt = await zeroEx.awaitTransactionMinedAsync(txHash); const ethSpentOnGas = gasPrice.times(receipt.gasUsed); @@ -121,7 +122,8 @@ contract('EtherTokenV2', (accounts: string[]) => { const initEthBalance = await getEthBalanceAsync(account); const ethTokensToWithdraw = initEthTokenBalance; expect(ethTokensToWithdraw).to.not.be.bignumber.equal(0); - const txHash = await zeroEx.etherToken.withdrawAsync(ethTokensToWithdraw, account); + const txHash = await zeroEx.etherToken.withdrawAsync(ethTokensToWithdraw, account, + {gasLimit: constants.MAX_ETHERTOKEN_WITHDRAW_GAS}); const receipt = await zeroEx.awaitTransactionMinedAsync(txHash); const logs = receipt.logs; diff --git a/packages/contracts/test/ts/unlimited_allowance_token.ts b/packages/contracts/test/ts/unlimited_allowance_token.ts index 3b4d2db77..a328563cd 100644 --- a/packages/contracts/test/ts/unlimited_allowance_token.ts +++ b/packages/contracts/test/ts/unlimited_allowance_token.ts @@ -85,7 +85,8 @@ contract('UnlimitedAllowanceToken', (accounts: string[]) => { const amountToTransfer = initOwnerBalance; const initSpenderAllowance = zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS; await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance); - await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer); + await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, + {gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS}); const newSpenderAllowance = await zeroEx.token.getAllowanceAsync(tokenAddress, owner, spender); expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance); @@ -96,7 +97,8 @@ contract('UnlimitedAllowanceToken', (accounts: string[]) => { const amountToTransfer = initOwnerBalance; const initSpenderAllowance = initOwnerBalance; await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance); - await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer); + await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, + {gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS}); const newOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner); const newSpenderBalance = await zeroEx.token.getBalanceAsync(tokenAddress, spender); @@ -110,7 +112,8 @@ contract('UnlimitedAllowanceToken', (accounts: string[]) => { const amountToTransfer = initOwnerBalance; const initSpenderAllowance = initOwnerBalance; await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance); - await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer); + await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, + {gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS}); const newSpenderAllowance = await zeroEx.token.getAllowanceAsync(tokenAddress, owner, spender); expect(newSpenderAllowance).to.be.bignumber.equal(0); diff --git a/packages/contracts/test/ts/unlimited_allowance_token_v2.ts b/packages/contracts/test/ts/unlimited_allowance_token_v2.ts index 73e12f00c..137fcd8a5 100644 --- a/packages/contracts/test/ts/unlimited_allowance_token_v2.ts +++ b/packages/contracts/test/ts/unlimited_allowance_token_v2.ts @@ -92,7 +92,8 @@ contract('UnlimitedAllowanceTokenV2', (accounts: string[]) => { const amountToTransfer = initOwnerBalance; const initSpenderAllowance = zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS; await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance); - await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer); + await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, + {gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS}); const newSpenderAllowance = await zeroEx.token.getAllowanceAsync(tokenAddress, owner, spender); expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance); @@ -103,7 +104,8 @@ contract('UnlimitedAllowanceTokenV2', (accounts: string[]) => { const amountToTransfer = initOwnerBalance; const initSpenderAllowance = initOwnerBalance; await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance); - await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer); + await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, + {gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS}); const newOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner); const newSpenderBalance = await zeroEx.token.getBalanceAsync(tokenAddress, spender); @@ -117,7 +119,8 @@ contract('UnlimitedAllowanceTokenV2', (accounts: string[]) => { const amountToTransfer = initOwnerBalance; const initSpenderAllowance = initOwnerBalance; await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance); - await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer); + await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer, + {gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS}); const newSpenderAllowance = await zeroEx.token.getAllowanceAsync(tokenAddress, owner, spender); expect(newSpenderAllowance).to.be.bignumber.equal(0); diff --git a/packages/contracts/test/ts/zrx_token.ts b/packages/contracts/test/ts/zrx_token.ts index 1c9655402..6312056b2 100644 --- a/packages/contracts/test/ts/zrx_token.ts +++ b/packages/contracts/test/ts/zrx_token.ts @@ -94,12 +94,14 @@ contract('ZRXToken', (accounts: string[]) => { it('should return false if owner has insufficient balance', async () => { const ownerBalance = await zeroEx.token.getBalanceAsync(zrxAddress, owner); const amountToTransfer = ownerBalance.plus(1); - let txHash = await zeroEx.token.setAllowanceAsync(zrxAddress, owner, spender, amountToTransfer); + let txHash = await zeroEx.token.setAllowanceAsync(zrxAddress, owner, spender, amountToTransfer, + {gasLimit: constants.MAX_TOKEN_APPROVE_GAS}); await zeroEx.awaitTransactionMinedAsync(txHash); const didReturnTrue = await zrx.transferFrom.call(owner, spender, amountToTransfer, {from: spender}); expect(didReturnTrue).to.be.false(); // Reset allowance - txHash = await zeroEx.token.setAllowanceAsync(zrxAddress, owner, spender, new BigNumber(0)); + txHash = await zeroEx.token.setAllowanceAsync(zrxAddress, owner, spender, new BigNumber(0), + {gasLimit: constants.MAX_TOKEN_APPROVE_GAS}); await zeroEx.awaitTransactionMinedAsync(txHash); }); @@ -127,7 +129,8 @@ contract('ZRXToken', (accounts: string[]) => { const initSpenderAllowance = MAX_UINT; let txHash = await zeroEx.token.setAllowanceAsync(zrxAddress, owner, spender, initSpenderAllowance); await zeroEx.awaitTransactionMinedAsync(txHash); - txHash = await zeroEx.token.transferFromAsync(zrxAddress, owner, spender, spender, amountToTransfer); + txHash = await zeroEx.token.transferFromAsync(zrxAddress, owner, spender, spender, amountToTransfer, + {gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS}); await zeroEx.awaitTransactionMinedAsync(txHash); const newSpenderAllowance = await zeroEx.token.getAllowanceAsync(zrxAddress, owner, spender); @@ -144,7 +147,8 @@ contract('ZRXToken', (accounts: string[]) => { const initSpenderAllowance = initOwnerBalance; let txHash = await zeroEx.token.setAllowanceAsync(zrxAddress, owner, spender, initSpenderAllowance); await zeroEx.awaitTransactionMinedAsync(txHash); - txHash = await zeroEx.token.transferFromAsync(zrxAddress, owner, spender, spender, amountToTransfer); + txHash = await zeroEx.token.transferFromAsync(zrxAddress, owner, spender, spender, amountToTransfer, + {gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS}); await zeroEx.awaitTransactionMinedAsync(txHash); const newOwnerBalance = await zeroEx.token.getBalanceAsync(zrxAddress, owner); @@ -160,7 +164,8 @@ contract('ZRXToken', (accounts: string[]) => { const initSpenderAllowance = initOwnerBalance; let txHash = await zeroEx.token.setAllowanceAsync(zrxAddress, owner, spender, initSpenderAllowance); await zeroEx.awaitTransactionMinedAsync(txHash); - txHash = await zeroEx.token.transferFromAsync(zrxAddress, owner, spender, spender, amountToTransfer); + txHash = await zeroEx.token.transferFromAsync(zrxAddress, owner, spender, spender, amountToTransfer, + {gasLimit: constants.MAX_TOKEN_TRANSFERFROM_GAS}); await zeroEx.awaitTransactionMinedAsync(txHash); const newSpenderAllowance = await zeroEx.token.getAllowanceAsync(zrxAddress, owner, spender); diff --git a/packages/contracts/util/constants.ts b/packages/contracts/util/constants.ts index c28a18e27..e61b2f802 100644 --- a/packages/contracts/util/constants.ts +++ b/packages/contracts/util/constants.ts @@ -3,4 +3,7 @@ export const constants = { INVALID_OPCODE: 'invalid opcode', REVERT: 'revert', TESTRPC_NETWORK_ID: 50, + MAX_ETHERTOKEN_WITHDRAW_GAS: 43000, + MAX_TOKEN_TRANSFERFROM_GAS: 80000, + MAX_TOKEN_APPROVE_GAS: 60000, }; |