test(systemtest): Fix prune & gov test (#22190)

This commit is contained in:
Hieu Vu 2024-10-09 22:43:31 +07:00 committed by GitHub
parent 91c0e79f47
commit 597e0fac11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 11 deletions

View File

@ -33,6 +33,15 @@ func SetGovVotingPeriod(t *testing.T, period time.Duration) GenesisMutator {
}
}
func SetGovExpeditedVotingPeriod(t *testing.T, period time.Duration) GenesisMutator {
t.Helper()
return func(genesis []byte) []byte {
state, err := sjson.SetRawBytes(genesis, "app_state.gov.params.expedited_voting_period", []byte(fmt.Sprintf("%q", period.String())))
require.NoError(t, err)
return state
}
}
// GetGenesisBalance return the balance amount for an address from the given genesis json
func GetGenesisBalance(rawGenesis []byte, addr string) sdk.Coins {
var r []sdk.Coin

View File

@ -375,6 +375,13 @@ func TestQueryDeposit(t *testing.T) {
sut.ResetChain(t)
cli := NewCLIWrapper(t, sut, verbose)
// short voting period
// update expedited voting period to avoid validation error
sut.ModifyGenesisJSON(
t,
SetGovVotingPeriod(t, time.Second*8),
SetGovExpeditedVotingPeriod(t, time.Second*7),
)
// get validator address
valAddr := gjson.Get(cli.Keys("keys", "list"), "0.address").String()

View File

@ -89,7 +89,7 @@ func TestPrune(t *testing.T) {
// prune
var command []string
if isV2() {
command = []string{"store", "prune", "--keep-recent=1"}
command = []string{"store", "prune", "--store.keep-recent=1"}
} else {
command = []string{"prune", "everything"}
}

View File

@ -134,16 +134,6 @@ func (s *SystemUnderTest) SetupChain() {
if err != nil {
panic(fmt.Sprintf("failed to set block max gas: %s", err))
}
// Short period for gov
genesisBz, err = sjson.SetRawBytes(genesisBz, "app_state.gov.params.voting_period", []byte(fmt.Sprintf(`"%s"`, "8s")))
if err != nil {
panic(fmt.Sprintf("failed to set regular voting period: %s", err))
}
// update expedited voting period to avoid validation error
genesisBz, err = sjson.SetRawBytes(genesisBz, "app_state.gov.params.expedited_voting_period", []byte(fmt.Sprintf(`"%s"`, "7s")))
if err != nil {
panic(fmt.Sprintf("failed to set expedited voting period: %s", err))
}
s.withEachNodeHome(func(i int, home string) {
if err := saveGenesis(home, genesisBz); err != nil {
panic(err)