Skip to content

Commit 536e61c

Browse files
jaybuidlunknownunknown1
authored andcommitted
test: withdrawFeesAndRewards() coverage for complex DK jump sequence
1 parent 00be694 commit 536e61c

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

contracts/test/foundry/KlerosCore_Appeals.t.sol

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,48 @@ contract KlerosCore_AppealsTest is KlerosCore_TestBase {
748748

749749
vm.prank(staker1);
750750
disputeKit3.castVote(disputeID, voteIDs, 2, 0, "XYZ");
751+
752+
vm.warp(block.timestamp + timesPerPeriod[2]);
753+
core.passPeriod(disputeID); // Appeal
754+
755+
vm.warp(block.timestamp + timesPerPeriod[3]);
756+
core.passPeriod(disputeID); // Execution
757+
758+
core.executeRuling(disputeID); // winning choice is 2
759+
760+
// Appeal Rewards for Round 1 //
761+
disputeKit3.withdrawFeesAndRewards(disputeID, payable(crowdfunder1), 0, 1); // wrong side, no reward
762+
vm.expectEmit();
763+
emit DisputeKitClassicBase.Withdrawal(disputeID, 0, 2, payable(crowdfunder2), 0.84 ether);
764+
disputeKit3.withdrawFeesAndRewards(disputeID, payable(crowdfunder2), 0, 2); // REWARDS
765+
disputeKit2.withdrawFeesAndRewards(disputeID, payable(crowdfunder1), 0, 1); // wrong DK, no reward
766+
disputeKit2.withdrawFeesAndRewards(disputeID, payable(crowdfunder2), 0, 2); // wrong DK, no reward
767+
vm.expectRevert(DisputeKitClassicBase.NotActiveForCoreDisputeID.selector);
768+
disputeKit.withdrawFeesAndRewards(disputeID, payable(crowdfunder1), 0, 1); // wrong DK, no reward
769+
vm.expectRevert(DisputeKitClassicBase.NotActiveForCoreDisputeID.selector);
770+
disputeKit.withdrawFeesAndRewards(disputeID, payable(crowdfunder2), 0, 2); // wrong DK, no reward
771+
772+
// Appeal Rewards for Round 2 //
773+
disputeKit3.withdrawFeesAndRewards(disputeID, payable(crowdfunder1), 1, 1); // wrong DK, no reward
774+
disputeKit3.withdrawFeesAndRewards(disputeID, payable(crowdfunder2), 1, 2); // wrong DK, no reward
775+
disputeKit2.withdrawFeesAndRewards(disputeID, payable(crowdfunder1), 1, 1); // wrong side, no reward
776+
vm.expectEmit();
777+
emit DisputeKitClassicBase.Withdrawal(disputeID, 1, 2, payable(crowdfunder2), 1.8 ether);
778+
disputeKit2.withdrawFeesAndRewards(disputeID, payable(crowdfunder2), 1, 2); // REWARDS
779+
vm.expectRevert(DisputeKitClassicBase.NotActiveForCoreDisputeID.selector);
780+
disputeKit.withdrawFeesAndRewards(disputeID, payable(crowdfunder1), 1, 1); // wrong DK, no reward
781+
vm.expectRevert(DisputeKitClassicBase.NotActiveForCoreDisputeID.selector);
782+
disputeKit.withdrawFeesAndRewards(disputeID, payable(crowdfunder2), 1, 2); // wrong DK, no reward
783+
784+
// Appeal Rewards for Round 3 //
785+
disputeKit3.withdrawFeesAndRewards(disputeID, payable(crowdfunder1), 2, 1); // no appeal, no reward
786+
disputeKit3.withdrawFeesAndRewards(disputeID, payable(crowdfunder2), 2, 2); // no appeal, no reward
787+
disputeKit2.withdrawFeesAndRewards(disputeID, payable(crowdfunder1), 2, 1); // no appeal, no reward
788+
disputeKit2.withdrawFeesAndRewards(disputeID, payable(crowdfunder2), 2, 2); // no appeal, no reward
789+
vm.expectRevert(DisputeKitClassicBase.NotActiveForCoreDisputeID.selector);
790+
disputeKit.withdrawFeesAndRewards(disputeID, payable(crowdfunder1), 2, 1); // wrong DK, no reward
791+
vm.expectRevert(DisputeKitClassicBase.NotActiveForCoreDisputeID.selector);
792+
disputeKit.withdrawFeesAndRewards(disputeID, payable(crowdfunder2), 2, 2); // wrong DK, no reward
751793
}
752794

753795
function test_appeal_quickPassPeriod() public {

0 commit comments

Comments
 (0)