From 48a864f93d73d942203dc6cdee7e611974fe0a84 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Mon, 15 Jan 2018 20:10:46 -0500 Subject: [PATCH] store: fix tests --- store/rootmultistore.go | 2 +- store/rootmultistore_test.go | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/store/rootmultistore.go b/store/rootmultistore.go index 67c0f1b2f2..944cea4a00 100644 --- a/store/rootmultistore.go +++ b/store/rootmultistore.go @@ -111,7 +111,7 @@ func (rs *rootMultiStore) LoadVersion(ver int64) error { } func (rs *rootMultiStore) nameToKey(name string) SubstoreKey { - for key, _ := range rs.substores { + for key, _ := range rs.storeLoaders { if key.Name() == name { return key } diff --git a/store/rootmultistore_test.go b/store/rootmultistore_test.go index e66394146c..eafb2ef4a2 100644 --- a/store/rootmultistore_test.go +++ b/store/rootmultistore_test.go @@ -4,8 +4,11 @@ import ( "testing" "github.com/stretchr/testify/assert" + dbm "github.com/tendermint/tmlibs/db" "github.com/tendermint/tmlibs/merkle" + + sdk "github.com/cosmos/cosmos-sdk/types" ) func TestMultistoreCommitLoad(t *testing.T) { @@ -65,13 +68,13 @@ func TestMultistoreCommitLoad(t *testing.T) { func newMultiStoreWithLoaders(db dbm.DB) *rootMultiStore { store := NewCommitMultiStore(db) - storeLoaders := map[string]CommitStoreLoader{ - "store1": newMockCommitStore, - "store2": newMockCommitStore, - "store3": newMockCommitStore, + storeLoaders := map[SubstoreKey]CommitStoreLoader{ + sdk.NewKVStoreKey("store1"): newMockCommitStore, + sdk.NewKVStoreKey("store2"): newMockCommitStore, + sdk.NewKVStoreKey("store3"): newMockCommitStore, } - for name, loader := range storeLoaders { - store.SetSubstoreLoader(name, loader) + for key, loader := range storeLoaders { + store.SetSubstoreLoader(key, loader) } return store } @@ -90,9 +93,10 @@ func getExpectedCommitID(store *rootMultiStore, ver int64) CommitID { } } -func hashStores(stores map[string]CommitStore) []byte { +func hashStores(stores map[SubstoreKey]CommitStore) []byte { m := make(map[string]interface{}, len(stores)) - for name, store := range stores { + for key, store := range stores { + name := key.Name() m[name] = substore{ Name: name, substoreCore: substoreCore{