test: fix TestSimAppExportAndBlockedAddrs for simapp v1 (#14036)

This commit is contained in:
Julien Robert 2022-11-28 12:37:13 +01:00 committed by GitHub
parent 5567828674
commit 68c1517046
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 11 deletions

View File

@ -5696,7 +5696,7 @@ type GenesisState struct {
PreviousProposer string `protobuf:"bytes,4,opt,name=previous_proposer,json=previousProposer,proto3" json:"previous_proposer,omitempty"`
// fee_pool defines the outstanding rewards of all validators at genesis.
OutstandingRewards []*ValidatorOutstandingRewardsRecord `protobuf:"bytes,5,rep,name=outstanding_rewards,json=outstandingRewards,proto3" json:"outstanding_rewards,omitempty"`
// fee_pool defines the accumulated commisions of all validators at genesis.
// fee_pool defines the accumulated commissions of all validators at genesis.
ValidatorAccumulatedCommissions []*ValidatorAccumulatedCommissionRecord `protobuf:"bytes,6,rep,name=validator_accumulated_commissions,json=validatorAccumulatedCommissions,proto3" json:"validator_accumulated_commissions,omitempty"`
// fee_pool defines the historical rewards of all validators at genesis.
ValidatorHistoricalRewards []*ValidatorHistoricalRewardsRecord `protobuf:"bytes,7,rep,name=validator_historical_rewards,json=validatorHistoricalRewards,proto3" json:"validator_historical_rewards,omitempty"`

View File

@ -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())

View File

@ -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),
)
}