@@ -17,16 +17,13 @@ contract SuccinctVAppRewardsTest is SuccinctVAppTest {
1717 bytes32 [] public rewardLeaves;
1818 bytes32 public rewardsMerkleRoot;
1919 Merkle public merkle;
20-
20+
2121 // Prover for testing prover rewards.
2222 address public testProver;
2323
2424 // Storage slot for rewardsRoot in SuccinctVApp (slot 11 based on contract layout).
2525 uint256 constant REWARDS_ROOT_SLOT = 11 ;
2626
27- // Events.
28- event RewardClaimed (uint256 indexed index , address indexed account , uint256 amount );
29-
3027 function setUp () public override {
3128 super .setUp ();
3229
@@ -42,7 +39,7 @@ contract SuccinctVAppRewardsTest is SuccinctVAppTest {
4239 makeAddr ("REWARD_4 " ),
4340 testProver // Include the prover in rewards
4441 ];
45- rewardAmounts = [1 ether, 2 ether, 3 ether, 4 ether, 5 ether ];
42+ rewardAmounts = [1e18 , 2e18 , 3e18 , 4e18 , 5e18 ];
4643
4744 // Build the merkle tree.
4845 for (uint256 i = 0 ; i < rewardAccounts.length ; i++ ) {
@@ -52,15 +49,16 @@ contract SuccinctVAppRewardsTest is SuccinctVAppTest {
5249 rewardsMerkleRoot = merkle.getRoot (rewardLeaves);
5350
5451 // Fund the VApp with $PROVE for rewards.
55- MockERC20 (PROVE).mint (VAPP, 100 ether );
52+ MockERC20 (PROVE).mint (VAPP, 100e18 );
5653 }
5754
5855 function _setRewardsRoot (bytes32 _root ) internal {
5956 // Use vm.store to directly set the rewardsRoot in storage.
6057 vm.store (VAPP, bytes32 (REWARDS_ROOT_SLOT), _root);
6158 }
6259
63- function test_RewardsInitialState () public view {
60+ // Initial state should have no root and all indexes should be unclaimed.
61+ function test_Rewards_WhenInitialState () public view {
6462 // Rewards root should be empty initially.
6563 assertEq (SuccinctVApp (VAPP).rewardsRoot (), bytes32 (0 ));
6664
@@ -70,7 +68,8 @@ contract SuccinctVAppRewardsTest is SuccinctVAppTest {
7068 }
7169 }
7270
73- function test_RewardClaim_WithValidProof () public {
71+ // A valid proof should be able to claim a reward.
72+ function test_RewardClaim_WhenValid () public {
7473 // Set the rewards root.
7574 _setRewardsRoot (rewardsMerkleRoot);
7675
@@ -95,7 +94,7 @@ contract SuccinctVAppRewardsTest is SuccinctVAppTest {
9594
9695 // Claim.
9796 vm.expectEmit (true , true , true , true , VAPP);
98- emit RewardClaimed (i, claimer, amount);
97+ emit ISuccinctVApp. RewardClaimed (i, claimer, amount);
9998 SuccinctVApp (VAPP).rewardClaim (i, claimer, amount, proof);
10099
101100 // Check post-claim state.
@@ -113,7 +112,8 @@ contract SuccinctVAppRewardsTest is SuccinctVAppTest {
113112 }
114113 }
115114
116- function test_RevertRewardClaim_AlreadyClaimed () public {
115+ // Not allowed to re-claim a reward.
116+ function test_RevertRewardClaim_WhenAlreadyClaimed () public {
117117 // Set the rewards root.
118118 _setRewardsRoot (rewardsMerkleRoot);
119119
@@ -131,7 +131,8 @@ contract SuccinctVAppRewardsTest is SuccinctVAppTest {
131131 }
132132 }
133133
134- function test_RevertRewardClaim_InvalidProof () public {
134+ // Not allowed to claim with an invalid proof.
135+ function test_RevertRewardClaim_WhenInvalidProof () public {
135136 // Set the rewards root.
136137 _setRewardsRoot (rewardsMerkleRoot);
137138
@@ -147,6 +148,7 @@ contract SuccinctVAppRewardsTest is SuccinctVAppTest {
147148 SuccinctVApp (VAPP).rewardClaim (index, claimer, amount, invalidProof);
148149 }
149150
151+ // Not allowed to claim when paused.
150152 function test_RevertRewardClaim_WhenPaused () public {
151153 // Pause the contract.
152154 vm.prank (OWNER);
@@ -163,6 +165,7 @@ contract SuccinctVAppRewardsTest is SuccinctVAppTest {
163165 SuccinctVApp (VAPP).rewardClaim (index, claimer, amount, proof);
164166 }
165167
168+ // isClaimed should correctly track claimed rewards.
166169 function test_IsClaimed_BitMapLogic () public {
167170 // Set the rewards root.
168171 _setRewardsRoot (rewardsMerkleRoot);
@@ -178,36 +181,10 @@ contract SuccinctVAppRewardsTest is SuccinctVAppTest {
178181 SuccinctVApp (VAPP).rewardClaim (0 , rewardAccounts[0 ], rewardAmounts[0 ], proof);
179182 assertEq (SuccinctVApp (VAPP).isClaimed (0 ), true );
180183 assertEq (SuccinctVApp (VAPP).isClaimed (1 ), false );
181-
182- // Test boundary cases for bitmap.
183- // These would need proper merkle tree setup to actually claim at boundary indexes,
184- // but the bitmap logic is tested above by checking various indexes.
185- }
186-
187- function test_RewardClaim_TransfersPROVE () public {
188- // Set the rewards root.
189- _setRewardsRoot (rewardsMerkleRoot);
190-
191- // Test regular account (not a prover).
192- uint256 regularAccountIndex = 0 ;
193- address regularAccount = rewardAccounts[regularAccountIndex];
194- uint256 amount = rewardAmounts[regularAccountIndex];
195-
196- // Check initial balances.
197- uint256 initialVAppBalance = MockERC20 (PROVE).balanceOf (VAPP);
198- uint256 initialClaimerBalance = MockERC20 (PROVE).balanceOf (regularAccount);
199- assertEq (initialClaimerBalance, 0 );
200-
201- // Claim reward.
202- bytes32 [] memory proof = merkle.getProof (rewardLeaves, regularAccountIndex);
203- SuccinctVApp (VAPP).rewardClaim (regularAccountIndex, regularAccount, amount, proof);
204-
205- // Verify transfer occurred.
206- assertEq (MockERC20 (PROVE).balanceOf (regularAccount), amount);
207- assertEq (MockERC20 (PROVE).balanceOf (VAPP), initialVAppBalance - amount);
208184 }
209185
210- function test_RewardClaim_DifferentCaller () public {
186+ // Anyone is allowed to claim a reward for an account as long it's valid.
187+ function test_RewardClaim_WhenDifferentCaller () public {
211188 // Set the rewards root.
212189 _setRewardsRoot (rewardsMerkleRoot);
213190
@@ -224,7 +201,8 @@ contract SuccinctVAppRewardsTest is SuccinctVAppTest {
224201 assertEq (MockERC20 (PROVE).balanceOf (randomCaller), 0 );
225202 }
226203
227- function test_RevertRewardClaim_WrongAmount () public {
204+ // Not allowed to claim with a wrong amount.
205+ function test_RevertRewardClaim_WhenWrongAmount () public {
228206 // Set the rewards root.
229207 _setRewardsRoot (rewardsMerkleRoot);
230208
@@ -236,7 +214,8 @@ contract SuccinctVAppRewardsTest is SuccinctVAppTest {
236214 SuccinctVApp (VAPP).rewardClaim (0 , rewardAccounts[0 ], wrongAmount, proof);
237215 }
238216
239- function test_RevertRewardClaim_WrongAccount () public {
217+ // Not allowed to claim with a wrong account.
218+ function test_RevertRewardClaim_WhenWrongAccount () public {
240219 // Set the rewards root.
241220 _setRewardsRoot (rewardsMerkleRoot);
242221
@@ -248,7 +227,8 @@ contract SuccinctVAppRewardsTest is SuccinctVAppTest {
248227 SuccinctVApp (VAPP).rewardClaim (0 , wrongAccount, rewardAmounts[0 ], proof);
249228 }
250229
251- function test_RevertRewardClaim_EmptyProof () public {
230+ // Not allowed to claim with an empty proof.
231+ function test_RevertRewardClaim_WhenEmptyProof () public {
252232 // Set the rewards root.
253233 _setRewardsRoot (rewardsMerkleRoot);
254234
@@ -259,7 +239,8 @@ contract SuccinctVAppRewardsTest is SuccinctVAppTest {
259239 SuccinctVApp (VAPP).rewardClaim (0 , rewardAccounts[0 ], rewardAmounts[0 ], emptyProof);
260240 }
261241
262- function test_PartialRewardClaims () public {
242+ // It's valid if only a subset of accounts claim within an epoch.
243+ function test_RewardClaim_WhenPartial () public {
263244 // Set the rewards root.
264245 _setRewardsRoot (rewardsMerkleRoot);
265246
@@ -283,15 +264,17 @@ contract SuccinctVAppRewardsTest is SuccinctVAppTest {
283264 assertEq (MockERC20 (PROVE).balanceOf (VAPP), expectedRemainingBalance);
284265 }
285266
286- function test_RewardClaim_ToProverVault () public {
267+ // Rewards should be transferred to the prover vault correctly: PROVE is sent to iPROVE,
268+ // and the iPROVE is sent to the prover.
269+ function test_RewardClaim_WhenToProverVault () public {
287270 // Set the rewards root.
288271 _setRewardsRoot (rewardsMerkleRoot);
289272
290273 // Get the prover index (last one in our array).
291274 uint256 proverIndex = rewardAccounts.length - 1 ;
292275 address proverVault = rewardAccounts[proverIndex];
293276 uint256 amount = rewardAmounts[proverIndex];
294-
277+
295278 // Verify it's recognized as a prover.
296279 assertEq (proverVault, testProver);
297280
@@ -305,7 +288,7 @@ contract SuccinctVAppRewardsTest is SuccinctVAppTest {
305288 // Claim reward for prover.
306289 bytes32 [] memory proof = merkle.getProof (rewardLeaves, proverIndex);
307290 vm.expectEmit (true , true , true , true , VAPP);
308- emit RewardClaimed (proverIndex, proverVault, amount);
291+ emit ISuccinctVApp. RewardClaimed (proverIndex, proverVault, amount);
309292 SuccinctVApp (VAPP).rewardClaim (proverIndex, proverVault, amount, proof);
310293
311294 // Verify the prover received iPROVE instead of PROVE.
@@ -315,23 +298,26 @@ contract SuccinctVAppRewardsTest is SuccinctVAppTest {
315298 assertEq (SuccinctVApp (VAPP).isClaimed (proverIndex), true );
316299 }
317300
318- function test_RewardClaim_MixedAccountTypes () public {
301+ // Rewards should be transferred to mixed prover vaults and EOAs correctly.
302+ function test_RewardClaim_WhenMixedAccountTypes () public {
319303 // Set the rewards root.
320304 _setRewardsRoot (rewardsMerkleRoot);
321305
322306 // Claim for regular account (index 0).
323307 bytes32 [] memory proof0 = merkle.getProof (rewardLeaves, 0 );
324308 SuccinctVApp (VAPP).rewardClaim (0 , rewardAccounts[0 ], rewardAmounts[0 ], proof0);
325-
309+
326310 // Verify regular account received PROVE.
327311 assertEq (MockERC20 (PROVE).balanceOf (rewardAccounts[0 ]), rewardAmounts[0 ]);
328312 assertEq (MockERC20 (I_PROVE).balanceOf (rewardAccounts[0 ]), 0 );
329313
330314 // Claim for prover (last index).
331315 uint256 proverIndex = rewardAccounts.length - 1 ;
332316 bytes32 [] memory proofProver = merkle.getProof (rewardLeaves, proverIndex);
333- SuccinctVApp (VAPP).rewardClaim (proverIndex, testProver, rewardAmounts[proverIndex], proofProver);
334-
317+ SuccinctVApp (VAPP).rewardClaim (
318+ proverIndex, testProver, rewardAmounts[proverIndex], proofProver
319+ );
320+
335321 // Verify prover received iPROVE.
336322 assertEq (MockERC20 (PROVE).balanceOf (testProver), 0 );
337323 assertEq (MockERC20 (I_PROVE).balanceOf (testProver), rewardAmounts[proverIndex]);
0 commit comments