Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

Commit c9778f9

Browse files
committed
feat: pauser test
1 parent 6f2a60c commit c9778f9

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

contracts/test/GlobalPauser.t.sol

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity >=0.8.0;
3+
4+
import { ERC20 } from "solmate/tokens/ERC20.sol";
5+
import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
6+
7+
import "./config/BaseTest.t.sol";
8+
import { IonicComptroller } from "../compound/ComptrollerInterface.sol";
9+
import { GlobalPauser } from "../GlobalPauser.sol";
10+
import { PoolDirectory } from "../PoolDirectory.sol";
11+
import { ICErc20 } from "../compound/CTokenInterfaces.sol";
12+
13+
import "forge-std/console.sol";
14+
15+
contract DevTesting is BaseTest {
16+
address poolDirectory = 0x39C353Cf9041CcF467A04d0e78B63d961E81458a;
17+
18+
address pauseGuardian = 0x1155b614971f16758C92c4890eD338C9e3ede6b7;
19+
address multisig = 0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2;
20+
GlobalPauser pauser;
21+
22+
function afterForkSetUp() internal override {
23+
super.afterForkSetUp();
24+
pauser = new GlobalPauser(poolDirectory);
25+
}
26+
27+
function testPauseNotGuardian(address sender) public debuggingOnly forkAtBlock(MODE_MAINNET, 9110133) {
28+
vm.assume(sender != pauseGuardian);
29+
vm.expectRevert(bytes("!guardian"));
30+
pauser.pauseAll(true);
31+
}
32+
33+
function testPauseAll() public debuggingOnly forkAtBlock(MODE_MAINNET, 9110133) {
34+
(, PoolDirectory.Pool[] memory pools) = PoolDirectory(poolDirectory).getActivePools();
35+
for (uint256 i = 0; i < pools.length; i++) {
36+
ICErc20[] memory markets = IonicComptroller(pools[i].comptroller).getAllMarkets();
37+
for (uint256 j = 0; j < markets.length; j++) {
38+
bool isPaused = IonicComptroller(pools[i].comptroller).borrowGuardianPaused(address(markets[j]));
39+
assertEq(isPaused, false);
40+
isPaused = IonicComptroller(pools[i].comptroller).mintGuardianPaused(address(markets[j]));
41+
assertEq(isPaused, false);
42+
}
43+
}
44+
vm.prank(pauseGuardian);
45+
pauser.pauseAll(true);
46+
for (uint256 i = 0; i < pools.length; i++) {
47+
ICErc20[] memory markets = IonicComptroller(pools[i].comptroller).getAllMarkets();
48+
for (uint256 j = 0; j < markets.length; j++) {
49+
bool isPaused = IonicComptroller(pools[i].comptroller).borrowGuardianPaused(address(markets[j]));
50+
assertEq(isPaused, true);
51+
isPaused = IonicComptroller(pools[i].comptroller).mintGuardianPaused(address(markets[j]));
52+
assertEq(isPaused, true);
53+
}
54+
}
55+
vm.prank(pauseGuardian);
56+
pauser.pauseAll(false);
57+
for (uint256 i = 0; i < pools.length; i++) {
58+
ICErc20[] memory markets = IonicComptroller(pools[i].comptroller).getAllMarkets();
59+
for (uint256 j = 0; j < markets.length; j++) {
60+
bool isPaused = IonicComptroller(pools[i].comptroller).borrowGuardianPaused(address(markets[j]));
61+
assertEq(isPaused, false);
62+
isPaused = IonicComptroller(pools[i].comptroller).mintGuardianPaused(address(markets[j]));
63+
assertEq(isPaused, false);
64+
}
65+
}
66+
}
67+
}

0 commit comments

Comments
 (0)