From 23b7226a73865b055915624ec957d1cb8aed407b Mon Sep 17 00:00:00 2001 From: David Racero Date: Wed, 9 Sep 2020 16:35:49 +0200 Subject: [PATCH] Fix bignumber global test config --- test/__setup.spec.ts | 4 ++-- test/liquidation-underlying.spec.ts | 6 ++++++ test/scenario.spec.ts | 9 +++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/test/__setup.spec.ts b/test/__setup.spec.ts index 689ecf3a..e2db2752 100644 --- a/test/__setup.spec.ts +++ b/test/__setup.spec.ts @@ -504,8 +504,8 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => { const mockFlashLoanReceiver = await deployMockFlashLoanReceiver(addressesProvider.address); await insertContractAddressInDb(eContractid.MockFlashLoanReceiver, mockFlashLoanReceiver.address); - const mockSwapAdapter = await deployMockSwapAdapter(addressesProvider.address) - await insertContractAddressInDb(eContractid.MockSwapAdapter, mockSwapAdapter.address) + const mockSwapAdapter = await deployMockSwapAdapter(addressesProvider.address); + await insertContractAddressInDb(eContractid.MockSwapAdapter, mockSwapAdapter.address); await deployWalletBalancerProvider(addressesProvider.address); diff --git a/test/liquidation-underlying.spec.ts b/test/liquidation-underlying.spec.ts index 676c9c26..9a58965e 100644 --- a/test/liquidation-underlying.spec.ts +++ b/test/liquidation-underlying.spec.ts @@ -19,6 +19,12 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset', USER_DID_NOT_BORROW_SPECIFIED, THE_COLLATERAL_CHOSEN_CANNOT_BE_LIQUIDATED, } = ProtocolErrors; + before('Before LendingPool liquidation: set config', () => { + BigNumber.config({DECIMAL_PLACES: 0, ROUNDING_MODE: BigNumber.ROUND_DOWN}); + }); + after('After LendingPool liquidation: reset config', () => { + BigNumber.config({DECIMAL_PLACES: 20, ROUNDING_MODE: BigNumber.ROUND_HALF_UP}); + }); it('LIQUIDATION - Deposits WETH, borrows DAI', async () => { const {dai, weth, users, pool, oracle} = testEnv; diff --git a/test/scenario.spec.ts b/test/scenario.spec.ts index 5d449d76..54fe7433 100644 --- a/test/scenario.spec.ts +++ b/test/scenario.spec.ts @@ -8,8 +8,6 @@ import {getReservesConfigByPool} from '../helpers/constants'; import {AavePools, iAavePoolAssets, IReserveParams} from '../helpers/types'; import {executeStory} from './helpers/scenario-engine'; -BigNumber.config({DECIMAL_PLACES: 0, ROUNDING_MODE: BigNumber.ROUND_DOWN}); - const scenarioFolder = './test/helpers/scenarios/'; const selectedScenarios: string[] = []; @@ -21,12 +19,19 @@ fs.readdirSync(scenarioFolder).forEach((file) => { makeSuite(scenario.title, async (testEnv) => { before('Initializing configuration', async () => { + // Sets BigNumber for this suite, instead of globally + BigNumber.config({DECIMAL_PLACES: 0, ROUNDING_MODE: BigNumber.ROUND_DOWN}); + actionsConfiguration.skipIntegrityCheck = false; //set this to true to execute solidity-coverage calculationsConfiguration.reservesParams = >( getReservesConfigByPool(AavePools.proto) ); }); + after('Reset', () => { + // Reset BigNumber + BigNumber.config({DECIMAL_PLACES: 20, ROUNDING_MODE: BigNumber.ROUND_HALF_UP}); + }); for (const story of scenario.stories) { it(story.description, async () => {