aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/test/token_wrapper_test.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-12-02 13:12:19 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-12-02 13:31:50 +0800
commit78fb8d2bdcc8a8d41dc23dfc29b6858c7658c6b0 (patch)
treef11352d331ec8201f31a3e11b85cbad97f893f22 /packages/0x.js/test/token_wrapper_test.ts
parent5673b42ec47342a1e4be2dd77a5676407a60e401 (diff)
downloaddexon-sol-tools-78fb8d2bdcc8a8d41dc23dfc29b6858c7658c6b0.tar
dexon-sol-tools-78fb8d2bdcc8a8d41dc23dfc29b6858c7658c6b0.tar.gz
dexon-sol-tools-78fb8d2bdcc8a8d41dc23dfc29b6858c7658c6b0.tar.bz2
dexon-sol-tools-78fb8d2bdcc8a8d41dc23dfc29b6858c7658c6b0.tar.lz
dexon-sol-tools-78fb8d2bdcc8a8d41dc23dfc29b6858c7658c6b0.tar.xz
dexon-sol-tools-78fb8d2bdcc8a8d41dc23dfc29b6858c7658c6b0.tar.zst
dexon-sol-tools-78fb8d2bdcc8a8d41dc23dfc29b6858c7658c6b0.zip
Use our promisify
Diffstat (limited to 'packages/0x.js/test/token_wrapper_test.ts')
-rw-r--r--packages/0x.js/test/token_wrapper_test.ts17
1 files changed, 12 insertions, 5 deletions
diff --git a/packages/0x.js/test/token_wrapper_test.ts b/packages/0x.js/test/token_wrapper_test.ts
index c853fe0c2..421bd0a8c 100644
--- a/packages/0x.js/test/token_wrapper_test.ts
+++ b/packages/0x.js/test/token_wrapper_test.ts
@@ -1,6 +1,5 @@
import BigNumber from 'bignumber.js';
import * as chai from 'chai';
-import promisify = require('es6-promisify');
import 'mocha';
import * as Web3 from 'web3';
@@ -19,6 +18,8 @@ import {
ZeroExError,
} from '../src';
import {BlockParamLiteral, DoneCallback} from '../src/types';
+import {promisify} from '../src/utils/promisify';
+import {Web3Wrapper} from '../src/web3_wrapper';
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
import {chaiSetup} from './utils/chai_setup';
@@ -38,12 +39,14 @@ describe('TokenWrapper', () => {
let tokenUtils: TokenUtils;
let coinbase: string;
let addressWithoutFunds: string;
+ let web3Wrapper: Web3Wrapper;
const config = {
networkId: constants.TESTRPC_NETWORK_ID,
};
before(async () => {
web3 = web3Factory.create();
zeroEx = new ZeroEx(web3.currentProvider, config);
+ web3Wrapper = new Web3Wrapper(web3.currentProvider, config.networkId);
userAddresses = await zeroEx.getAvailableAddressesAsync();
tokens = await zeroEx.tokenRegistry.getTokensAsync();
tokenUtils = new TokenUtils(tokens);
@@ -237,8 +240,10 @@ describe('TokenWrapper', () => {
await zeroEx.token.setAllowanceAsync(zrx.address, coinbase, userWithNormalAllowance, transferAmount);
await zeroEx.token.setUnlimitedAllowanceAsync(zrx.address, coinbase, userWithUnlimitedAllowance);
- const initBalanceWithNormalAllowance = await promisify(web3.eth.getBalance)(userWithNormalAllowance);
- const initBalanceWithUnlimitedAllowance = await promisify(web3.eth.getBalance)(userWithUnlimitedAllowance);
+ const initBalanceWithNormalAllowance = await web3Wrapper.getBalanceInWeiAsync(userWithNormalAllowance);
+ const initBalanceWithUnlimitedAllowance = await web3Wrapper.getBalanceInWeiAsync(
+ userWithUnlimitedAllowance,
+ );
await zeroEx.token.transferFromAsync(
zrx.address, coinbase, userWithNormalAllowance, userWithNormalAllowance, transferAmount,
@@ -247,8 +252,10 @@ describe('TokenWrapper', () => {
zrx.address, coinbase, userWithUnlimitedAllowance, userWithUnlimitedAllowance, transferAmount,
);
- const finalBalanceWithNormalAllowance = await promisify(web3.eth.getBalance)(userWithNormalAllowance);
- const finalBalanceWithUnlimitedAllowance = await promisify(web3.eth.getBalance)(userWithUnlimitedAllowance);
+ const finalBalanceWithNormalAllowance = await web3Wrapper.getBalanceInWeiAsync(userWithNormalAllowance);
+ const finalBalanceWithUnlimitedAllowance = await web3Wrapper.getBalanceInWeiAsync(
+ userWithUnlimitedAllowance,
+ );
const normalGasCost = initBalanceWithNormalAllowance.minus(finalBalanceWithNormalAllowance);
const unlimitedGasCost = initBalanceWithUnlimitedAllowance.minus(finalBalanceWithUnlimitedAllowance);