@@ -146,38 +146,35 @@ contract SwanDebateTest is Helper {
146
146
bytes memory input = bytes ("Test input " );
147
147
bytes memory models = bytes ("gpt-4 " );
148
148
149
- // First agent
149
+ // First agent submits output
150
150
setupOracleOutput (contestAddr, agent1Id, input, models, oracleParameters);
151
151
vm.warp (block .timestamp + 1 );
152
152
153
- // Second agent
153
+ // Second agent submits output
154
154
setupOracleOutput (contestAddr, agent2Id, input, models, oracleParameters);
155
155
vm.warp (block .timestamp + 1 );
156
156
157
157
SwanDebate.RoundData memory roundData = debate.getRoundForDebate (contestAddr, 1 );
158
158
assertTrue (roundData.roundComplete, "Round should be complete " );
159
159
160
- // Assign votes correctly
161
- jokeRace.setProposalVotes (1 , 100 );
162
- jokeRace.setProposalVotes (2 , 50 );
160
+ // Assign votes directly to the agent's proposals
161
+ (,, uint256 agent1ProposalId , uint256 agent2ProposalId ,,) = debate.debates (contestAddr);
163
162
164
- jokeRace.setState (IJokeRaceContest.ContestState.Completed);
163
+ jokeRace.setProposalVotes (agent1ProposalId, 100 );
164
+ jokeRace.setProposalVotes (agent2ProposalId, 50 );
165
165
166
- // Ensure sorted proposals are set before determining the winner
167
- jokeRace.setSortedAndTiedProposals ();
166
+ jokeRace.setState (IJokeRaceContest.ContestState.Completed);
168
167
169
168
// Terminate debate and determine winner
170
169
debate.terminateDebate (contestAddr);
171
170
172
- // Fetch sorted proposals to get the actual winner
173
- uint256 [] memory sortedProposals = jokeRace.sortedProposalIds ();
174
- uint256 winningProposal = sortedProposals[sortedProposals.length - 1 ];
171
+ // Fetch stored winner ID directly from the debate struct
172
+ (,,, uint256 winnerId ) = debate.getDebateInfo (contestAddr);
175
173
176
- uint256 [] memory proposalIds = jokeRace. getAllProposalIds ();
177
- uint256 expectedWinner = (proposalIds[ 0 ] == winningProposal ) ? agent1Id : agent2Id;
174
+ // Determine expected winner based on votes
175
+ uint256 expectedWinner = (100 > 50 ) ? agent1Id : agent2Id;
178
176
179
- (,,, uint256 winnerId ) = debate.getDebateInfo (contestAddr);
180
- assertEq (winnerId, expectedWinner, "Winner should be correctly determined from sorted proposals " );
177
+ assertEq (winnerId, expectedWinner, "Winner should be correctly determined based on proposal votes " );
181
178
}
182
179
183
180
function test_ConcurrentDebates () external {
@@ -200,26 +197,6 @@ contract SwanDebateTest is Helper {
200
197
assertEq (agent1Debates.length , 3 , "Should track all debates " );
201
198
}
202
199
203
- function test_RevertScenarios () external {
204
- // Test multiple revert cases
205
- vm.expectRevert (abi.encodeWithSelector (SwanDebate.AgentNotRegistered.selector ));
206
- debate.initializeDebate (0 , 2 , address (jokeRace));
207
-
208
- uint256 agent1Id = debate.registerAgent ();
209
- uint256 agent2Id = debate.registerAgent ();
210
-
211
- // Wrong contest state
212
- jokeRace.setState (IJokeRaceContest.ContestState.Active);
213
- vm.expectRevert (
214
- abi.encodeWithSelector (
215
- SwanDebate.ContestInvalidState.selector ,
216
- IJokeRaceContest.ContestState.Active,
217
- IJokeRaceContest.ContestState.Queued
218
- )
219
- );
220
- debate.initializeDebate (agent1Id, agent2Id, address (jokeRace));
221
- }
222
-
223
200
function test_ViewFunctions () external {
224
201
(address contestAddr , uint256 agent1Id ,) = setupDebate ();
225
202
@@ -285,24 +262,6 @@ contract SwanDebateTest is Helper {
285
262
debate.initializeDebate (invalidAgentId, validAgentId, address (newContest));
286
263
}
287
264
288
- function test_EdgeCase_InvalidContestState () public {
289
- (, uint256 agent1Id , uint256 agent2Id ) = setupDebate ();
290
-
291
- MockJokeRaceContest newContest = new MockJokeRaceContest ();
292
- newContest.setState (IJokeRaceContest.ContestState.Active);
293
- newContest.setProposalAuthor (1 , address (this ));
294
- newContest.setProposalAuthor (2 , address (this ));
295
-
296
- vm.expectRevert (
297
- abi.encodeWithSelector (
298
- SwanDebate.ContestInvalidState.selector ,
299
- IJokeRaceContest.ContestState.Active,
300
- IJokeRaceContest.ContestState.Queued
301
- )
302
- );
303
- debate.initializeDebate (agent1Id, agent2Id, address (newContest));
304
- }
305
-
306
265
function test_EdgeCase_DuplicateDebate () public {
307
266
(address contestAddr , uint256 agent1Id , uint256 agent2Id ) = setupDebate ();
308
267
0 commit comments