From 89f18ad425a21c41adb6deb786b1f426c7f7d179 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Mon, 28 Nov 2022 12:37:13 +0100 Subject: [PATCH] test: fix `TestSimAppExportAndBlockedAddrs` for simapp v1 (#14036) --- app.go | 11 ++--------- app_test.go | 10 +++++++++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app.go b/app.go index 3b45f7028779..ad5360494872 100644 --- a/app.go +++ b/app.go @@ -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()) diff --git a/app_test.go b/app_test.go index e9175e9bb2f3..539db5dfa604 100644 --- a/app_test.go +++ b/app_test.go @@ -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), ) }