Skip to content

Commit

Permalink
expanded bonded checks
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic committed May 16, 2023
1 parent d71ad69 commit a7cd212
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion x/superfluid/keeper/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ func (suite *KeeperTestSuite) TestMigrateSuperfluidBondedBalancerToConcentrated(
originalGammLockId = originalGammLockId + 1
}

balancerDelegationPre, _ := stakingKeeper.GetDelegation(ctx, balancerIntermediaryAcc.GetAccAddress(), valAddr)

// System under test.
positionId, amount0, amount1, _, _, concentratedLockId, poolIdLeaving, poolIdEntering, err := superfluidKeeper.MigrateSuperfluidBondedBalancerToConcentrated(ctx, poolJoinAcc, originalGammLockId, coinsToMigrate, synthLockBeforeMigration[0].SynthDenom, tc.tokenOutMins)
if tc.expectedError != nil {
Expand Down Expand Up @@ -351,9 +353,13 @@ func (suite *KeeperTestSuite) TestMigrateSuperfluidBondedBalancerToConcentrated(
_, err = lockupKeeper.GetSyntheticLockup(ctx, originalGammLockId, keeper.StakingSyntheticDenom(balancerLock.Coins[0].Denom, valAddr.String()))
suite.Require().Error(err)

// The delegation from the intermediary account holder does not exist.
// The delegation from the intermediary account holder should not exist.
delegation, found := stakingKeeper.GetDelegation(ctx, balancerIntermediaryAcc.GetAccAddress(), valAddr)
suite.Require().False(found, "expected no delegation, found delegation w/ %d shares", delegation.Shares)

// Check that the original gamm lockup is deleted.
_, err := suite.App.LockupKeeper.GetLockByID(ctx, originalGammLockId)
suite.Require().Error(err)
} else if tc.percentOfSharesToMigrate.LT(sdk.OneDec()) {
// If we migrated part of the shares:
// The intermediary account connection to the old gamm lock should still be present.
Expand All @@ -367,7 +373,17 @@ func (suite *KeeperTestSuite) TestMigrateSuperfluidBondedBalancerToConcentrated(
// The delegation from the intermediary account holder should still exist.
_, found := stakingKeeper.GetDelegation(ctx, balancerIntermediaryAcc.GetAccAddress(), valAddr)
suite.Require().True(found, "expected delegation, found delegation no delegation")

// Check what is remaining in the original gamm lock.
lock, err := suite.App.LockupKeeper.GetLockByID(ctx, originalGammLockId)
suite.Require().NoError(err)
suite.Require().Equal(balancerPoolShareOut.Amount.Sub(coinsToMigrate.Amount).String(), lock.Coins[0].Amount.String(), "expected %s shares, found %s shares", lock.Coins[0].Amount.String(), balancerPoolShareOut.Amount.Sub(coinsToMigrate.Amount).String())
}
// Check the new superfluid staked amount.
clIntermediaryAcc := superfluidKeeper.GetLockIdIntermediaryAccountConnection(ctx, concentratedLockId)
delegation, found := stakingKeeper.GetDelegation(ctx, clIntermediaryAcc, valAddr)
suite.Require().True(found, "expected delegation, found delegation no delegation")
suite.Require().Equal(balancerDelegationPre.Shares.Mul(tc.percentOfSharesToMigrate).RoundInt().Sub(sdk.OneInt()).String(), delegation.Shares.RoundInt().String(), "expected %d shares, found %d shares", balancerDelegationPre.Shares.Mul(tc.percentOfSharesToMigrate).RoundInt().String(), delegation.Shares.String())

// Check if the new intermediary account connection was created.
newConcentratedIntermediaryAccount := superfluidKeeper.GetLockIdIntermediaryAccountConnection(ctx, concentratedLockId)
Expand Down

0 comments on commit a7cd212

Please sign in to comment.