Skip to content

Commit

Permalink
Test contract history order
Browse files Browse the repository at this point in the history
  • Loading branch information
alpe authored and conorpp committed Feb 1, 2023
1 parent 5aa0843 commit 57ce507
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions x/wasm/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"bytes"
"encoding/json"
"errors"
fuzz "github.com/google/gofuzz"
"github.com/tendermint/tendermint/libs/rand"
"math"
"os"
"testing"
Expand Down Expand Up @@ -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)
}

0 comments on commit 57ce507

Please sign in to comment.