Skip to content

Commit

Permalink
refactor: changed all the revert operations in tests to the same naming
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanVerbner committed Jun 29, 2021
1 parent 4d08f6e commit 70f4a3b
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 51 deletions.
6 changes: 3 additions & 3 deletions packages/contracts/test/CollSurplusPool.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ contract('CollSurplusPool', async accounts => {
await deploymentHelper.connectLQTYContractsToCore(LQTYContracts, contracts)
})

let snapshotId;
let revertToSnapshot;

beforeEach(async() => {
let snapshot = await timeMachine.takeSnapshot();
snapshotId = snapshot['result'];
revertToSnapshot = () => timeMachine.revertToSnapshot(snapshot['result'])
});

afterEach(async() => {
await timeMachine.revertToSnapshot(snapshotId);
await revertToSnapshot();
});

it("CollSurplusPool::getETH(): Returns the ETH balance of the CollSurplusPool after redemption", async () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/contracts/test/FeeArithmeticTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,15 @@ contract('Fee arithmetic tests', async accounts => {
await deploymentHelper.connectLQTYContractsToCore(LQTYContracts, contracts)
})

let snapshotId;
let revertToSnapshot;

beforeEach(async() => {
let snapshot = await timeMachine.takeSnapshot();
snapshotId = snapshot['result'];
revertToSnapshot = () => timeMachine.revertToSnapshot(snapshot['result'])
});

afterEach(async() => {
await timeMachine.revertToSnapshot(snapshotId);
await revertToSnapshot();
});

it("minutesPassedSinceLastFeeOp(): returns minutes passed for no time increase", async () => {
Expand Down
8 changes: 4 additions & 4 deletions packages/contracts/test/GasCompensationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ contract('Gas compensation tests', async accounts => {
await deploymentHelper.connectLQTYContractsToCore(LQTYContracts, contracts)
})

let snapshotId;
let revertToSnapshot;

beforeEach(async() => {
let snapshot = await timeMachine.takeSnapshot();
snapshotId = snapshot['result'];
revertToSnapshot = () => timeMachine.revertToSnapshot(snapshot['result'])
});

afterEach(async() => {
await timeMachine.revertToSnapshot(snapshotId);
});
await revertToSnapshot();
});

// --- Raw gas compensation calculations ---

Expand Down
6 changes: 3 additions & 3 deletions packages/contracts/test/GrowthTokenTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ contract('LQTY Token', async accounts => {
await deploymentHelper.connectLQTYContractsToCore(LQTYContracts, contracts)
})

let snapshotId;
let revertToSnapshot;

beforeEach(async() => {
let snapshot = await timeMachine.takeSnapshot();
snapshotId = snapshot['result'];
revertToSnapshot = () => timeMachine.revertToSnapshot(snapshot['result'])
});

afterEach(async() => {
await timeMachine.revertToSnapshot(snapshotId);
await revertToSnapshot();
});

it('balanceOf(): gets the balance of the account', async () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/contracts/test/LQTYIssuanceArithmeticTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ contract('LQTY community issuance arithmetic tests', async accounts => {
await deploymentHelper.connectLQTYContractsToCore(LQTYContracts, contracts)
})

let snapshotId;
let revertToSnapshot;

beforeEach(async() => {
let snapshot = await timeMachine.takeSnapshot();
snapshotId = snapshot['result'];
revertToSnapshot = () => timeMachine.revertToSnapshot(snapshot['result'])
});

afterEach(async() => {
await timeMachine.revertToSnapshot(snapshotId);
await revertToSnapshot();
});

// Accuracy tests
Expand Down
10 changes: 5 additions & 5 deletions packages/contracts/test/StabilityPoolTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ contract('StabilityPool', async accounts => {
await th.registerFrontEnds(frontEnds, stabilityPool)
})

let snapshotId;
let revertToSnapshot;

beforeEach(async() => {
let snapshot = await timeMachine.takeSnapshot();
snapshotId = snapshot['result'];
revertToSnapshot = () => timeMachine.revertToSnapshot(snapshot['result'])
});

afterEach(async() => {
await timeMachine.revertToSnapshot(snapshotId);
})

await revertToSnapshot();
});
// --- provideToSP() ---
// increases recorded LUSD at Stability Pool
it("provideToSP(): increases the Stability Pool LUSD balance", async () => {
Expand Down
8 changes: 4 additions & 4 deletions packages/contracts/test/StabilityPool_LQTYIssuanceTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,16 @@ contract('StabilityPool - LQTY Rewards', async accounts => {
issuance_M6 = toBN('41651488815552900').mul(communityLQTYSupply).div(toBN(dec(1, 18)))
})

let snapshotId;
let revertToSnapshot;

beforeEach(async() => {
let snapshot = await timeMachine.takeSnapshot();
snapshotId = snapshot['result'];
revertToSnapshot = () => timeMachine.revertToSnapshot(snapshot['result'])
});

afterEach(async() => {
await timeMachine.revertToSnapshot(snapshotId);
})
await revertToSnapshot();
});

it("liquidation < 1 minute after a deposit does not change totalLQTYIssued", async () => {

Expand Down
9 changes: 4 additions & 5 deletions packages/contracts/test/StabilityPool_SPWithdrawalTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,16 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations'
await deploymentHelper.connectLQTYContractsToCore(LQTYContracts, contracts)
})

let snapshotId;
let revertToSnapshot;

beforeEach(async() => {
let snapshot = await timeMachine.takeSnapshot();
snapshotId = snapshot['result'];
revertToSnapshot = () => timeMachine.revertToSnapshot(snapshot['result'])
});

afterEach(async() => {
await timeMachine.revertToSnapshot(snapshotId);
})

await revertToSnapshot();
});
// --- Compounding tests ---

// --- withdrawFromSP()
Expand Down
10 changes: 5 additions & 5 deletions packages/contracts/test/StabilityPool_SPWithdrawalToCDPTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations'
await deploymentHelper.connectLQTYContractsToCore(LQTYContracts, contracts)
})

let snapshotId;
let revertToSnapshot;

beforeEach(async() => {
let snapshot = await timeMachine.takeSnapshot();
snapshotId = snapshot['result'];
revertToSnapshot = () => timeMachine.revertToSnapshot(snapshot['result'])
});

afterEach(async() => {
await timeMachine.revertToSnapshot(snapshotId);
})

await revertToSnapshot();
});
// --- Compounding tests ---

// --- withdrawETHGainToTrove() ---
Expand Down
8 changes: 4 additions & 4 deletions packages/contracts/test/TroveManagerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@ contract('TroveManager', async accounts => {
await deploymentHelper.connectLQTYContractsToCore(LQTYContracts, contracts)
})

let snapshotId;
let revertToSnapshot;

beforeEach(async() => {
let snapshot = await timeMachine.takeSnapshot();
snapshotId = snapshot['result'];
revertToSnapshot = () => timeMachine.revertToSnapshot(snapshot['result'])
});

afterEach(async() => {
await timeMachine.revertToSnapshot(snapshotId);
})
await revertToSnapshot();
});

it('liquidate(): closes a Trove that has ICR < MCR', async () => {
await openTrove({ ICR: toBN(dec(20, 18)), extraParams: { from: whale } })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ contract('TroveManager - Redistribution reward calculations', async accounts =>
await deploymentHelper.connectLQTYContractsToCore(LQTYContracts, contracts)
})

let snapshotId;
let revertToSnapshot;

beforeEach(async() => {
let snapshot = await timeMachine.takeSnapshot();
snapshotId = snapshot['result'];
revertToSnapshot = () => timeMachine.revertToSnapshot(snapshot['result'])
});

afterEach(async() => {
await timeMachine.revertToSnapshot(snapshotId);
})
await revertToSnapshot();
});

it("redistribution: A, B Open. B Liquidated. C, D Open. D Liquidated. Distributes correct rewards", async () => {
// A, B open trove
Expand Down
8 changes: 4 additions & 4 deletions packages/contracts/test/TroveManager_RecoveryModeTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,16 @@ contract('TroveManager - in Recovery Mode', async accounts => {
await deploymentHelper.connectLQTYContractsToCore(LQTYContracts, contracts)
})

let snapshotId;
let revertToSnapshot;

beforeEach(async() => {
let snapshot = await timeMachine.takeSnapshot();
snapshotId = snapshot['result'];
revertToSnapshot = () => timeMachine.revertToSnapshot(snapshot['result'])
});

afterEach(async() => {
await timeMachine.revertToSnapshot(snapshotId);
})
await revertToSnapshot();
});

it("checkRecoveryMode(): Returns true if TCR falls below CCR", async () => {
// --- SETUP ---
Expand Down
8 changes: 4 additions & 4 deletions packages/contracts/test/stakeDeclineTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ contract('TroveManager', async accounts => {
await deploymentHelper.connectLQTYContractsToCore(LQTYContracts, contracts)
})

let snapshotId;
let revertToSnapshot;

beforeEach(async() => {
let snapshot = await timeMachine.takeSnapshot();
snapshotId = snapshot['result'];
revertToSnapshot = () => timeMachine.revertToSnapshot(snapshot['result'])
});

afterEach(async() => {
await timeMachine.revertToSnapshot(snapshotId);
})
await revertToSnapshot();
});

it("A given trove's stake decline is negligible with adjustments and tiny liquidations", async () => {
await priceFeed.setPrice(dec(100, 18))
Expand Down

0 comments on commit 70f4a3b

Please sign in to comment.