refactor(x/simulation)!: remove accounts string (#20056)

This commit is contained in:
Julián Toledano
2024-04-16 11:50:36 +00:00
committed by GitHub
parent 4ed8c8431d
commit 9d6c6ef0ba
6 changed files with 18 additions and 2 deletions
+1
View File
@@ -120,6 +120,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
### API Breaking Changes
* (x/simulation)[#20056](https://github.com/cosmos/cosmos-sdk/pull/20056) `SimulateFromSeed` now takes an address codec as argument.
* (x/crisis) [#20043](https://github.com/cosmos/cosmos-sdk/pull/20043) Changed `NewMsgVerifyInvariant` to accept a string as argument instead of an `AccAddress`.
* (x/genutil) [#19926](https://github.com/cosmos/cosmos-sdk/pull/19926) Removal of the Address.String() method and related changes:
* Added an address codec as an argument to `CollectTxs`, `GenAppStateFromConfig`, and `AddGenesisAccount`.
+1 -1
View File
@@ -306,7 +306,7 @@ func NewSimApp(
return app
}
// overwritte default ante handlers with custom ante handlers
// overwrite default ante handlers with custom ante handlers
// set SkipAnteHandler to true in app config and set custom ante handler on baseapp
func (app *SimApp) setCustomAnteHandler() {
anteHandler, err := NewAnteHandler(
+2
View File
@@ -10,6 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client/flags"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/server"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
@@ -72,6 +73,7 @@ func BenchmarkFullAppSimulation(b *testing.B) {
BlockedAddresses(),
config,
app.AppCodec(),
codectestutil.CodecOptions{}.GetAddressCodec(),
)
// export state and simParams before the simulation error is checked
+6
View File
@@ -26,6 +26,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client/flags"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/server"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
@@ -92,6 +93,7 @@ func TestFullAppSimulation(t *testing.T) {
BlockedAddresses(),
config,
app.AppCodec(),
codectestutil.CodecOptions{}.GetAddressCodec(),
)
// export state and simParams before the simulation error is checked
@@ -140,6 +142,7 @@ func TestAppImportExport(t *testing.T) {
BlockedAddresses(),
config,
app.AppCodec(),
codectestutil.CodecOptions{}.GetAddressCodec(),
)
// export state and simParams before the simulation error is checked
@@ -261,6 +264,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
BlockedAddresses(),
config,
app.AppCodec(),
codectestutil.CodecOptions{}.GetAddressCodec(),
)
// export state and simParams before the simulation error is checked
@@ -313,6 +317,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
BlockedAddresses(),
config,
app.AppCodec(),
codectestutil.CodecOptions{}.GetAddressCodec(),
)
require.NoError(t, err)
}
@@ -392,6 +397,7 @@ func TestAppStateDeterminism(t *testing.T) {
BlockedAddresses(),
config,
app.AppCodec(),
codectestutil.CodecOptions{}.GetAddressCodec(),
)
require.NoError(t, err)
+1
View File
@@ -8,6 +8,7 @@ import (
epochstypes "cosmossdk.io/x/epochs/types"
protocolpooltypes "cosmossdk.io/x/protocolpool/types"
upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/types/module"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
)
+7 -1
View File
@@ -13,6 +13,7 @@ import (
abci "github.com/cometbft/cometbft/abci/types"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
"cosmossdk.io/core/address"
"cosmossdk.io/core/header"
"github.com/cosmos/cosmos-sdk/baseapp"
@@ -66,6 +67,7 @@ func SimulateFromSeed(
blockedAddrs map[string]bool,
config simulation.Config,
cdc codec.JSONCodec,
addresscodec address.Codec,
) (stopEarly bool, exportedParams Params, err error) {
tb.Helper()
// in case we have to end early, don't os.Exit so that we can run cleanup code.
@@ -101,7 +103,11 @@ func SimulateFromSeed(
var tmpAccs []simulation.Account
for _, acc := range accs {
if !blockedAddrs[acc.Address.String()] {
accAddr, err := addresscodec.BytesToString(acc.Address)
if err != nil {
return true, params, err
}
if !blockedAddrs[accAddr] {
tmpAccs = append(tmpAccs, acc)
}
}