From 57ce5075c9dd440a9d7d5af284da2c673b554c40 Mon Sep 17 00:00:00 2001 From: Alex Peters Date: Thu, 8 Sep 2022 14:48:57 +0200 Subject: [PATCH] Test contract history order --- x/wasm/keeper/keeper_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/x/wasm/keeper/keeper_test.go b/x/wasm/keeper/keeper_test.go index ac26f1039..7d2f2c388 100644 --- a/x/wasm/keeper/keeper_test.go +++ b/x/wasm/keeper/keeper_test.go @@ -4,6 +4,8 @@ import ( "bytes" "encoding/json" "errors" + fuzz "github.com/google/gofuzz" + "github.com/tendermint/tendermint/libs/rand" "math" "os" "testing" @@ -1936,3 +1938,20 @@ func TestSetAccessConfig(t *testing.T) { }) } } + +func TestAppendToContractHistory(t *testing.T) { + ctx, keepers := CreateTestInput(t, false, SupportedFeatures) + var contractAddr sdk.AccAddress = rand.Bytes(types.ContractAddrLen) + var orderedEntries []types.ContractCodeHistoryEntry + + f := fuzz.New().Funcs(ModelFuzzers...) + for i := 0; i < 10; i++ { + var entry types.ContractCodeHistoryEntry + f.Fuzz(&entry) + keepers.WasmKeeper.appendToContractHistory(ctx, contractAddr, entry) + orderedEntries = append(orderedEntries, entry) + } + // when + gotHistory := keepers.WasmKeeper.GetContractHistory(ctx, contractAddr) + assert.Equal(t, orderedEntries, gotHistory) +}