Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated createICAAccount test to closer resemble ibc code #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions x/staking/keeper/liquid_stake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 account should be considered a liquid staking provider
require.False(t, app.StakingKeeper.AccountIsLiquidStakingProvider(baseAccountAddress), "base account")
Expand Down Expand Up @@ -1048,7 +1051,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:
Expand Down
4 changes: 2 additions & 2 deletions x/staking/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down