|
4 | 4 | package blockdb |
5 | 5 |
|
6 | 6 | import ( |
7 | | - "slices" |
8 | 7 | "testing" |
9 | 8 |
|
10 | 9 | "github.com/stretchr/testify/require" |
@@ -57,44 +56,6 @@ func TestCacheHas(t *testing.T) { |
57 | 56 | require.True(t, has) |
58 | 57 | } |
59 | 58 |
|
60 | | -func TestCachePutStoresClone(t *testing.T) { |
61 | | - db := newCacheDatabase(t, DefaultConfig()) |
62 | | - height := uint64(40) |
63 | | - block := randomBlock(t) |
64 | | - clone := slices.Clone(block) |
65 | | - require.NoError(t, db.Put(height, clone)) |
66 | | - |
67 | | - // Modify the original block after Put |
68 | | - clone[0] = 99 |
69 | | - |
70 | | - // Cache should have the original unmodified data |
71 | | - cached, ok := db.cache.Get(height) |
72 | | - require.True(t, ok) |
73 | | - require.Equal(t, block, cached) |
74 | | -} |
75 | | - |
76 | | -func TestCacheGetReturnsClone(t *testing.T) { |
77 | | - db := newCacheDatabase(t, DefaultConfig()) |
78 | | - height := uint64(50) |
79 | | - block := randomBlock(t) |
80 | | - require.NoError(t, db.Put(height, block)) |
81 | | - |
82 | | - // Get the block and modify the returned data |
83 | | - data, err := db.Get(height) |
84 | | - require.NoError(t, err) |
85 | | - data[0] = 99 |
86 | | - |
87 | | - // Cache should still have the original unmodified data |
88 | | - cached, ok := db.cache.Get(height) |
89 | | - require.True(t, ok) |
90 | | - require.Equal(t, block, cached) |
91 | | - |
92 | | - // Second Get should also return original data |
93 | | - data, err = db.Get(height) |
94 | | - require.NoError(t, err) |
95 | | - require.Equal(t, block, data) |
96 | | -} |
97 | | - |
98 | 59 | func TestCachePutOverridesSameHeight(t *testing.T) { |
99 | 60 | db := newCacheDatabase(t, DefaultConfig()) |
100 | 61 | height := uint64(60) |
|
0 commit comments