Make BlockchainLifecycle accept only web3Wrapper
This commit is contained in:
parent
49ff4299c6
commit
32e3cab116
@ -10,9 +10,9 @@ import { ApprovalContractEventArgs, LogWithDecodedArgs, Order, TokenEvents, Zero
|
|||||||
import { chaiSetup } from './utils/chai_setup';
|
import { chaiSetup } from './utils/chai_setup';
|
||||||
import { constants } from './utils/constants';
|
import { constants } from './utils/constants';
|
||||||
import { TokenUtils } from './utils/token_utils';
|
import { TokenUtils } from './utils/token_utils';
|
||||||
|
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||||
|
|
||||||
const web3 = web3Factory.create();
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3);
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
|
|
||||||
|
@ -23,11 +23,11 @@ import { chaiSetup } from './utils/chai_setup';
|
|||||||
import { constants } from './utils/constants';
|
import { constants } from './utils/constants';
|
||||||
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
|
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
|
||||||
import { TokenUtils } from './utils/token_utils';
|
import { TokenUtils } from './utils/token_utils';
|
||||||
|
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
const web3 = web3Factory.create();
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3);
|
|
||||||
|
|
||||||
// Since the address depositing/withdrawing ETH/WETH also needs to pay gas costs for the transaction,
|
// Since the address depositing/withdrawing ETH/WETH also needs to pay gas costs for the transaction,
|
||||||
// a small amount of ETH will be used to pay this gas cost. We therefore check that the difference between
|
// a small amount of ETH will be used to pay this gas cost. We therefore check that the difference between
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
|
import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils';
|
||||||
import { BlockParamLiteral } from '@0xproject/types';
|
import { BlockParamLiteral } from '@0xproject/types';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
@ -9,11 +9,11 @@ import { ExchangeTransferSimulator } from '../src/utils/exchange_transfer_simula
|
|||||||
|
|
||||||
import { chaiSetup } from './utils/chai_setup';
|
import { chaiSetup } from './utils/chai_setup';
|
||||||
import { constants } from './utils/constants';
|
import { constants } from './utils/constants';
|
||||||
|
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
const web3 = web3Factory.create();
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3);
|
|
||||||
|
|
||||||
describe('ExchangeTransferSimulator', () => {
|
describe('ExchangeTransferSimulator', () => {
|
||||||
const config = {
|
const config = {
|
||||||
|
@ -26,11 +26,11 @@ import { constants } from './utils/constants';
|
|||||||
import { FillScenarios } from './utils/fill_scenarios';
|
import { FillScenarios } from './utils/fill_scenarios';
|
||||||
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
|
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
|
||||||
import { TokenUtils } from './utils/token_utils';
|
import { TokenUtils } from './utils/token_utils';
|
||||||
|
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
const web3 = web3Factory.create();
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3);
|
|
||||||
|
|
||||||
const NON_EXISTENT_ORDER_HASH = '0x79370342234e7acd6bbeac335bd3bb1d368383294b64b8160a00f4060e4d3777';
|
const NON_EXISTENT_ORDER_HASH = '0x79370342234e7acd6bbeac335bd3bb1d368383294b64b8160a00f4060e4d3777';
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
|
import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
@ -16,11 +16,11 @@ import { constants } from './utils/constants';
|
|||||||
import { FillScenarios } from './utils/fill_scenarios';
|
import { FillScenarios } from './utils/fill_scenarios';
|
||||||
import { reportNoErrorCallbackErrors } from './utils/report_callback_errors';
|
import { reportNoErrorCallbackErrors } from './utils/report_callback_errors';
|
||||||
import { TokenUtils } from './utils/token_utils';
|
import { TokenUtils } from './utils/token_utils';
|
||||||
|
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
const web3 = web3Factory.create();
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3);
|
|
||||||
|
|
||||||
describe('ExpirationWatcher', () => {
|
describe('ExpirationWatcher', () => {
|
||||||
let zeroEx: ZeroEx;
|
let zeroEx: ZeroEx;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
|
import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
@ -22,13 +22,13 @@ import { constants } from './utils/constants';
|
|||||||
import { FillScenarios } from './utils/fill_scenarios';
|
import { FillScenarios } from './utils/fill_scenarios';
|
||||||
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
|
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
|
||||||
import { TokenUtils } from './utils/token_utils';
|
import { TokenUtils } from './utils/token_utils';
|
||||||
|
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||||
|
|
||||||
const TIMEOUT_MS = 150;
|
const TIMEOUT_MS = 150;
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
const web3 = web3Factory.create();
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3);
|
|
||||||
|
|
||||||
describe('OrderStateWatcher', () => {
|
describe('OrderStateWatcher', () => {
|
||||||
let zeroEx: ZeroEx;
|
let zeroEx: ZeroEx;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
|
import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils';
|
||||||
import { BlockParamLiteral } from '@0xproject/types';
|
import { BlockParamLiteral } from '@0xproject/types';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
@ -14,11 +14,11 @@ import { chaiSetup } from './utils/chai_setup';
|
|||||||
import { constants } from './utils/constants';
|
import { constants } from './utils/constants';
|
||||||
import { FillScenarios } from './utils/fill_scenarios';
|
import { FillScenarios } from './utils/fill_scenarios';
|
||||||
import { TokenUtils } from './utils/token_utils';
|
import { TokenUtils } from './utils/token_utils';
|
||||||
|
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
const web3 = web3Factory.create();
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3);
|
|
||||||
|
|
||||||
describe('OrderValidation', () => {
|
describe('OrderValidation', () => {
|
||||||
let zeroEx: ZeroEx;
|
let zeroEx: ZeroEx;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
|
import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import 'mocha';
|
import 'mocha';
|
||||||
@ -11,10 +11,10 @@ import { DoneCallback } from '../src/types';
|
|||||||
import { chaiSetup } from './utils/chai_setup';
|
import { chaiSetup } from './utils/chai_setup';
|
||||||
import { constants } from './utils/constants';
|
import { constants } from './utils/constants';
|
||||||
import { assertNodeCallbackError } from './utils/report_callback_errors';
|
import { assertNodeCallbackError } from './utils/report_callback_errors';
|
||||||
|
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const web3 = web3Factory.create();
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3);
|
|
||||||
|
|
||||||
describe('SubscriptionTest', () => {
|
describe('SubscriptionTest', () => {
|
||||||
let zeroEx: ZeroEx;
|
let zeroEx: ZeroEx;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
|
import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils';
|
||||||
import { schemas, SchemaValidator } from '@0xproject/json-schemas';
|
import { schemas, SchemaValidator } from '@0xproject/json-schemas';
|
||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
@ -8,11 +8,11 @@ import { Token, ZeroEx } from '../src';
|
|||||||
|
|
||||||
import { chaiSetup } from './utils/chai_setup';
|
import { chaiSetup } from './utils/chai_setup';
|
||||||
import { constants } from './utils/constants';
|
import { constants } from './utils/constants';
|
||||||
|
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
const web3 = web3Factory.create();
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3);
|
|
||||||
|
|
||||||
const TOKEN_REGISTRY_SIZE_AFTER_MIGRATION = 7;
|
const TOKEN_REGISTRY_SIZE_AFTER_MIGRATION = 7;
|
||||||
|
|
||||||
|
@ -22,11 +22,11 @@ import { chaiSetup } from './utils/chai_setup';
|
|||||||
import { constants } from './utils/constants';
|
import { constants } from './utils/constants';
|
||||||
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
|
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
|
||||||
import { TokenUtils } from './utils/token_utils';
|
import { TokenUtils } from './utils/token_utils';
|
||||||
|
import { web3, web3Wrapper } from './utils/web3_wrapper';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
const web3 = web3Factory.create();
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3);
|
|
||||||
|
|
||||||
describe('TokenWrapper', () => {
|
describe('TokenWrapper', () => {
|
||||||
let zeroEx: ZeroEx;
|
let zeroEx: ZeroEx;
|
||||||
@ -35,13 +35,11 @@ describe('TokenWrapper', () => {
|
|||||||
let tokenUtils: TokenUtils;
|
let tokenUtils: TokenUtils;
|
||||||
let coinbase: string;
|
let coinbase: string;
|
||||||
let addressWithoutFunds: string;
|
let addressWithoutFunds: string;
|
||||||
let web3Wrapper: Web3Wrapper;
|
|
||||||
const config = {
|
const config = {
|
||||||
networkId: constants.TESTRPC_NETWORK_ID,
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
};
|
};
|
||||||
before(async () => {
|
before(async () => {
|
||||||
zeroEx = new ZeroEx(web3.currentProvider, config);
|
zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||||
web3Wrapper = new Web3Wrapper(web3.currentProvider);
|
|
||||||
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
||||||
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
||||||
tokenUtils = new TokenUtils(tokens);
|
tokenUtils = new TokenUtils(tokens);
|
||||||
|
@ -4,10 +4,8 @@ import * as Web3 from 'web3';
|
|||||||
export class BlockchainLifecycle {
|
export class BlockchainLifecycle {
|
||||||
private _web3Wrapper: Web3Wrapper;
|
private _web3Wrapper: Web3Wrapper;
|
||||||
private _snapshotIdsStack: number[];
|
private _snapshotIdsStack: number[];
|
||||||
constructor(web3Orweb3Wrapper: Web3Wrapper | Web3) {
|
constructor(web3Wrapper: Web3Wrapper) {
|
||||||
this._web3Wrapper = (web3Orweb3Wrapper as Web3Wrapper).isZeroExWeb3Wrapper
|
this._web3Wrapper = web3Wrapper;
|
||||||
? (web3Orweb3Wrapper as Web3Wrapper)
|
|
||||||
: new Web3Wrapper((web3Orweb3Wrapper as Web3).currentProvider);
|
|
||||||
this._snapshotIdsStack = [];
|
this._snapshotIdsStack = [];
|
||||||
}
|
}
|
||||||
// TODO: In order to run these tests on an actual node, we should check if we are running against
|
// TODO: In order to run these tests on an actual node, we should check if we are running against
|
||||||
|
Loading…
x
Reference in New Issue
Block a user