@@ -400,7 +400,7 @@ describe('Staking::Delegation', () => {
400
400
await shouldDelegate ( delegator2 , toGRT ( '5000' ) )
401
401
} )
402
402
403
- it ( 'should delegate a high number of tokens' , async function ( ) {
403
+ it ( 'should delegate a high amount of tokens' , async function ( ) {
404
404
await shouldDelegate ( delegator , toGRT ( '100' ) )
405
405
await shouldDelegate ( delegator , toGRT ( '1000000000000000000' ) )
406
406
} )
@@ -416,9 +416,10 @@ describe('Staking::Delegation', () => {
416
416
await shouldDelegate ( delegator , toGRT ( '10000000' ) )
417
417
} )
418
418
419
- it ( 'should delegate and burn delegation deposit tax (100%)' , async function ( ) {
419
+ it ( 'reject delegate with delegation deposit tax (100%)' , async function ( ) {
420
420
await staking . setDelegationTaxPercentage ( 1000000 )
421
- await shouldDelegate ( delegator , toGRT ( '10000000' ) )
421
+ const tx = staking . connect ( delegator . signer ) . delegate ( indexer . address , toGRT ( '10000000' ) )
422
+ await expect ( tx ) . revertedWith ( '!shares' )
422
423
} )
423
424
} )
424
425
} )
@@ -649,5 +650,25 @@ describe('Staking::Delegation', () => {
649
650
const afterDelegationPool = await staking . delegationPools ( indexer . address )
650
651
expect ( afterDelegationPool . tokens ) . eq ( beforeDelegationPool . tokens . add ( delegationFees ) )
651
652
} )
653
+
654
+ it ( 'revert if it cannot assign the smallest amount of shares' , async function ( ) {
655
+ // Init the delegation pool
656
+ await shouldDelegate ( delegator , tokensToDelegate )
657
+
658
+ // Collect funds thru full allocation cycle
659
+ await staking . connect ( governor . signer ) . setDelegationRatio ( 10 )
660
+ await staking . connect ( indexer . signer ) . setDelegationParameters ( 0 , 0 , 0 )
661
+ await setupAllocation ( tokensToAllocate )
662
+ await staking . connect ( assetHolder . signer ) . collect ( tokensToCollect , allocationID )
663
+ await advanceToNextEpoch ( epochManager )
664
+ await staking . connect ( indexer . signer ) . closeAllocation ( allocationID , poi )
665
+ await advanceToNextEpoch ( epochManager )
666
+ await staking . connect ( indexer . signer ) . claim ( allocationID , true )
667
+
668
+ // Delegate with such small amount of tokens (1 wei) that we do not have enough precision
669
+ // to even assign 1 wei of shares
670
+ const tx = staking . connect ( delegator . signer ) . delegate ( indexer . address , toBN ( 1 ) )
671
+ await expect ( tx ) . revertedWith ( '!shares' )
672
+ } )
652
673
} )
653
674
} )
0 commit comments