Skip to content

Commit

Permalink
test: fix TestSimAppExportAndBlockedAddrs for simapp v1 (cosmos#14036)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Nov 28, 2022
1 parent f387269 commit 89f18ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
11 changes: 2 additions & 9 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,20 +675,13 @@ func GetMaccPerms() map[string][]string {
return dupMaccPerms
}

// ModuleAccountAddrsLegacy returns all the app's module account addresses.
func ModuleAccountAddrsLegacy() map[string]bool {
// BlockedAddresses returns all the app's blocked account addresses.
func BlockedAddresses() map[string]bool {
modAccAddrs := make(map[string]bool)
for acc := range GetMaccPerms() {
modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true
}

return modAccAddrs
}

// BlockedAddresses returns all the app's blocked account addresses.
func BlockedAddresses() map[string]bool {
modAccAddrs := ModuleAccountAddrsLegacy()

// allow the following addresses to receive funds
delete(modAccAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String())

Expand Down
10 changes: 9 additions & 1 deletion app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,18 @@ func TestSimAppExportAndBlockedAddrs(t *testing.T) {
AppOpts: simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome),
})

// BlockedAddresses returns a map of addresses in app v1 and a map of modules name in app v2.
for acc := range BlockedAddresses() {
var addr sdk.AccAddress
if modAddr, err := sdk.AccAddressFromBech32(acc); err == nil {
addr = modAddr
} else {
addr = app.AccountKeeper.GetModuleAddress(acc)
}

require.True(
t,
app.BankKeeper.BlockedAddr(app.AccountKeeper.GetModuleAddress(acc)),
app.BankKeeper.BlockedAddr(addr),
fmt.Sprintf("ensure that blocked addresses are properly set in bank keeper: %s should be blocked", acc),
)
}
Expand Down

0 comments on commit 89f18ad

Please sign in to comment.