Skip to content

Commit

Permalink
refactor: don't use simapp.AppConfig outside simapp (cosmos#14328)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Dec 16, 2022
1 parent cbee1b3 commit c824809
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
4 changes: 2 additions & 2 deletions simapp/sim_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func BenchmarkFullAppSimulation(b *testing.B) {
AppStateFn(app.AppCodec(), app.SimulationManager()),
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
simtestutil.SimulationOperations(app, app.AppCodec(), config),
ModuleAccountAddrs(),
BlockedAddresses(),
config,
app.AppCodec(),
)
Expand Down Expand Up @@ -107,7 +107,7 @@ func BenchmarkInvariants(b *testing.B) {
AppStateFn(app.AppCodec(), app.SimulationManager()),
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
simtestutil.SimulationOperations(app, app.AppCodec(), config),
ModuleAccountAddrs(),
BlockedAddresses(),
config,
app.AppCodec(),
)
Expand Down
10 changes: 5 additions & 5 deletions simapp/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestFullAppSimulation(t *testing.T) {
AppStateFn(app.AppCodec(), app.SimulationManager()),
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
simtestutil.SimulationOperations(app, app.AppCodec(), config),
ModuleAccountAddrs(),
BlockedAddresses(),
config,
app.AppCodec(),
)
Expand Down Expand Up @@ -140,7 +140,7 @@ func TestAppImportExport(t *testing.T) {
AppStateFn(app.AppCodec(), app.SimulationManager()),
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
simtestutil.SimulationOperations(app, app.AppCodec(), config),
ModuleAccountAddrs(),
BlockedAddresses(),
config,
app.AppCodec(),
)
Expand Down Expand Up @@ -257,7 +257,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
AppStateFn(app.AppCodec(), app.SimulationManager()),
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
simtestutil.SimulationOperations(app, app.AppCodec(), config),
ModuleAccountAddrs(),
BlockedAddresses(),
config,
app.AppCodec(),
)
Expand Down Expand Up @@ -305,7 +305,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
AppStateFn(app.AppCodec(), app.SimulationManager()),
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
simtestutil.SimulationOperations(newApp, newApp.AppCodec(), config),
ModuleAccountAddrs(),
BlockedAddresses(),
config,
app.AppCodec(),
)
Expand Down Expand Up @@ -360,7 +360,7 @@ func TestAppStateDeterminism(t *testing.T) {
AppStateFn(app.AppCodec(), app.SimulationManager()),
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
simtestutil.SimulationOperations(app, app.AppCodec(), config),
ModuleAccountAddrs(),
BlockedAddresses(),
config,
app.AppCodec(),
)
Expand Down
14 changes: 0 additions & 14 deletions simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
tmtypes "github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tm-db"

"cosmossdk.io/depinject"
"cosmossdk.io/math"

bam "github.com/cosmos/cosmos-sdk/baseapp"
Expand All @@ -29,7 +28,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module/testutil"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
)
Expand Down Expand Up @@ -217,18 +215,6 @@ func initAccountWithCoins(app *SimApp, ctx sdk.Context, addr sdk.AccAddress, coi
}
}

// ModuleAccountAddrs provides a list of blocked module accounts from configuration in AppConfig
//
// Ported from SimApp
func ModuleAccountAddrs() map[string]bool {
var bk bankkeeper.Keeper
err := depinject.Inject(AppConfig, &bk)
if err != nil {
panic("unable to load DI container")
}
return bk.GetBlockedAddresses()
}

// NewTestNetworkFixture returns a new simapp AppConstructor for network simulation tests
func NewTestNetworkFixture() network.TestFixture {
dir, err := os.MkdirTemp("", "simapp")
Expand Down

0 comments on commit c824809

Please sign in to comment.