@@ -329,6 +329,31 @@ describe('SubgraphAvailabilityManager', () => {
329
329
// previous votes are no longer valid
330
330
expect ( await rewardsManager . isDenied ( subgraphDeploymentID1 ) ) . to . be . false
331
331
} )
332
+
333
+ it ( 'clears opposite vote when voting' , async ( ) => {
334
+ const denied = true
335
+ await subgraphAvailabilityManager . connect ( oracleOne ) . vote ( subgraphDeploymentID1 , denied , 0 )
336
+ await subgraphAvailabilityManager . connect ( oracleTwo ) . vote ( subgraphDeploymentID1 , denied , 1 )
337
+ await subgraphAvailabilityManager . connect ( oracleThree ) . vote ( subgraphDeploymentID1 , denied , 2 )
338
+
339
+ // 3/5 oracles vote denied = true so subgraph is denied
340
+ expect ( await rewardsManager . isDenied ( subgraphDeploymentID1 ) ) . to . be . true
341
+
342
+ // oracleOne changes its vote to denied = false
343
+ await subgraphAvailabilityManager . connect ( oracleOne ) . vote ( subgraphDeploymentID1 , false , 0 )
344
+
345
+ // last deny vote should be 0 for oracleOne
346
+ expect (
347
+ await subgraphAvailabilityManager . lastDenyVote ( 0 , subgraphDeploymentID1 , 0 ) ,
348
+ ) . to . be . equal ( 0 )
349
+
350
+ // executionThreshold isn't met now since oracleOne changed its vote
351
+ expect ( await subgraphAvailabilityManager . checkVotes ( subgraphDeploymentID1 , denied ) ) . to . be
352
+ . false
353
+
354
+ // subgraph is still denied in rewards manager because only one oracle changed its vote
355
+ expect ( await rewardsManager . isDenied ( subgraphDeploymentID1 ) ) . to . be . true
356
+ } )
332
357
} )
333
358
334
359
describe ( 'vote many' , async ( ) => {
0 commit comments