From dfb0be3dbf7e5541396c13f345a1e28353392e63 Mon Sep 17 00:00:00 2001 From: Ragnar Date: Fri, 7 Nov 2025 12:50:02 +0100 Subject: [PATCH 1/3] Update wrappers.go --- blockstm/wrappers.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/blockstm/wrappers.go b/blockstm/wrappers.go index bc5b2d667216..0cb02b5e57cd 100644 --- a/blockstm/wrappers.go +++ b/blockstm/wrappers.go @@ -17,18 +17,15 @@ type msWrapper struct { } func (ms msWrapper) CacheWrapWithTrace(w io.Writer, tc storetypes.TraceContext) storetypes.CacheWrap { - // TODO implement me - panic("implement me") + return cachemulti.NewFromParent(ms.getCacheWrapper, w, tc).(storetypes.CacheWrap) } func (ms msWrapper) CacheMultiStoreWithVersion(version int64) (storetypes.CacheMultiStore, error) { - // TODO implement me - panic("implement me") + panic("cannot branch cached multi-store with a version") } func (ms msWrapper) LatestVersion() int64 { - // TODO implement me - panic("implement me") + panic("cannot get latest version from branch cached multi-store") } func (ms msWrapper) getCacheWrapper(key storetypes.StoreKey) storetypes.CacheWrapper { From 52579e715c304d18775e91d5e1b36ff5608a7c81 Mon Sep 17 00:00:00 2001 From: Ragnar Date: Wed, 12 Nov 2025 23:14:22 +0100 Subject: [PATCH 2/3] Update wrappers.go --- blockstm/wrappers.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/blockstm/wrappers.go b/blockstm/wrappers.go index 0cb02b5e57cd..e76c6e2d4550 100644 --- a/blockstm/wrappers.go +++ b/blockstm/wrappers.go @@ -17,7 +17,8 @@ type msWrapper struct { } func (ms msWrapper) CacheWrapWithTrace(w io.Writer, tc storetypes.TraceContext) storetypes.CacheWrap { - return cachemulti.NewFromParent(ms.getCacheWrapper, w, tc).(storetypes.CacheWrap) + cms := cachemulti.NewFromParent(ms.getCacheWrapper, w, tc) + return cms.CacheWrap() } func (ms msWrapper) CacheMultiStoreWithVersion(version int64) (storetypes.CacheMultiStore, error) { From 4147b90b9ae2f3c2737080014c94b7dad2dcc5d7 Mon Sep 17 00:00:00 2001 From: Ragnar Date: Tue, 2 Dec 2025 15:58:25 +0200 Subject: [PATCH 3/3] Create wrappers_test.go --- blockstm/wrappers_test.go | 48 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 blockstm/wrappers_test.go diff --git a/blockstm/wrappers_test.go b/blockstm/wrappers_test.go new file mode 100644 index 000000000000..6536da838d91 --- /dev/null +++ b/blockstm/wrappers_test.go @@ -0,0 +1,48 @@ +package blockstm + +import ( + "bytes" + "testing" + + "github.com/test-go/testify/require" + + "cosmossdk.io/store/cachemulti" + storetypes "cosmossdk.io/store/types" +) + +func TestMsWrapper_CacheWrapWithTrace(t *testing.T) { + t.Parallel() + storeKey := storetypes.NewKVStoreKey("test") + mmdb := NewMultiMemDB(map[storetypes.StoreKey]int{storeKey: 0}) + ms := msWrapper{mmdb} + + var buf bytes.Buffer + tc := storetypes.TraceContext(map[string]interface{}{"blockHeight": 1}) + + cacheWrappedWithTrace := ms.CacheWrapWithTrace(&buf, tc) + require.NotNil(t, cacheWrappedWithTrace) + require.IsType(t, cachemulti.Store{}, cacheWrappedWithTrace) +} + +func TestMsWrapper_CacheMultiStoreWithVersion(t *testing.T) { + t.Parallel() + storeKey := storetypes.NewKVStoreKey("test") + mmdb := NewMultiMemDB(map[storetypes.StoreKey]int{storeKey: 0}) + ms := msWrapper{mmdb} + + require.Panics(t, func() { + _, _ = ms.CacheMultiStoreWithVersion(1) + }, "should panic when trying to branch cached multi-store with a version") +} + +func TestMsWrapper_LatestVersion(t *testing.T) { + t.Parallel() + storeKey := storetypes.NewKVStoreKey("test") + mmdb := NewMultiMemDB(map[storetypes.StoreKey]int{storeKey: 0}) + ms := msWrapper{mmdb} + + require.Panics(t, func() { + _ = ms.LatestVersion() + }, "should panic when trying to get latest version from branch cached multi-store") +} +