Skip to content

Commit d3f4005

Browse files
committed
fix sim test
1 parent c21b748 commit d3f4005

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

app/sim_test.go

+23-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ import (
2121
"github.com/cosmos/cosmos-sdk/codec"
2222
"github.com/cosmos/cosmos-sdk/store"
2323
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
24+
sdk "github.com/cosmos/cosmos-sdk/types"
2425
"github.com/cosmos/cosmos-sdk/types/module"
2526
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
2627
"github.com/cosmos/cosmos-sdk/x/simulation"
2728
simcli "github.com/cosmos/cosmos-sdk/x/simulation/client/cli"
29+
30+
tax2gastypes "github.com/classic-terra/core/v3/x/tax2gas/types"
2831
)
2932

3033
// SimAppChainID hardcoded chainID for simulation
@@ -142,16 +145,34 @@ func TestAppStateDeterminism(t *testing.T) {
142145
simtestutil.EmptyAppOptions{}, emptyWasmOpts, interBlockCacheOpt(), fauxMerkleModeOpt(),
143146
)
144147

148+
appGenState := app.DefaultGenesis()
149+
tax2gasGenState := tax2gastypes.GenesisState{}
150+
err := app.AppCodec().UnmarshalJSON(appGenState[tax2gastypes.ModuleName], &tax2gasGenState)
151+
require.NoError(t, err)
152+
153+
tax2gasGenState.Params = tax2gastypes.Params{
154+
Enabled: true,
155+
GasPrices: sdk.DecCoins{
156+
sdk.NewDecCoinFromDec("stake", sdk.NewDecWithPrec(0, 3)),
157+
},
158+
}
159+
newGenState := tax2gasGenState
160+
bz, err := app.AppCodec().MarshalJSON(&newGenState)
161+
require.NoError(t, err)
162+
163+
fmt.Println("bz :", string(bz))
164+
appGenState[tax2gastypes.ModuleName] = bz
165+
145166
fmt.Printf(
146167
"running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n",
147168
config.Seed, i+1, numSeeds, j+1, numTimesToRunPerSeed,
148169
)
149170

150-
_, _, err := simulation.SimulateFromSeed(
171+
_, _, err = simulation.SimulateFromSeed(
151172
t,
152173
os.Stdout,
153174
app.BaseApp,
154-
AppStateFn(app.AppCodec(), app.SimulationManager(), app.DefaultGenesis()),
175+
AppStateFn(app.AppCodec(), app.SimulationManager(), appGenState),
155176
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
156177
simtestutil.SimulationOperations(app, app.AppCodec(), config),
157178
app.ModuleAccountAddrs(),

x/tax2gas/types/params.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func NewParams() Params {
6161
func DefaultParams() Params {
6262
return Params{
6363
GasPrices: DefaultGasPrices,
64-
Enabled: false,
64+
Enabled: true,
6565
BypassMinFeeMsgTypes: DefaultBypassMinFeeMsgTypes,
6666
MaxTotalBypassMinFeeMsgGasUsage: DefaultmaxTotalBypassMinFeeMsgGasUsage,
6767
}
@@ -73,9 +73,6 @@ func (p Params) Validate() error {
7373
if len(p.GasPrices) == 0 {
7474
return fmt.Errorf("must provide at least 1 gas prices")
7575
}
76-
if !p.GasPrices.IsAllPositive() {
77-
return fmt.Errorf("gas prices must be positive")
78-
}
7976
}
8077
return nil
8178
}

0 commit comments

Comments
 (0)