@@ -153,6 +153,73 @@ contract KlerosCore_ExecutionTest is KlerosCore_TestBase {
153153 assertEq (pinakion.balanceOf (staker2), 999999999999980000 , "Wrong token balance of staker2 " );
154154 }
155155
156+ function test_execute_multipleWinners () public {
157+ uint256 disputeID = 0 ;
158+ uint256 numberOfOptions = 5 ; // 5 choices, 2 will be winners, the rest - losers
159+
160+ arbitrable.changeNumberOfRulingOptions (numberOfOptions);
161+
162+ vm.prank (staker1);
163+ core.setStake (GENERAL_COURT, 10000 );
164+ vm.prank (disputer);
165+ arbitrable.createDispute {value: feeForJuror * 5 }("Action " ); // 5 jurors, with future votes distribution 2-2-1-0-0
166+ vm.warp (block .timestamp + minStakingTime);
167+ sortitionModule.passPhase (); // Generating
168+ vm.warp (block .timestamp + rngLookahead);
169+ sortitionModule.passPhase (); // Drawing phase
170+
171+ core.draw (disputeID, 5 );
172+
173+ vm.warp (block .timestamp + timesPerPeriod[0 ]);
174+ core.passPeriod (disputeID); // Vote
175+
176+ uint256 [] memory voteIDs = new uint256 [](2 );
177+ voteIDs[0 ] = 0 ;
178+ voteIDs[1 ] = 1 ;
179+ vm.prank (staker1);
180+ disputeKit.castVote (disputeID, voteIDs, 1 , 0 , "XYZ " ); // Cast first 2 votes for 1st choice
181+
182+ voteIDs = new uint256 [](2 );
183+ voteIDs[0 ] = 2 ;
184+ voteIDs[1 ] = 3 ;
185+ vm.prank (staker1);
186+ disputeKit.castVote (disputeID, voteIDs, 2 , 0 , "XYZ " ); // Cast next 2 votes for 2nd choice
187+
188+ voteIDs = new uint256 [](1 );
189+ voteIDs[0 ] = 4 ;
190+ vm.prank (staker1);
191+ disputeKit.castVote (disputeID, voteIDs, 3 , 0 , "XYZ " ); // Cast the last vote for 3rd choice.
192+ core.passPeriod (disputeID); // Appeal
193+
194+ vm.warp (block .timestamp + timesPerPeriod[3 ]);
195+ core.passPeriod (disputeID); // Execution
196+
197+ assertEq (disputeKit.getCoherentCount (disputeID, 0 ), 4 , "Wrong coherent count " ); // Votes casted for first 2 choices are coherent
198+
199+ uint256 pnkCoherence;
200+ uint256 feeCoherence;
201+ // dispute, round, voteID, feeForJuror (not used in classic DK), pnkPerJuror (not used in classic DK)
202+ (pnkCoherence, feeCoherence) = disputeKit.getDegreeOfCoherenceReward (disputeID, 0 , 0 , 0 , 0 );
203+ assertEq (pnkCoherence, 10000 , "Wrong reward pnk coherence 0 vote ID " );
204+ assertEq (feeCoherence, 10000 , "Wrong reward fee coherence 0 vote ID " );
205+
206+ (pnkCoherence, feeCoherence) = disputeKit.getDegreeOfCoherenceReward (disputeID, 0 , 1 , 0 , 0 );
207+ assertEq (pnkCoherence, 10000 , "Wrong reward pnk coherence 1 vote ID " );
208+ assertEq (feeCoherence, 10000 , "Wrong reward fee coherence 1 vote ID " );
209+
210+ (pnkCoherence, feeCoherence) = disputeKit.getDegreeOfCoherenceReward (disputeID, 0 , 2 , 0 , 0 );
211+ assertEq (pnkCoherence, 10000 , "Wrong reward pnk coherence 2 vote ID " );
212+ assertEq (feeCoherence, 10000 , "Wrong reward fee coherence 2 vote ID " );
213+
214+ (pnkCoherence, feeCoherence) = disputeKit.getDegreeOfCoherenceReward (disputeID, 0 , 3 , 0 , 0 );
215+ assertEq (pnkCoherence, 10000 , "Wrong reward pnk coherence 3 vote ID " );
216+ assertEq (feeCoherence, 10000 , "Wrong reward fee coherence 3 vote ID " );
217+
218+ (pnkCoherence, feeCoherence) = disputeKit.getDegreeOfCoherenceReward (disputeID, 0 , 4 , 0 , 0 );
219+ assertEq (pnkCoherence, 0 , "Wrong reward pnk coherence 4 vote ID " );
220+ assertEq (feeCoherence, 0 , "Wrong reward fee coherence 4 vote ID " );
221+ }
222+
156223 function test_execute_maxStakeCheck () public {
157224 uint256 disputeID = 0 ;
158225
0 commit comments