Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
8 changes: 4 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ func (app *App) LoadHeight(height int64) error {
return app.LoadVersion(height)
}

// ModuleAccountAddrs returns all the app's module account addresses.
// ModuleAccountAddrs returns a map of the app's module account addresses.
func (app *App) ModuleAccountAddrs() map[string]bool {
modAccAddrs := make(map[string]bool)
for acc := range maccPerms {
Expand All @@ -644,11 +644,11 @@ func (app *App) ModuleAccountAddrs() map[string]bool {
return modAccAddrs
}

// BlockedAddresses returns all the app's blocked account addresses.
// BlockedAddresses returns a map of the app's blocked account addresses.
func (app *App) BlockedAddresses() map[string]bool {
modAccAddrs := make(map[string]bool)
for acc := range app.ModuleAccountAddrs() {
modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true
for address := range app.ModuleAccountAddrs() {
modAccAddrs[address] = true
}

// allow the following addresses to receive funds
Expand Down
62 changes: 62 additions & 0 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
tmdb "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/baseapp"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -100,6 +102,57 @@ func TestInitChain(t *testing.T) {
}
}

func TestModuleAccountAddrs(t *testing.T) {
testApp := getTestApp()
got := testApp.ModuleAccountAddrs()

moduleNames := []string{
"fee_collector",
"distribution",
"gov",
"mint",
"bonded_tokens_pool",
"not_bonded_tokens_pool",
"transfer",
"interchainaccounts",
"hyperlane",
"warp",
}
for _, moduleName := range moduleNames {
address := authtypes.NewModuleAddress(moduleName).String()
assert.Contains(t, got, address)
}
assert.Equal(t, len(moduleNames), len(got))
}

func TestBlockedAddresses(t *testing.T) {
testApp := getTestApp()
got := testApp.BlockedAddresses()

t.Run("blocked addresses should not contain the gov module address", func(t *testing.T) {
govAddress := authtypes.NewModuleAddress(govtypes.ModuleName).String()
assert.NotContains(t, got, govAddress)
})
t.Run("blocked addresses should contain all the other module addresses", func(t *testing.T) {
moduleNames := []string{
"fee_collector",
"distribution",
"mint",
"bonded_tokens_pool",
"not_bonded_tokens_pool",
"transfer",
"interchainaccounts",
"hyperlane",
"warp",
}
for _, moduleName := range moduleNames {
address := authtypes.NewModuleAddress(moduleName).String()
assert.Contains(t, got, address)
}
assert.Equal(t, len(moduleNames), len(got))
})
}

func TestNodeHome(t *testing.T) {
// Test that NodeHome is accessible and non-empty
assert.NotEmpty(t, app.NodeHome, "NodeHome should be set and non-empty")
Expand All @@ -121,3 +174,12 @@ type NoopAppOptions struct{}
func (nao NoopAppOptions) Get(string) any {
return nil
}

func getTestApp() *app.App {
logger := log.NewNopLogger()
db := tmdb.NewMemDB()
traceStore := &NoopWriter{}
timeoutCommit := time.Second
appOptions := NoopAppOptions{}
return app.New(logger, db, traceStore, timeoutCommit, appOptions)
}
Loading