Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,14 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi

drawnAddress = sortitionModule.draw(key, _coreDisputeID, _nonce);

if (_postDrawCheck(round, _coreDisputeID, drawnAddress)) {
round.votes.push(Vote({account: drawnAddress, commit: bytes32(0), choice: 0, voted: false}));
alreadyDrawn[localDisputeID][localRoundID][drawnAddress] = true;
} else {
drawnAddress = address(0);
if (drawnAddress != address(0)) {
// Sortition can return 0 address if no one has staked yet.
if (_postDrawCheck(round, _coreDisputeID, drawnAddress)) {
round.votes.push(Vote({account: drawnAddress, commit: bytes32(0), choice: 0, voted: false}));
alreadyDrawn[localDisputeID][localRoundID][drawnAddress] = true;
} else {
drawnAddress = address(0);
}
}
}

Expand Down
20 changes: 20 additions & 0 deletions contracts/test/foundry/KlerosCore.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,26 @@ contract KlerosCoreTest is Test {
}
}

function test_draw_noEmptyAddresses() public {
uint256 disputeID = 0;
uint256 roundID = 0;

vm.prank(disputer);
arbitrable.createDispute{value: feeForJuror * DEFAULT_NB_OF_JURORS}("Action");
vm.warp(block.timestamp + minStakingTime);
sortitionModule.passPhase(); // Generating
vm.roll(block.number + rngLookahead + 1);
sortitionModule.passPhase(); // Drawing phase

core.draw(disputeID, DEFAULT_NB_OF_JURORS); // No one is staked so check that the empty addresses are not drawn.

KlerosCoreBase.Round memory round = core.getRoundInfo(disputeID, roundID);
assertEq(round.drawIterations, 3, "Wrong drawIterations number");

(, , , , uint256 nbVoters, ) = disputeKit.getRoundInfo(disputeID, roundID, 0);
assertEq(nbVoters, 0, "nbVoters should be 0");
}

function test_draw_parentCourts() public {
uint96 newCourtID = 2;
uint256 disputeID = 0;
Expand Down
Loading