File tree Expand file tree Collapse file tree 2 files changed +38
-3
lines changed Expand file tree Collapse file tree 2 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -263,7 +263,7 @@ func TestHasBlock(t *testing.T) {
263
263
{
264
264
name : "db_closed" ,
265
265
dbClosed : true ,
266
- wantErr : ErrDatabaseClosed ,
266
+ wantErr : database . ErrClosed ,
267
267
},
268
268
}
269
269
@@ -276,14 +276,14 @@ func TestHasBlock(t *testing.T) {
276
276
if i == gapHeight {
277
277
continue
278
278
}
279
- require .NoError (t , store .WriteBlock (i , randomBlock (t )))
279
+ require .NoError (t , store .Put (i , randomBlock (t )))
280
280
}
281
281
282
282
if tc .dbClosed {
283
283
require .NoError (t , store .Close ())
284
284
}
285
285
286
- has , err := store .HasBlock (tc .height )
286
+ has , err := store .Has (tc .height )
287
287
if tc .wantErr != nil {
288
288
require .ErrorIs (t , err , tc .wantErr )
289
289
} else {
Original file line number Diff line number Diff line change @@ -20,6 +20,41 @@ import (
20
20
)
21
21
22
22
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 ) {
23
58
customConfig := DefaultConfig ().WithMinimumHeight (10 )
24
59
25
60
tests := []struct {
You can’t perform that action at this time.
0 commit comments