@@ -222,11 +222,6 @@ contract SparkRewardsClaimFailureTests is SparkRewardsClaimTestBase {
222222 rewards.setMerkleRoot (root);
223223 }
224224
225- function test_claim_accountNotMsgSender () public {
226- vm.expectRevert ("SparkRewards/invalid-account " );
227- rewards.claim (1 , makeAddr ("account " ), address (token1), 1 , root, new bytes32 [](0 ));
228- }
229-
230225 function test_claim_merkleRootNotExpected () public {
231226 vm.expectRevert ("SparkRewards/merkle-root-was-updated " );
232227 rewards.claim (1 , address (this ), address (token1), 1 , "root2 " , new bytes32 [](0 ));
@@ -247,7 +242,6 @@ contract SparkRewardsClaimFailureTests is SparkRewardsClaimTestBase {
247242
248243 leaf.epoch += 1 ;
249244
250- vm.prank (leaf.account);
251245 vm.expectRevert ("SparkRewards/invalid-proof " );
252246 rewards.claim (leaf.epoch, leaf.account, leaf.token, leaf.cumulativeAmount, root, leaf.proof);
253247 }
@@ -259,7 +253,6 @@ contract SparkRewardsClaimFailureTests is SparkRewardsClaimTestBase {
259253
260254 leaf.account = makeAddr ("fakeAccount " );
261255
262- vm.prank (leaf.account);
263256 vm.expectRevert ("SparkRewards/invalid-proof " );
264257 rewards.claim (leaf.epoch, leaf.account, leaf.token, leaf.cumulativeAmount, root, leaf.proof);
265258 }
@@ -271,7 +264,6 @@ contract SparkRewardsClaimFailureTests is SparkRewardsClaimTestBase {
271264
272265 leaf.token = makeAddr ("fakeToken " );
273266
274- vm.prank (leaf.account);
275267 vm.expectRevert ("SparkRewards/invalid-proof " );
276268 rewards.claim (leaf.epoch, leaf.account, leaf.token, leaf.cumulativeAmount, root, leaf.proof);
277269 }
@@ -283,7 +275,6 @@ contract SparkRewardsClaimFailureTests is SparkRewardsClaimTestBase {
283275
284276 leaf.cumulativeAmount += 1 ;
285277
286- vm.prank (leaf.account);
287278 vm.expectRevert ("SparkRewards/invalid-proof " );
288279 rewards.claim (leaf.epoch, leaf.account, leaf.token, leaf.cumulativeAmount, root, leaf.proof);
289280 }
@@ -293,10 +284,8 @@ contract SparkRewardsClaimFailureTests is SparkRewardsClaimTestBase {
293284
294285 Leaf memory leaf = parseLeaf (index, vm.readFile (filePath1));
295286
296- vm.prank (leaf.account);
297287 rewards.claim (leaf.epoch, leaf.account, leaf.token, leaf.cumulativeAmount, root, leaf.proof);
298288
299- vm.prank (leaf.account);
300289 vm.expectRevert ("SparkRewards/nothing-to-claim " );
301290 rewards.claim (leaf.epoch, leaf.account, leaf.token, leaf.cumulativeAmount, root, leaf.proof);
302291 }
@@ -354,7 +343,6 @@ contract RewardsClaimFileBasedTests is SparkRewardsClaimTestBase {
354343
355344 assertEq (rewards.cumulativeClaimed (leaf.account, leaf.token, leaf.epoch), 0 );
356345
357- vm.prank (leaf.account);
358346 uint256 claimedAmount = rewards.claim (
359347 leaf.epoch,
360348 leaf.account,
@@ -388,7 +376,39 @@ contract RewardsClaimFileBasedTests is SparkRewardsClaimTestBase {
388376
389377 assertEq (rewards.cumulativeClaimed (leaf.account, leaf.token, leaf.epoch), 0 );
390378
391- vm.prank (leaf.account);
379+ uint256 claimedAmount = rewards.claim (
380+ leaf.epoch,
381+ leaf.account,
382+ leaf.token,
383+ leaf.cumulativeAmount,
384+ root,
385+ leaf.proof
386+ );
387+
388+ assertEq (claimedAmount, leaf.cumulativeAmount);
389+
390+ assertEq (token.balanceOf (wallet), 1_000_000_000e18 - claimedAmount);
391+ assertEq (token.balanceOf (leaf.account), claimedAmount);
392+
393+ assertEq (rewards.cumulativeClaimed (leaf.account, leaf.token, leaf.epoch), claimedAmount);
394+ }
395+
396+ function testFuzz_claim_singleClaim_otherUser (uint256 index , address user ) public {
397+ vm.prank (merkleRootAdmin);
398+ rewards.setMerkleRoot (complexRoot1);
399+
400+ index = _bound (index, 0 , valuesLength);
401+
402+ ( bytes32 root , Leaf memory leaf ) = getClaimParams (index, filePath1);
403+
404+ IERC20 token = IERC20 (leaf.token);
405+
406+ assertEq (token.balanceOf (wallet), 1_000_000_000e18 );
407+ assertEq (token.balanceOf (leaf.account), 0 );
408+
409+ assertEq (rewards.cumulativeClaimed (leaf.account, leaf.token, leaf.epoch), 0 );
410+
411+ vm.prank (user);
392412 uint256 claimedAmount = rewards.claim (
393413 leaf.epoch,
394414 leaf.account,
@@ -438,7 +458,6 @@ contract RewardsClaimFileBasedTests is SparkRewardsClaimTestBase {
438458 uint256 userBalance = token.balanceOf (leaf.account);
439459 uint256 walletBalance = token.balanceOf (wallet);
440460
441- vm.prank (leaf.account);
442461 uint256 claimedAmount = rewards.claim (
443462 leaf.epoch,
444463 leaf.account,
@@ -497,7 +516,6 @@ contract RewardsClaimFileBasedTests is SparkRewardsClaimTestBase {
497516 uint256 userBalance = token.balanceOf (leaf.account);
498517 uint256 walletBalance = token.balanceOf (wallet);
499518
500- vm.prank (leaf.account);
501519 uint256 claimedAmount = rewards.claim (
502520 leaf.epoch,
503521 leaf.account,
@@ -524,7 +542,6 @@ contract RewardsClaimFileBasedTests is SparkRewardsClaimTestBase {
524542 // Step 2: Demonstrate claims can't happen until root is updated
525543
526544 Leaf memory failingLeaf = leaves2[0 ];
527- vm.prank (failingLeaf.account);
528545 vm.expectRevert ("SparkRewards/merkle-root-was-updated " );
529546 rewards.claim (
530547 failingLeaf.epoch,
@@ -551,7 +568,6 @@ contract RewardsClaimFileBasedTests is SparkRewardsClaimTestBase {
551568 uint256 walletBalance = token.balanceOf (wallet);
552569 uint256 cumulativeClaimed = rewards.cumulativeClaimed (leaf.account, leaf.token, leaf.epoch);
553570
554- vm.prank (leaf.account);
555571 uint256 claimedAmount = rewards.claim (
556572 leaf.epoch,
557573 leaf.account,
@@ -609,7 +625,6 @@ contract RewardsClaimFileBasedTests is SparkRewardsClaimTestBase {
609625 uint256 userBalance = token.balanceOf (leaf.account);
610626 uint256 walletBalance = token.balanceOf (wallet);
611627
612- vm.prank (leaf.account);
613628 uint256 claimedAmount = rewards.claim (
614629 leaf.epoch,
615630 leaf.account,
@@ -636,7 +651,6 @@ contract RewardsClaimFileBasedTests is SparkRewardsClaimTestBase {
636651 // Step 2: Demonstrate claims can't happen until root is updated
637652
638653 Leaf memory failingLeaf = leaves2[0 ];
639- vm.prank (failingLeaf.account);
640654 vm.expectRevert ("SparkRewards/merkle-root-was-updated " );
641655 rewards.claim (
642656 failingLeaf.epoch,
@@ -663,7 +677,6 @@ contract RewardsClaimFileBasedTests is SparkRewardsClaimTestBase {
663677 uint256 walletBalance = token.balanceOf (wallet);
664678 uint256 cumulativeClaimed = rewards.cumulativeClaimed (leaf.account, leaf.token, leaf.epoch);
665679
666- vm.prank (leaf.account);
667680 uint256 claimedAmount = rewards.claim (
668681 leaf.epoch,
669682 leaf.account,
@@ -723,7 +736,24 @@ contract SparkRewardsClaimHardcodedTests is SparkRewardsClaimTestBase {
723736
724737 assertEq (rewards.cumulativeClaimed (account, token, epoch), 0 );
725738
726- vm.prank (account);
739+ uint256 amount = rewards.claim (epoch, account, token, cumulativeAmount, root, proof);
740+
741+ assertEq (amount, 1000e18 );
742+
743+ assertEq (token1.balanceOf (wallet), 1_000_000_000e18 - 1000e18 );
744+ assertEq (token1.balanceOf (account), 1000e18 );
745+
746+
747+ assertEq (rewards.cumulativeClaimed (account, token, epoch), 1000e18 );
748+ }
749+
750+ function test_claim_otherUser (address user ) public {
751+ assertEq (token1.balanceOf (wallet), 1_000_000_000e18 );
752+ assertEq (token1.balanceOf (account), 0 );
753+
754+ assertEq (rewards.cumulativeClaimed (account, token, epoch), 0 );
755+
756+ vm.prank (user);
727757 uint256 amount = rewards.claim (epoch, account, token, cumulativeAmount, root, proof);
728758
729759 assertEq (amount, 1000e18 );
@@ -737,7 +767,6 @@ contract SparkRewardsClaimHardcodedTests is SparkRewardsClaimTestBase {
737767
738768 function test_claim_cumulativeClaiming () public {
739769 // Do first claim
740- vm.prank (account);
741770 uint256 amount = rewards.claim (epoch, account, token, cumulativeAmount, root, proof);
742771
743772 assertEq (amount, 1000e18 );
@@ -761,7 +790,6 @@ contract SparkRewardsClaimHardcodedTests is SparkRewardsClaimTestBase {
761790 vm.prank (merkleRootAdmin);
762791 rewards.setMerkleRoot (root);
763792
764- vm.prank (account);
765793 amount = rewards.claim (epoch, account, token, cumulativeAmount, root, proof);
766794
767795 assertEq (amount, 500e18 );
@@ -807,7 +835,6 @@ contract SparkRewardsClaimHardcodedTests is SparkRewardsClaimTestBase {
807835
808836 assertEq (rewards.cumulativeClaimed (account, token, epoch), 0 );
809837
810- vm.prank (account);
811838 uint256 amount = rewards.claim (epoch, account, token, cumulativeAmount, root, bigProof);
812839
813840 assertEq (amount, cumulativeAmount);
0 commit comments