Skip to content

Commit 2ef8932

Browse files
committed
add tests for basic write values
1 parent 3663e7f commit 2ef8932

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

x/blockdb/writeblock_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,41 @@ import (
2020
)
2121

2222
func TestWriteBlock_Basic(t *testing.T) {
23+
tests := []struct {
24+
name string
25+
block []byte
26+
want []byte
27+
}{
28+
{
29+
name: "normal write",
30+
block: []byte("hello"),
31+
want: []byte("hello"),
32+
},
33+
{
34+
name: "empty block",
35+
block: []byte{},
36+
want: []byte{},
37+
},
38+
{
39+
name: "nil block",
40+
block: nil,
41+
want: []byte{},
42+
},
43+
}
44+
for _, tt := range tests {
45+
t.Run(tt.name, func(t *testing.T) {
46+
db, cleanup := newTestDatabase(t, DefaultConfig())
47+
defer cleanup()
48+
require.NoError(t, db.Put(0, tt.block))
49+
50+
got, err := db.Get(0)
51+
require.NoError(t, err)
52+
require.Equal(t, tt.want, got)
53+
})
54+
}
55+
}
56+
57+
func TestWriteBlock_MaxHeight(t *testing.T) {
2358
customConfig := DefaultConfig().WithMinimumHeight(10)
2459

2560
tests := []struct {

0 commit comments

Comments
 (0)