diff options
Diffstat (limited to 'packages/contracts/test')
-rw-r--r-- | packages/contracts/test/ether_token.ts | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/packages/contracts/test/ether_token.ts b/packages/contracts/test/ether_token.ts index d4e478099..fd7321280 100644 --- a/packages/contracts/test/ether_token.ts +++ b/packages/contracts/test/ether_token.ts @@ -20,12 +20,6 @@ describe('EtherToken', () => { const gasPrice = ZeroEx.toBaseUnitAmount(new BigNumber(20), 9); let zeroEx: ZeroEx; let etherTokenAddress: string; - const sendTransactionAsync = promisify<string>(web3.eth.sendTransaction); - const getEthBalanceAsync = async (owner: string) => { - const balanceStr = await promisify<string>(web3.eth.getBalance)(owner); - const balance = new BigNumber(balanceStr); - return balance; - }; before(async () => { const accounts = await web3Wrapper.getAvailableAddressesAsync(); account = accounts[0]; @@ -45,7 +39,7 @@ describe('EtherToken', () => { }); describe('deposit', () => { it('should throw if caller attempts to deposit more Ether than caller balance', async () => { - const initEthBalance = await getEthBalanceAsync(account); + const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); const ethToDeposit = initEthBalance.plus(1); return expect(zeroEx.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account)).to.be.rejectedWith( @@ -54,7 +48,7 @@ describe('EtherToken', () => { }); it('should convert deposited Ether to wrapped Ether tokens', async () => { - const initEthBalance = await getEthBalanceAsync(account); + const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); const initEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account); const ethToDeposit = new BigNumber(web3.toWei(1, 'ether')); @@ -63,7 +57,7 @@ describe('EtherToken', () => { const receipt = await zeroEx.awaitTransactionMinedAsync(txHash); const ethSpentOnGas = gasPrice.times(receipt.gasUsed); - const finalEthBalance = await getEthBalanceAsync(account); + const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); const finalEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account); expect(finalEthBalance).to.be.bignumber.equal(initEthBalance.minus(ethToDeposit.plus(ethSpentOnGas))); @@ -85,7 +79,7 @@ describe('EtherToken', () => { const ethToDeposit = new BigNumber(web3.toWei(1, 'ether')); await zeroEx.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account); const initEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account); - const initEthBalance = await getEthBalanceAsync(account); + const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); const ethTokensToWithdraw = initEthTokenBalance; expect(ethTokensToWithdraw).to.not.be.bignumber.equal(0); const txHash = await zeroEx.etherToken.withdrawAsync(etherTokenAddress, ethTokensToWithdraw, account, { @@ -94,7 +88,7 @@ describe('EtherToken', () => { const receipt = await zeroEx.awaitTransactionMinedAsync(txHash); const ethSpentOnGas = gasPrice.times(receipt.gasUsed); - const finalEthBalance = await getEthBalanceAsync(account); + const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); const finalEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account); expect(finalEthBalance).to.be.bignumber.equal( @@ -106,12 +100,12 @@ describe('EtherToken', () => { describe('fallback', () => { it('should convert sent ether to ether tokens', async () => { - const initEthBalance = await getEthBalanceAsync(account); + const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); const initEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account); const ethToDeposit = ZeroEx.toBaseUnitAmount(new BigNumber(1), 18); - const txHash = await sendTransactionAsync({ + const txHash = await web3Wrapper.sendTransactionAsync({ from: account, to: etherTokenAddress, value: ethToDeposit, @@ -121,7 +115,7 @@ describe('EtherToken', () => { const receipt = await zeroEx.awaitTransactionMinedAsync(txHash); const ethSpentOnGas = gasPrice.times(receipt.gasUsed); - const finalEthBalance = await getEthBalanceAsync(account); + const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); const finalEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account); expect(finalEthBalance).to.be.bignumber.equal(initEthBalance.minus(ethToDeposit.plus(ethSpentOnGas))); |