@@ -15,6 +15,7 @@ import {
15
15
toBN ,
16
16
toGRT ,
17
17
Account ,
18
+ advanceEpochs ,
18
19
} from '../lib/testHelpers'
19
20
20
21
const { AddressZero, HashZero } = constants
@@ -581,16 +582,14 @@ describe('Staking:Allocation', () => {
581
582
await staking . connect ( me . signer ) . closeAllocation ( allocationID , poi )
582
583
} )
583
584
584
- it ( 'should close an allocation (by delegator)' , async function ( ) {
585
+ it ( 'should close an allocation (by public)' , async function ( ) {
586
+ // Reject to close if public address and under max allocation epochs
587
+ const tx1 = staking . connect ( me . signer ) . closeAllocation ( allocationID , poi )
588
+ await expect ( tx1 ) . revertedWith ( '<epochs' )
589
+
585
590
// Move max allocation epochs to close by delegator
586
591
const maxAllocationEpochs = await staking . maxAllocationEpochs ( )
587
- for ( let i = 0 ; i < maxAllocationEpochs + 1 ; i ++ ) {
588
- await advanceToNextEpoch ( epochManager )
589
- }
590
-
591
- // Reject to close if the address is not delegator
592
- const tx1 = staking . connect ( me . signer ) . closeAllocation ( allocationID , poi )
593
- await expect ( tx1 ) . revertedWith ( '!auth' )
592
+ await advanceEpochs ( epochManager , maxAllocationEpochs )
594
593
595
594
// Calculations
596
595
const beforeAlloc = await staking . getAllocation ( allocationID )
@@ -605,9 +604,8 @@ describe('Staking:Allocation', () => {
605
604
// Setup
606
605
await grt . connect ( governor . signer ) . mint ( me . address , toGRT ( '1' ) )
607
606
await grt . connect ( me . signer ) . approve ( staking . address , toGRT ( '1' ) )
608
- await staking . connect ( me . signer ) . delegate ( indexer . address , toGRT ( '1' ) )
609
607
610
- // Should close by delegator
608
+ // Should close by public
611
609
const tx = staking . connect ( me . signer ) . closeAllocation ( allocationID , poi )
612
610
await expect ( tx )
613
611
. emit ( staking , 'AllocationClosed' )
0 commit comments