Skip to content

Commit

Permalink
test: Add case when reset isolationDebt with non-zero debtCeiling
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmtzinf committed Dec 27, 2021
1 parent 35b4346 commit e043b80
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export enum ProtocolErrors {
VL_DEBT_CEILING_CROSSED = '108',
SL_USER_IN_ISOLATION_MODE = '109',
PC_BRIDGE_PROTOCOL_FEE_INVALID = '110',
DEBT_CEILING_NOT_ZERO = '111',

// SafeCast
UINT128_OVERFLOW = "SafeCast: value doesn't fit in 128 bits",
Expand Down
34 changes: 34 additions & 0 deletions test-suites/pool-edge.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ makeSuite('Pool: Edge cases', (testEnv: TestEnv) => {
P_CALLER_NOT_POOL_CONFIGURATOR,
RL_RESERVE_ALREADY_INITIALIZED,
PC_INVALID_CONFIGURATION,
DEBT_CEILING_NOT_ZERO,
} = ProtocolErrors;

const MAX_STABLE_RATE_BORROW_SIZE_PERCENT = '2500';
Expand Down Expand Up @@ -558,4 +559,37 @@ makeSuite('Pool: Edge cases', (testEnv: TestEnv) => {
);
expect((await pool.getReservesList()).length).to.be.eq(await pool.MAX_NUMBER_RESERVES());
});

it('Call `resetIsolationModeTotalDebt()` to reset isolationModeTotalDebt of an asset with non-zero debt ceiling', async () => {
const {
configurator,
pool,
helpersContract,
dai,
poolAdmin,
deployer,
users: [user0],
} = testEnv;

const snapId = await evmSnapshot();

const debtCeiling = utils.parseUnits('10', 18);

expect(await helpersContract.getDebtCeiling(dai.address)).to.be.eq(0);

await configurator.connect(poolAdmin.signer).setDebtCeiling(dai.address, debtCeiling);

expect(await helpersContract.getDebtCeiling(dai.address)).to.be.eq(debtCeiling);

// Impersonate PoolConfigurator
await topUpNonPayableWithEther(deployer.signer, [configurator.address], utils.parseEther('1'));
await impersonateAccountsHardhat([configurator.address]);
const configSigner = await hre.ethers.getSigner(configurator.address);

await expect(
pool.connect(configSigner).resetIsolationModeTotalDebt(dai.address)
).to.be.revertedWith(DEBT_CEILING_NOT_ZERO);

await evmRevert(snapId);
});
});

0 comments on commit e043b80

Please sign in to comment.