From a7cd21274ed1b8d100a045b9d01f1147f9dbef19 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Mon, 15 May 2023 20:57:24 -0500 Subject: [PATCH] expanded bonded checks --- x/superfluid/keeper/migrate_test.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/x/superfluid/keeper/migrate_test.go b/x/superfluid/keeper/migrate_test.go index ad3d0ba5354..ca336d4be04 100644 --- a/x/superfluid/keeper/migrate_test.go +++ b/x/superfluid/keeper/migrate_test.go @@ -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 { @@ -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. @@ -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)