@@ -19,6 +19,7 @@ import {
19
19
toGRT ,
20
20
} from '@graphprotocol/sdk'
21
21
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
22
+ import { IRewardsManager } from '../../../build/types'
22
23
23
24
const { AddressZero } = constants
24
25
@@ -93,6 +94,7 @@ describe('Staking:Allocation', () => {
93
94
let epochManager : EpochManager
94
95
let grt : GraphToken
95
96
let staking : IStaking
97
+ let rewardsManager : IRewardsManager
96
98
let libExponential : LibExponential
97
99
98
100
// Test values
@@ -375,6 +377,7 @@ describe('Staking:Allocation', () => {
375
377
epochManager = contracts . EpochManager
376
378
grt = contracts . GraphToken as GraphToken
377
379
staking = contracts . Staking as IStaking
380
+ rewardsManager = contracts . RewardsManager as IRewardsManager
378
381
379
382
const stakingName = isGraphL1ChainId ( graph . chainId ) ? 'L1Staking' : 'L2Staking'
380
383
const entry = graph . addressBook . getEntry ( stakingName )
@@ -875,9 +878,24 @@ describe('Staking:Allocation', () => {
875
878
await expect ( tx ) . revertedWith ( '!active' )
876
879
} )
877
880
878
- it ( 'reject close before at least one epoch has passed' , async function ( ) {
881
+ it ( 'allow close before one epoch has passed' , async function ( ) {
882
+ const currentEpoch = await epochManager . currentEpoch ( )
883
+ const beforeAlloc = await staking . getAllocation ( allocationID )
884
+
879
885
const tx = staking . connect ( indexer ) . closeAllocation ( allocationID , poi )
880
- await expect ( tx ) . revertedWith ( '<epochs' )
886
+ await expect ( tx )
887
+ . emit ( staking , 'AllocationClosed' )
888
+ . withArgs (
889
+ indexer . address ,
890
+ subgraphDeploymentID ,
891
+ currentEpoch ,
892
+ beforeAlloc . tokens ,
893
+ allocationID ,
894
+ indexer . address ,
895
+ poi ,
896
+ false ,
897
+ )
898
+ await expect ( tx ) . not . to . emit ( rewardsManager , 'RewardsAssigned' )
881
899
} )
882
900
883
901
it ( 'reject close if not the owner of allocation' , async function ( ) {
@@ -922,7 +940,7 @@ describe('Staking:Allocation', () => {
922
940
it ( 'should close an allocation (by public) only if allocation is non-zero' , async function ( ) {
923
941
// Reject to close if public address and under max allocation epochs
924
942
const tx1 = staking . connect ( me ) . closeAllocation ( allocationID , poi )
925
- await expect ( tx1 ) . revertedWith ( '<epochs ' )
943
+ await expect ( tx1 ) . revertedWith ( '!auth ' )
926
944
927
945
// Move max allocation epochs to close by delegator
928
946
const maxAllocationEpochs = await staking . maxAllocationEpochs ( )
0 commit comments