From 0a3da0d50c416ac9cc1bbf538e4fc639c6565a5c Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 15 Apr 2022 16:21:21 +0200 Subject: [PATCH] test: verify commitStores deterministic ordering (#11650) Co-authored-by: Aleksandr Bezobchuk --- store/rootmulti/store_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/store/rootmulti/store_test.go b/store/rootmulti/store_test.go index 80cbcf68cb..0a50f11e5c 100644 --- a/store/rootmulti/store_test.go +++ b/store/rootmulti/store_test.go @@ -730,6 +730,40 @@ func TestTraceConcurrency(t *testing.T) { stopW <- struct{}{} } +func TestCommitOrdered(t *testing.T) { + var db dbm.DB = dbm.NewMemDB() + multi := newMultiStoreWithMounts(db, types.PruneNothing) + err := multi.LoadLatestVersion() + require.Nil(t, err) + + commitID := types.CommitID{} + checkStore(t, multi, commitID, commitID) + + k, v := []byte("wind"), []byte("blows") + k2, v2 := []byte("water"), []byte("flows") + k3, v3 := []byte("fire"), []byte("burns") + + store1 := multi.GetStoreByName("store1").(types.KVStore) + store1.Set(k, v) + + store2 := multi.GetStoreByName("store2").(types.KVStore) + store2.Set(k2, v2) + + store3 := multi.GetStoreByName("store3").(types.KVStore) + store3.Set(k3, v3) + + typeID := multi.Commit() + require.Equal(t, int64(1), typeID.Version) + + ci, err := getCommitInfo(db, 1) + require.NoError(t, err) + require.Equal(t, int64(1), ci.Version) + require.Equal(t, 3, len(ci.StoreInfos)) + for i, s := range ci.StoreInfos { + require.Equal(t, s.Name, fmt.Sprintf("store%d", i+1)) + } +} + //----------------------------------------------------------------------- // utils