Skip to content

Commit

Permalink
Clean up app.yaml usage in test
Browse files Browse the repository at this point in the history
  • Loading branch information
kocubinski committed Jun 1, 2022
1 parent cb3de45 commit 2f198b1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
4 changes: 2 additions & 2 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ func init() {
}

//go:embed app.yaml
var appConfigYaml []byte
var AppConfigYaml []byte

var appConfig = appconfig.LoadYAML(appConfigYaml)
var appConfig = appconfig.LoadYAML(AppConfigYaml)

// NewSimApp returns a reference to an initialized SimApp.
func NewSimApp(
Expand Down
17 changes: 9 additions & 8 deletions simapp/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ modules:
- name: bank
config:
"@type": cosmos.bank.module.v1.Module
blocked_module_accounts:
- fee_collector
- distribution
- mint
- bonded_tokens_pool
- not_bonded_tokens_pool
- gov
- nft
# uncomment to provide a block list different from the modules mentioned in auth.module_account_permissions
# blocked_module_accounts:
# - fee_collector
# - distribution
# - mint
# - bonded_tokens_pool
# - not_bonded_tokens_pool
# - gov
# - nft
12 changes: 1 addition & 11 deletions simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"fmt"
"github.com/cosmos/cosmos-sdk/depinject"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
"os"
"strconv"
"testing"
"time"
Expand Down Expand Up @@ -510,20 +509,11 @@ func (ao EmptyAppOptions) Get(o string) interface{} {
return nil
}

// LoadAppConfig loads SimApp's app.yaml DI config into memory for testing purposes.
func LoadAppConfig() depinject.Config {
yaml, err := os.ReadFile("app.yaml")
if err != nil {
panic("Unable to read app.yaml")
}
return appconfig.LoadYAML(yaml)
}

// ModuleAccountAddrs provides a list of blocked module accounts from configuration in app.yaml
//
// Ported from SimApp
func ModuleAccountAddrs() map[string]bool {
cfg := LoadAppConfig()
cfg := appconfig.LoadYAML(AppConfigYaml)
var bk bankkeeper.Keeper
err := depinject.Inject(cfg, &bk)
if err != nil {
Expand Down

0 comments on commit 2f198b1

Please sign in to comment.