@@ -537,6 +537,29 @@ describe('Rewards', () => {
537537 )
538538 }
539539
540+ async function setupIndexerAllocationSignalingAfter ( ) {
541+ // Setup
542+ await epochManager . setEpochLength ( 10 )
543+
544+ // Allocate
545+ const tokensToAllocate = toGRT ( '12500' )
546+ await staking . connect ( indexer1 . signer ) . stake ( tokensToAllocate )
547+ await staking
548+ . connect ( indexer1 . signer )
549+ . allocateFrom (
550+ indexer1 . address ,
551+ subgraphDeploymentID1 ,
552+ tokensToAllocate ,
553+ allocationID1 ,
554+ metadata ,
555+ await channelKey1 . generateProof ( indexer1 . address ) ,
556+ )
557+
558+ // Update total signalled
559+ const signalled1 = toGRT ( '1500' )
560+ await curation . connect ( curator1 . signer ) . mint ( subgraphDeploymentID1 , signalled1 , 0 )
561+ }
562+
540563 async function setupIndexerAllocationWithDelegation (
541564 tokensToDelegate : BigNumber ,
542565 delegationParams : DelegationParameters ,
@@ -654,6 +677,24 @@ describe('Rewards', () => {
654677 . withArgs ( indexer1 . address , allocationID1 , await epochManager . currentEpoch ( ) , toBN ( 0 ) )
655678 } )
656679
680+ it ( 'does not revert with an underflow if the minimum signal changes, and signal came after allocation' , async function ( ) {
681+ // Align with the epoch boundary
682+ await advanceToNextEpoch ( epochManager )
683+ // Setup
684+ await setupIndexerAllocationSignalingAfter ( )
685+
686+ await rewardsManager . connect ( governor . signer ) . setMinimumSubgraphSignal ( toGRT ( 14000 ) )
687+
688+ // Jump
689+ await advanceToNextEpoch ( epochManager )
690+
691+ // Close allocation. At this point rewards should be collected for that indexer
692+ const tx = staking . connect ( indexer1 . signer ) . closeAllocation ( allocationID1 , randomHexBytes ( ) )
693+ await expect ( tx )
694+ . emit ( rewardsManager , 'RewardsAssigned' )
695+ . withArgs ( indexer1 . address , allocationID1 , await epochManager . currentEpoch ( ) , toBN ( 0 ) )
696+ } )
697+
657698 it ( 'does not revert if signal was already under minimum' , async function ( ) {
658699 await rewardsManager . connect ( governor . signer ) . setMinimumSubgraphSignal ( toGRT ( 2000 ) )
659700 // Align with the epoch boundary
0 commit comments