diff --git a/x/staking/keeper/liquid_stake_test.go b/x/staking/keeper/liquid_stake_test.go index 43830a7f51e5..1d2876b8791f 100644 --- a/x/staking/keeper/liquid_stake_test.go +++ b/x/staking/keeper/liquid_stake_test.go @@ -25,15 +25,18 @@ func createBaseAccount(app *simapp.SimApp, ctx sdk.Context, accountName string) // Helper function to create 32-length account // Used to mock an liquid staking provider's ICA account -func createICAAccount(app *simapp.SimApp, ctx sdk.Context, accountName string) sdk.AccAddress { - accountAddress := address.Module(accountName, []byte(accountName)) - account := authtypes.NewModuleAccount( - authtypes.NewBaseAccountWithAddress(accountAddress), - accountName, - ) +func createICAAccount(app *simapp.SimApp, ctx sdk.Context) sdk.AccAddress { + icahost := "icahost" + connectionID := "connection-0" + portID := icahost + + moduleAddress := app.AccountKeeper.GetModuleAddress(icahost) + icaAddress := sdk.AccAddress(address.Derive(moduleAddress, []byte(connectionID+portID))) + + account := authtypes.NewBaseAccountWithAddress(icaAddress) app.AccountKeeper.SetAccount(ctx, account) - return accountAddress + return icaAddress } // Helper function to create a module account address from a tokenized share @@ -82,7 +85,7 @@ func TestAccountIsLiquidStakingProvider(t *testing.T) { // Create base and ICA accounts baseAccountAddress := createBaseAccount(app, ctx, "base-account") - icaAccountAddress := createICAAccount(app, ctx, "ica-account") + icaAccountAddress := createICAAccount(app, ctx) // Only the ICA module account should be considered a liquid staking provider require.False(t, app.StakingKeeper.AccountIsLiquidStakingProvider(baseAccountAddress), "base account") @@ -1093,7 +1096,7 @@ func TestCalculateTotalLiquidStaked(t *testing.T) { var delegatorAddress sdk.AccAddress switch { case delegationCase.isLSTP: - delegatorAddress = createICAAccount(app, ctx, delegationCase.delegation.DelegatorAddress) + delegatorAddress = createICAAccount(app, ctx) case delegationCase.isTokenized: delegatorAddress = createTokenizeShareModuleAccount(1) default: diff --git a/x/staking/keeper/msg_server_test.go b/x/staking/keeper/msg_server_test.go index e0e03c7f0653..ec8e32de0efa 100644 --- a/x/staking/keeper/msg_server_test.go +++ b/x/staking/keeper/msg_server_test.go @@ -347,7 +347,7 @@ func TestTokenizeSharesAndRedeemTokens(t *testing.T) { addrVal1, addrVal2 := sdk.ValAddress(addrAcc1), sdk.ValAddress(addrAcc2) // Create ICA module account - icaAccountAddress := createICAAccount(app, ctx, "ica-module-account") + icaAccountAddress := createICAAccount(app, ctx) // Fund module account delegationCoin := sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), tc.delegationAmount) @@ -695,7 +695,7 @@ func TestValidatorBond(t *testing.T) { delegatorAddress := sdk.AccAddress(delegatorPubKey.Address()) validatorAddress := sdk.ValAddress(validatorPubKey.Address()) - icaAccountAddress := createICAAccount(app, ctx, "ica-module-account") + icaAccountAddress := createICAAccount(app, ctx) // Set the delegator address to either be a user account or an ICA account depending on the test case if tc.delegatorIsLSTP {