Skip to content

Commit

Permalink
tests to assert panics and getStoreType
Browse files Browse the repository at this point in the history
  • Loading branch information
udpatil committed Oct 4, 2023
1 parent 478d177 commit 3199d07
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion store/multiversion/mvkv.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (v *VersionIndexedStore) ReverseIterator(start []byte, end []byte) dbm.Iter

// GetStoreType implements types.KVStore.
func (v *VersionIndexedStore) GetStoreType() types.StoreType {
panic("unimplemented")
return v.parent.GetStoreType()
}

// CacheWrap implements types.KVStore.
Expand Down
17 changes: 17 additions & 0 deletions store/multiversion/mvkv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,20 @@ func TestVersionIndexedStoreSetters(t *testing.T) {
require.Equal(t, []byte("value3"), vis.Get([]byte("key2")))
require.Zero(t, len(vis.GetReadset()))
}

func TestVersionIndexedStoreBoilerplateFunctions(t *testing.T) {
mem := dbadapter.Store{DB: dbm.NewMemDB()}
parentKVStore := cachekv.NewStore(mem, types.NewKVStoreKey("mock"), 1000)
mvs := multiversion.NewMultiVersionStore()
// initialize a new VersionIndexedStore
vis := multiversion.NewVersionIndexedStore(parentKVStore, mvs, 1, 2, make(chan scheduler.Abort))

// asserts panics where appropriate
require.Panics(t, func() { vis.CacheWrap(types.NewKVStoreKey("mock")) })
require.Panics(t, func() { vis.CacheWrapWithListeners(types.NewKVStoreKey("mock"), nil) })
require.Panics(t, func() { vis.CacheWrapWithTrace(types.NewKVStoreKey("mock"), nil, nil) })
require.Panics(t, func() { vis.GetWorkingHash() })

// assert properly returns store type
require.Equal(t, types.StoreTypeDB, vis.GetStoreType())
}

0 comments on commit 3199d07

Please sign in to comment.