Skip to content

Commit 6d76559

Browse files
committed
test: extra comments
1 parent ad1ff0d commit 6d76559

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

contracts/test/foundry/KlerosCore_Appeals.t.sol

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import "../../src/libraries/Constants.sol";
1111
/// @title KlerosCore_AppealsTest
1212
/// @dev Tests for KlerosCore appeal system, funding, and court/DK jumping
1313
contract KlerosCore_AppealsTest is KlerosCore_TestBase {
14+
/// @dev Test funding appeal for only one side without completing the appeal.
15+
/// Verifies appeal period calculation, funding mechanics (partial and full), overpayment reimbursement,
16+
/// and error conditions (cannot appeal before appeal period, insufficient fees, only DK can call appeal).
1417
function test_appeal_fundOneSide() public {
1518
uint256 disputeID = 0;
1619
vm.deal(address(disputeKit), 1 ether);
@@ -103,6 +106,9 @@ contract KlerosCore_AppealsTest is KlerosCore_TestBase {
103106
disputeKit.fundAppeal(disputeID, 1);
104107
}
105108

109+
/// @dev Test appeal period timing constraints for losing vs winning sides.
110+
/// Verifies losers can only fund appeals in the first half of the appeal period,
111+
/// while winners can fund anytime until the end of the period.
106112
function test_appeal_timeoutCheck() public {
107113
uint256 disputeID = 0;
108114

@@ -147,6 +153,9 @@ contract KlerosCore_AppealsTest is KlerosCore_TestBase {
147153
disputeKit.fundAppeal{value: 0.1 ether}(disputeID, 2);
148154
}
149155

156+
/// @dev Test complete appeal funding without court or dispute kit jumping.
157+
/// Verifies that when both sides fully fund an appeal, a new round is created in the same court
158+
/// with increased juror count (nbVotes * 2 + 1), and the dispute period transitions to evidence.
150159
function test_appeal_fullFundingNoJump() public {
151160
uint256 disputeID = 0;
152161

@@ -209,9 +218,10 @@ contract KlerosCore_AppealsTest is KlerosCore_TestBase {
209218
core.passPeriod(disputeID);
210219
}
211220

221+
/// @dev Test simultaneous court jump and dispute kit jump to DISPUTE_KIT_CLASSIC.
222+
/// Setup: Dispute starts in Court2 with DK2, where DK2._jumpDisputeKitID == DISPUTE_KIT_CLASSIC.
223+
/// Verifies dispute jumps from Court2→GENERAL_COURT and DK2→DISPUTE_KIT_CLASSIC on appeal.
212224
function test_appeal_fullFundingCourtJumpAndDKJumpToClassic() public {
213-
// Setup: dk2 supported by court2 with dk2._jumpDisputeKitID == DISPUTE_KIT_CLASSIC
214-
// Ensure that court2 jumps to GENERAL_COURT and dk2 jumps to DISPUTE_KIT_CLASSIC
215225
uint256 disputeID = 0;
216226
DisputeKitClassic dkLogic = new DisputeKitClassic();
217227
// Create a new DK and court to check the jump
@@ -343,11 +353,10 @@ contract KlerosCore_AppealsTest is KlerosCore_TestBase {
343353
assertEq(account, staker1, "Wrong drawn account in the classic DK");
344354
}
345355

356+
/// @dev Test court jump and dispute kit jump to a non-classic dispute kit.
357+
/// Setup: DK2 supported by GENERAL_COURT, DK3 supported by Court2, with DK3.jumpDisputeKitIDOnCourtJump == DK2.
358+
/// Verifies dispute jumps from Court2→GENERAL_COURT and DK3→DK2 using jumpDisputeKitIDOnCourtJump setting.
346359
function test_appeal_fullFundingCourtJumpAndDKJumpToNonClassic() public {
347-
// Setup:
348-
// dk2 supported by GENERAL_COURT, which is a non-DISPUTE_KIT_CLASSIC
349-
// dk3 supported by court2, with dk3.nextRoundSettings[court2].jumpDisputeKitIDIncompatibilityFallback == dk2
350-
// Ensure that court2 jumps to GENERAL_COURT and dk3 jumps to dk2
351360
uint256 disputeID = 0;
352361
uint96 newCourtID = 2;
353362
uint256 dkID2 = 2;
@@ -493,9 +502,11 @@ contract KlerosCore_AppealsTest is KlerosCore_TestBase {
493502
assertEq(account, staker1, "Wrong drawn account in the classic DK");
494503
}
495504

505+
/// @dev Test dispute jumping between the same dispute kits multiple times across different rounds.
506+
/// Setup: Court hierarchy GENERAL_COURT→Court2→Court3. DK2 supported by Court2, DK3 supported by Court3.
507+
/// Verifies correct behavior when dispute oscillates: Court3/DK3 → Court2/DK2 → GENERAL_COURT/DK3,
508+
/// including local dispute ID tracking and round state management across multiple DK switches.
496509
function test_appeal_recurringDK() public {
497-
// Test the behaviour when dispute jumps from DK3 to DK2 and then back to DK3 again.
498-
499510
// Setup: create 2 more courts to facilitate appeal jump. Create 2 more DK.
500511
// Set General Court as parent to court2, and court2 as parent to court3. dk2 as jump DK for dk3, and dk3 as jump DK for dk2.
501512
// Ensure DK2 is supported by Court2 and DK3 is supported by court3.
@@ -829,6 +840,9 @@ contract KlerosCore_AppealsTest is KlerosCore_TestBase {
829840
disputeKit.withdrawFeesAndRewards(disputeID, payable(crowdfunder2), 2); // wrong DK, no reward
830841
}
831842

843+
/// @dev Test early termination of appeal period when no appeal is funded.
844+
/// Verifies that the appeal period can be passed before timeout expires when waiting halfway
845+
/// through the period with no appeal funded, allowing quick transition to execution.
832846
function test_appeal_quickPassPeriod() public {
833847
uint256 disputeID = 0;
834848

@@ -863,6 +877,9 @@ contract KlerosCore_AppealsTest is KlerosCore_TestBase {
863877
core.passPeriod(disputeID);
864878
}
865879

880+
/// @dev Fuzz test for appeal funding with random ruling options and juror vote distributions.
881+
/// Tests appeal mechanics with varying number of ruling options and different vote choices,
882+
/// ensuring appeal funding works correctly regardless of the choice configuration.
866883
function testFuzz_appeal(uint256 numberOfOptions, uint256 choice1, uint256 choice2, uint256 choice3) public {
867884
uint256 disputeID = 0;
868885

@@ -928,6 +945,9 @@ contract KlerosCore_AppealsTest is KlerosCore_TestBase {
928945
assertEq((disputeKit.getFundedChoices(disputeID)).length, 0, "No funded choices in a fresh round");
929946
}
930947

948+
/// @dev Fuzz test for appeal funding with random msg.value amounts.
949+
/// Verifies overpayment is correctly reimbursed, partial funding is tracked, and the dispute kit
950+
/// never holds more than the required appeal amount regardless of how much is sent.
931951
function testFuzz_fundAppeal_msgValue(uint256 appealValue) public {
932952
uint256 disputeID = 0;
933953

0 commit comments

Comments
 (0)