We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
testutil.MutateGenesisState
Test setups that manually configure GenesisState should be converted to using the testutil.MutateGenesisState.
Example from x/name/client/cli/cli_test.go:
x/name/client/cli/cli_test.go
var nameData nametypes.GenesisState nameData.Params.AllowUnrestrictedNames = true nameData.Params.MaxNameLevels = 2 nameData.Params.MaxSegmentLength = 32 nameData.Params.MinSegmentLength = 1 nameData.Bindings = append(nameData.Bindings, nametypes.NewNameRecord("attribute", s.accountAddr, false)) nameData.Bindings = append(nameData.Bindings, nametypes.NewNameRecord("example.attribute", s.accountAddr, false)) for i := 0; i < s.acc2NameCount; i++ { nameData.Bindings = append(nameData.Bindings, nametypes.NewNameRecord(toWritten(i), s.account2Addr, false)) } nameDataBz, err := cfg.Codec.MarshalJSON(&nameData) s.Require().NoError(err) genesisState[nametypes.ModuleName] = nameDataBz
Should be converted to:
testutil.MutateGenesisState(s.T(), &s.cfg, nametypes.ModuleName, &nametypes.GenesisState{}, func(nameData *nametypes.GenesisState) *nametypes.GenesisState { nameData.Params.AllowUnrestrictedNames = true nameData.Params.MaxNameLevels = 2 nameData.Params.MaxSegmentLength = 32 nameData.Params.MinSegmentLength = 1 nameData.Bindings = append(nameData.Bindings, nametypes.NewNameRecord("attribute", s.accountAddr, false)) nameData.Bindings = append(nameData.Bindings, nametypes.NewNameRecord("example.attribute", s.accountAddr, false)) for i := 0; i < s.acc2NameCount; i++ { nameData.Bindings = append(nameData.Bindings, nametypes.NewNameRecord(toWritten(i), s.account2Addr, false)) } return nameData })
Converting tests to use testutil.MutateGenesisState will make them cleaner and more consistent.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Summary
Test setups that manually configure GenesisState should be converted to using the
testutil.MutateGenesisState
.Problem Definition
Example from
x/name/client/cli/cli_test.go
:Should be converted to:
Proposal
Converting tests to use
testutil.MutateGenesisState
will make them cleaner and more consistent.For Admin Use
The text was updated successfully, but these errors were encountered: