@@ -58,13 +58,19 @@ contract FailSafeTests is TestBase {
58
58
}
59
59
}
60
60
61
- function test_FailSafe_pauseAll_RevertsForNonOwner () external {
62
- hoax (makeAddr ("nonOwner " ));
63
- vm.expectRevert ("Ownable: caller is not the owner " );
61
+ // FailSafe#pauseAll
62
+
63
+ function test_FailSafe_pauseAll_RevertsForNonGuardian () external {
64
+ hoax (makeAddr ("nonGuardian " ));
65
+ vm.expectRevert (FailSafe.NotGuardian.selector );
64
66
failsafe.pauseAll ();
65
67
}
66
68
67
69
function test_FailSafe_pauseAll_Success () external {
70
+ address newGuardian = makeAddr ("newGuardian " );
71
+ failsafe.setIsGuardian (newGuardian, true );
72
+ startHoax (newGuardian);
73
+
68
74
failsafe.pauseAll ();
69
75
70
76
// check if all operations are paused
@@ -93,4 +99,59 @@ contract FailSafeTests is TestBase {
93
99
assertTrue (nftxRouter.isPaused (NFTX_ROUTER_LOCK_ID_SELLNFTS));
94
100
assertTrue (nftxRouter.isPaused (NFTX_ROUTER_LOCK_ID_BUYNFTS));
95
101
}
102
+
103
+ // FailSafe#setContracts
104
+
105
+ function test_FailSafe_setContracts_RevertsForNonOwner () external {
106
+ hoax (makeAddr ("nonOwner " ));
107
+ vm.expectRevert (OWNABLE_NOT_OWNER_ERROR);
108
+ failsafe.setContracts (new FailSafe.Contract [](0 ));
109
+ }
110
+
111
+ function test_FailSafe_setContracts_Success () external {
112
+ FailSafe.Contract[] memory contracts = new FailSafe.Contract [](5 );
113
+ contracts[0 ] = FailSafe.Contract ({
114
+ addr: address (inventoryStaking),
115
+ lastLockId: 4
116
+ });
117
+ contracts[1 ] = FailSafe.Contract ({
118
+ addr: address (vaultFactory),
119
+ lastLockId: 0
120
+ });
121
+ contracts[2 ] = FailSafe.Contract ({
122
+ addr: address (feeDistributor),
123
+ lastLockId: 1
124
+ });
125
+ contracts[3 ] = FailSafe.Contract ({
126
+ addr: address (nftxRouter),
127
+ lastLockId: 4
128
+ });
129
+ contracts[4 ] = FailSafe.Contract ({
130
+ addr: makeAddr ("newContract " ),
131
+ lastLockId: 5
132
+ });
133
+
134
+ failsafe.setContracts (contracts);
135
+
136
+ // check if the contracts are set
137
+ for (uint256 i; i < contracts.length ; i++ ) {
138
+ (address addr , uint256 lastLockId ) = failsafe.contracts (i);
139
+ assertEq (addr, contracts[i].addr);
140
+ assertEq (lastLockId, contracts[i].lastLockId);
141
+ }
142
+ }
143
+
144
+ // FailSafe#setIsGuardian
145
+ function test_FailSafe_setIsGuardian_RevertsForNonOwner () external {
146
+ hoax (makeAddr ("nonOwner " ));
147
+ vm.expectRevert (OWNABLE_NOT_OWNER_ERROR);
148
+ failsafe.setIsGuardian (makeAddr ("addr " ), true );
149
+ }
150
+
151
+ function test_FailSafe_setIsGuardian_Success () external {
152
+ address newGuardian = makeAddr ("newGuardian " );
153
+ failsafe.setIsGuardian (newGuardian, true );
154
+
155
+ assertTrue (failsafe.isGuardian (newGuardian));
156
+ }
96
157
}
0 commit comments