aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/0x.js/test/utils/fill_scenarios.ts25
-rw-r--r--packages/0x.js/test/utils/token_utils.ts9
2 files changed, 30 insertions, 4 deletions
diff --git a/packages/0x.js/test/utils/fill_scenarios.ts b/packages/0x.js/test/utils/fill_scenarios.ts
index 090493935..bcaa63c78 100644
--- a/packages/0x.js/test/utils/fill_scenarios.ts
+++ b/packages/0x.js/test/utils/fill_scenarios.ts
@@ -1,10 +1,15 @@
+import {Web3Wrapper} from '@0xproject/web3-wrapper';
import BigNumber from 'bignumber.js';
import {SignedOrder, Token, ZeroEx} from '../../src';
+import {artifacts} from '../../src/artifacts';
+import {DummyTokenContract} from '../../src/contract_wrappers/generated/dummy_token';
import {orderFactory} from '../utils/order_factory';
import {constants} from './constants';
+const INITIAL_COINBASE_TOKEN_SUPPLY_IN_UNITS = new BigNumber(100);
+
export class FillScenarios {
private zeroEx: ZeroEx;
private userAddresses: string[];
@@ -21,6 +26,26 @@ export class FillScenarios {
this.zrxTokenAddress = zrxTokenAddress;
this.exchangeContractAddress = exchangeContractAddress;
}
+ public async initTokenBalancesAsync() {
+ const web3Wrapper = (this.zeroEx as any)._web3Wrapper as Web3Wrapper;
+ for (const token of this.tokens) {
+ if (token.symbol === 'WETH') {
+ // _.noop
+ } else if (token.symbol !== 'ZRX') {
+ const contractInstance = web3Wrapper.getContractInstance(
+ artifacts.DummyTokenArtifact.abi, token.address,
+ );
+ const dummyToken = new DummyTokenContract(contractInstance, {});
+ const tokenSupply = ZeroEx.toBaseUnitAmount(INITIAL_COINBASE_TOKEN_SUPPLY_IN_UNITS, token.decimals);
+ const txHash = await dummyToken.setBalance.sendTransactionAsync(this.coinbase, tokenSupply, {
+ from: this.coinbase,
+ });
+ await this.zeroEx.awaitTransactionMinedAsync(txHash);
+ } else {
+ // no-op
+ }
+ }
+ }
public async createFillableSignedOrderAsync(makerTokenAddress: string, takerTokenAddress: string,
makerAddress: string, takerAddress: string,
fillableAmount: BigNumber,
diff --git a/packages/0x.js/test/utils/token_utils.ts b/packages/0x.js/test/utils/token_utils.ts
index 9c20f52a1..4634899a7 100644
--- a/packages/0x.js/test/utils/token_utils.ts
+++ b/packages/0x.js/test/utils/token_utils.ts
@@ -3,6 +3,7 @@ import * as _ from 'lodash';
import {InternalZeroExError, Token} from '../../src/types';
const PROTOCOL_TOKEN_SYMBOL = 'ZRX';
+const WETH_TOKEN_SYMBOL = 'WETH';
export class TokenUtils {
private tokens: Token[];
@@ -16,10 +17,10 @@ export class TokenUtils {
}
return zrxToken;
}
- public getNonProtocolTokens(): Token[] {
- const nonProtocolTokens = _.filter(this.tokens, token => {
- return token.symbol !== PROTOCOL_TOKEN_SYMBOL;
+ public getDummyTokens(): Token[] {
+ const dummyTokens = _.filter(this.tokens, token => {
+ return !_.includes([PROTOCOL_TOKEN_SYMBOL, WETH_TOKEN_SYMBOL], token.symbol);
});
- return nonProtocolTokens;
+ return dummyTokens;
}
}