From 8813bd26f6f0be60c175ad0d7cd4a7d4c23d278a Mon Sep 17 00:00:00 2001 From: fabioberger Date: Fri, 8 Nov 2019 22:58:22 +0000 Subject: [PATCH] Pass around DevUtilsContract so it's only instantiated once --- contracts/exchange/test/exchange_transfer_simulator_test.ts | 2 +- contracts/exchange/test/utils/exchange_transfer_simulator.ts | 4 ++-- .../exchange/test/utils/fill_order_combinatorial_utils.ts | 2 +- contracts/exchange/test/utils/fill_order_simulator.ts | 5 +++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/contracts/exchange/test/exchange_transfer_simulator_test.ts b/contracts/exchange/test/exchange_transfer_simulator_test.ts index c14777e8d3..1363047157 100644 --- a/contracts/exchange/test/exchange_transfer_simulator_test.ts +++ b/contracts/exchange/test/exchange_transfer_simulator_test.ts @@ -88,7 +88,7 @@ blockchainTests('ExchangeTransferSimulator', env => { const balanceAndProxyAllowanceLazyStore = new BalanceAndProxyAllowanceLazyStore( simpleERC20BalanceAndProxyAllowanceFetcher, ); - exchangeTransferSimulator = new ExchangeTransferSimulator(balanceAndProxyAllowanceLazyStore, env.provider); + exchangeTransferSimulator = new ExchangeTransferSimulator(balanceAndProxyAllowanceLazyStore, devUtils); }); it("throws if the user doesn't have enough allowance", async () => { return expect( diff --git a/contracts/exchange/test/utils/exchange_transfer_simulator.ts b/contracts/exchange/test/utils/exchange_transfer_simulator.ts index 25364154fe..0c520517b0 100644 --- a/contracts/exchange/test/utils/exchange_transfer_simulator.ts +++ b/contracts/exchange/test/utils/exchange_transfer_simulator.ts @@ -55,9 +55,9 @@ export class ExchangeTransferSimulator { * @param store A class that implements AbstractBalanceAndProxyAllowanceLazyStore * @return an instance of ExchangeTransferSimulator */ - constructor(store: AbstractBalanceAndProxyAllowanceLazyStore, provider: SupportedProvider) { + constructor(store: AbstractBalanceAndProxyAllowanceLazyStore, devUtilsContract: DevUtilsContract) { this._store = store; - this._devUtils = new DevUtilsContract(constants.NULL_ADDRESS, provider); + this._devUtils = devUtilsContract; } /** * Simulates transferFrom call performed by a proxy diff --git a/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts b/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts index f0dbcb3d2e..14af32ccdd 100644 --- a/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts +++ b/contracts/exchange/test/utils/fill_order_combinatorial_utils.ts @@ -504,7 +504,7 @@ export class FillOrderCombinatorialUtils { takerAssetFillAmount: BigNumber, lazyStore: BalanceAndProxyAllowanceLazyStore, ): Promise { - const simulator = new FillOrderSimulator(lazyStore, this.provider); + const simulator = new FillOrderSimulator(lazyStore, devUtils); return simulator.simulateFillOrderAsync(signedOrder, this.takerAddress, takerAssetFillAmount); } diff --git a/contracts/exchange/test/utils/fill_order_simulator.ts b/contracts/exchange/test/utils/fill_order_simulator.ts index 0254c584d1..5b24338478 100644 --- a/contracts/exchange/test/utils/fill_order_simulator.ts +++ b/contracts/exchange/test/utils/fill_order_simulator.ts @@ -1,3 +1,4 @@ +import { DevUtilsContract } from '@0x/contracts-dev-utils'; import { constants, orderUtils } from '@0x/contracts-test-utils'; import { Order, SupportedProvider } from '@0x/order-utils'; import { FillResults } from '@0x/types'; @@ -25,9 +26,9 @@ export class FillOrderSimulator { public readonly lazyStore: LazyStore; private readonly _transferSimulator: ExchangeTransferSimulator; - constructor(lazyStore: LazyStore, provider: SupportedProvider) { + constructor(lazyStore: LazyStore, devUtilsContract: DevUtilsContract) { this.lazyStore = lazyStore; - this._transferSimulator = new ExchangeTransferSimulator(lazyStore, provider); + this._transferSimulator = new ExchangeTransferSimulator(lazyStore, devUtilsContract); } public async simulateFillOrderAsync(