@@ -34,8 +34,12 @@ contract RescuerTest is Test {
34
34
scribe = new ScribeOptimistic (address (this ), bytes32 ("TEST/TEST " ));
35
35
IScribeOptimistic (scribe).setMaxChallengeReward (type (uint ).max);
36
36
rescuer = new Rescuer (address (this ));
37
+ // Auth the recover contract on scribe
38
+ IAuth (address (scribe)).rely (address (rescuer));
37
39
}
38
40
41
+ // -- Test: Suck --
42
+
39
43
function testFuzz_suck (uint privKey ) public {
40
44
privKey = _bound (privKey, 1 , LibSecp256k1.Q () - 1 );
41
45
// Auth the recover contract on scribe
@@ -65,12 +69,13 @@ contract RescuerTest is Test {
65
69
emit Withdrawed (address (this ), recipient, withdraw_amount);
66
70
rescuer.withdraw (payable (recipient), withdraw_amount);
67
71
assertEq (recipient.balance, withdraw_amount);
72
+ assertEq (recipient.balance, 1 ether);
68
73
}
69
74
70
75
function testFuzz_suckMultiple (uint privKey ) public {
71
76
privKey = _bound (privKey, 1 , LibSecp256k1.Q () - 1 );
72
77
address [] memory scribes = new address [](10 );
73
- for (uint i = 0 ; i < 10 ; i++ ) {
78
+ for (uint i; i < scribes.len ; i++ ) {
74
79
scribes[i] = address (new ScribeOptimistic (address (this ), bytes32 ("TEST/TEST " )));
75
80
IScribeOptimistic (scribes[i]).setMaxChallengeReward (type (uint ).max);
76
81
// Auth the recover contract on scribe
@@ -87,21 +92,24 @@ contract RescuerTest is Test {
87
92
uint32 pokeDataAge = uint32 (block .timestamp );
88
93
IScribe.ECDSAData memory opPokeSig = _construct_opPokeSignature (feed, pokeDataAge);
89
94
// Rescue ETH via rescuer contract.
90
- for (uint i = 0 ; i < 10 ; i++ ) {
95
+ for (uint i; i < scribes.len ; i++ ) {
91
96
vm.expectEmit ();
92
97
emit Recovered (address (this ), address (scribes[i]), 1 ether);
93
98
}
94
99
rescuer.suck (
95
100
scribes, feed.pubKey, registrationSig, pokeDataAge, opPokeSig
96
101
);
97
102
// Withdraw the eth
98
- uint current_balance = address (this ).balance;
99
- uint withdraw_amount = address (rescuer).balance;
100
103
address recipient = address (0x1234567890123456789012345678901234567890 );
101
- vm.expectEmit ();
102
- emit Withdrawed (address (this ), recipient, withdraw_amount);
103
- rescuer.withdraw (payable (recipient), withdraw_amount);
104
- assertEq (recipient.balance, withdraw_amount);
104
+ for (uint i; i < scribes.len; i++ ){
105
+ uint current_balance = address (this ).balance;
106
+ uint withdraw_amount = address (rescuer).balance;
107
+ vm.expectEmit ();
108
+ emit Withdrawed (address (this ), recipient, withdraw_amount);
109
+ rescuer.withdraw (payable (recipient), withdraw_amount);
110
+ assertEq (recipient.balance, withdraw_amount);
111
+ }
112
+ assertEq (recipient.balance, scribes.len * (1 ether));
105
113
106
114
}
107
115
@@ -174,6 +182,7 @@ contract RescuerTest is Test {
174
182
);
175
183
}
176
184
185
+ // -- Test: Withdraw --
177
186
178
187
function testFuzz_withdraw (uint amount ) public {
179
188
amount = _bound (amount, 0 , 1000 ether);
@@ -188,7 +197,7 @@ contract RescuerTest is Test {
188
197
assertEq (withdraw_amount, amount);
189
198
}
190
199
191
- // ---------- Auth tests -------- --
200
+ // -- Test: Auth --
192
201
193
202
function test_suck_isAuthed () public {
194
203
// Deauth this on the rescuer contract
@@ -225,6 +234,7 @@ contract RescuerTest is Test {
225
234
rescuer.withdraw (payable (recipient), 0 );
226
235
}
227
236
237
+ // -- Helpers --
228
238
229
239
function _construct_opPokeSignature (LibFeed.Feed memory feed , uint32 pokeDataAge ) private returns (IScribe.ECDSAData memory ) {
230
240
IScribe.PokeData memory pokeData = IScribe.PokeData (0 , pokeDataAge);
0 commit comments