From f2f47ffd43428887b2a2680b074020e6ac112512 Mon Sep 17 00:00:00 2001 From: Chenqun Lu Date: Mon, 23 Oct 2023 16:40:01 +0800 Subject: [PATCH] fix(simulation): fix the problem of `validator set is empty after InitGenesis` in simulation test (#18196) --- CHANGELOG.md | 1 + testutil/sims/state_helpers.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59055fe238ab..e69b06bb9c29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/slashing) [#18016](https://github.com/cosmos/cosmos-sdk/pull/18016) Fixed builder function for missed blocks key (`validatorMissedBlockBitArrayPrefixKey`) in slashing/migration/v4 * (x/gov) [#17873](https://github.com/cosmos/cosmos-sdk/pull/17873) Fail any inactive and active proposals whose messages cannot be decoded. * (simulation) [#17911](https://github.com/cosmos/cosmos-sdk/pull/17911) Fix all problems with executing command `make test-sim-custom-genesis-fast` for simulation test. +* (simulation) [#18196](https://github.com/cosmos/cosmos-sdk/pull/18196) Fix the problem of `validator set is empty after InitGenesis` in simulation test. ### API Breaking Changes diff --git a/testutil/sims/state_helpers.go b/testutil/sims/state_helpers.go index a5c4eb60b792..d1a320e983ef 100644 --- a/testutil/sims/state_helpers.go +++ b/testutil/sims/state_helpers.go @@ -208,11 +208,11 @@ func AppStateRandomizedFn( ) appParams.GetOrGenerate( StakePerAccount, &initialStake, r, - func(r *rand.Rand) { initialStake = math.NewInt(r.Int63n(1e12)) }, + func(r *rand.Rand) { initialStake = sdk.DefaultPowerReduction.AddRaw(r.Int63n(1e12)) }, ) appParams.GetOrGenerate( InitiallyBondedValidators, &numInitiallyBonded, r, - func(r *rand.Rand) { numInitiallyBonded = int64(r.Intn(300)) }, + func(r *rand.Rand) { numInitiallyBonded = int64(r.Intn(299) + 1) }, ) if numInitiallyBonded > numAccs {