Skip to content

Commit 914ff33

Browse files
committed
test: add a test for underflow in rewards when min signal changes
1 parent 7c6e27d commit 914ff33

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test/rewards/rewards.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,41 @@ describe('Rewards', () => {
636636
expect(toRound(afterTokenSupply)).eq(toRound(expectedTokenSupply))
637637
})
638638

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+
639674
it('should distribute rewards on closed allocation and send to destination', async function () {
640675
const destinationAddress = randomHexBytes(20)
641676
await staking.connect(indexer1.signer).setRewardsDestination(destinationAddress)

0 commit comments

Comments
 (0)