@@ -636,6 +636,41 @@ describe('Rewards', () => {
636
636
expect ( toRound ( afterTokenSupply ) ) . eq ( toRound ( expectedTokenSupply ) )
637
637
} )
638
638
639
+ it ( 'does not revert with an underflow if the minimum signal changes' , async function ( ) {
640
+ // Align with the epoch boundary
641
+ await advanceToNextEpoch ( epochManager )
642
+ // Setup
643
+ await setupIndexerAllocation ( )
644
+
645
+ await rewardsManager . connect ( governor . signer ) . setMinimumSubgraphSignal ( toGRT ( 14000 ) )
646
+
647
+ // Jump
648
+ await advanceToNextEpoch ( epochManager )
649
+
650
+ // Close allocation. At this point rewards should be collected for that indexer
651
+ const tx = staking . connect ( indexer1 . signer ) . closeAllocation ( allocationID1 , randomHexBytes ( ) )
652
+ await expect ( tx )
653
+ . emit ( rewardsManager , 'RewardsAssigned' )
654
+ . withArgs ( indexer1 . address , allocationID1 , await epochManager . currentEpoch ( ) , toBN ( 0 ) )
655
+ } )
656
+
657
+ it ( 'does not revert if signal was already under minimum' , async function ( ) {
658
+ await rewardsManager . connect ( governor . signer ) . setMinimumSubgraphSignal ( toGRT ( 2000 ) )
659
+ // Align with the epoch boundary
660
+ await advanceToNextEpoch ( epochManager )
661
+ // Setup
662
+ await setupIndexerAllocation ( )
663
+
664
+ // Jump
665
+ await advanceToNextEpoch ( epochManager )
666
+ // Close allocation. At this point rewards should be collected for that indexer
667
+ const tx = staking . connect ( indexer1 . signer ) . closeAllocation ( allocationID1 , randomHexBytes ( ) )
668
+
669
+ await expect ( tx )
670
+ . emit ( rewardsManager , 'RewardsAssigned' )
671
+ . withArgs ( indexer1 . address , allocationID1 , await epochManager . currentEpoch ( ) , toBN ( 0 ) )
672
+ } )
673
+
639
674
it ( 'should distribute rewards on closed allocation and send to destination' , async function ( ) {
640
675
const destinationAddress = randomHexBytes ( 20 )
641
676
await staking . connect ( indexer1 . signer ) . setRewardsDestination ( destinationAddress )
0 commit comments