aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-01-26 18:21:06 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-01-30 23:01:37 +0800
commit6f13d107c4ca90049249e44a90b45cac2b490762 (patch)
tree905b7b408ca8d9fcc794ff9cb78b229134bd4dae /packages/contracts
parente56b2ceebb5e18aff0daf8951f3bd854c84bc433 (diff)
downloaddexon-sol-tools-6f13d107c4ca90049249e44a90b45cac2b490762.tar
dexon-sol-tools-6f13d107c4ca90049249e44a90b45cac2b490762.tar.gz
dexon-sol-tools-6f13d107c4ca90049249e44a90b45cac2b490762.tar.bz2
dexon-sol-tools-6f13d107c4ca90049249e44a90b45cac2b490762.tar.lz
dexon-sol-tools-6f13d107c4ca90049249e44a90b45cac2b490762.tar.xz
dexon-sol-tools-6f13d107c4ca90049249e44a90b45cac2b490762.tar.zst
dexon-sol-tools-6f13d107c4ca90049249e44a90b45cac2b490762.zip
Remove promisified web3 functions from tests
Diffstat (limited to 'packages/contracts')
-rw-r--r--packages/contracts/test/ether_token.ts22
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)));