Skip to content

Commit

Permalink
Fix test data generator (#1263)
Browse files Browse the repository at this point in the history
  • Loading branch information
alpe authored Mar 15, 2023
1 parent d648261 commit 2eaa893
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion x/wasm/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ func TestGenesisExportImport(t *testing.T) {
contractAddr := wasmKeeper.ClassicAddressGenerator()(srcCtx, codeID, nil)
wasmKeeper.storeContractInfo(srcCtx, contractAddr, &contract)
wasmKeeper.appendToContractHistory(srcCtx, contractAddr, history...)
wasmKeeper.importContractState(srcCtx, contractAddr, stateModels)
err = wasmKeeper.importContractState(srcCtx, contractAddr, stateModels)
require.NoError(t, err)
}
var wasmParams types.Params
f.NilChance(0).Fuzz(&wasmParams)
Expand Down
8 changes: 5 additions & 3 deletions x/wasm/keeper/test_fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ func FuzzContractCodeHistory(m *types.ContractCodeHistoryEntry, c fuzz.Continue)

func FuzzStateModel(m *types.Model, c fuzz.Continue) {
m.Key = tmBytes.HexBytes(c.RandString())
if len(m.Key) == 0 {
m.Key = tmBytes.HexBytes("non empty key")
if len(m.Key) != 0 {
c.Fuzz(&m.Value)
return
}
c.Fuzz(&m.Value)
// try again, keys must not be empty
FuzzStateModel(m, c)
}

func FuzzAccessType(m *types.AccessType, c fuzz.Continue) {
Expand Down

0 comments on commit 2eaa893

Please sign in to comment.