5
5
"path"
6
6
"testing"
7
7
8
- "gotest.tools/assert"
9
-
8
+ "github.com/stretchr/testify/assert"
10
9
"github.com/vitelabs/go-vite/v2/common"
11
10
"github.com/vitelabs/go-vite/v2/crypto"
12
11
chain_file_manager "github.com/vitelabs/go-vite/v2/ledger/chain/file_manager"
@@ -15,7 +14,7 @@ import (
15
14
func TestReadSnapshotBlocks (t * testing.T ) {
16
15
chainDir := path .Join (common .HomeDir (), ".gvite/mockdata/ledger_2101_2" )
17
16
db , err := NewBlockDB (chainDir )
18
- assert .NilError (t , err )
17
+ assert .NoError (t , err )
19
18
statusList := db .GetStatus ()
20
19
for _ , status := range statusList {
21
20
t .Log (status .Name , status .Count , status .Size , status .Status )
@@ -29,7 +28,7 @@ func TestReadSnapshotBlocks(t *testing.T) {
29
28
if err == io .EOF {
30
29
break
31
30
}
32
- assert .NilError (t , err )
31
+ assert .NoError (t , err )
33
32
if nextLocation == nil {
34
33
break
35
34
}
@@ -45,7 +44,7 @@ func TestReadSnapshotBlocks(t *testing.T) {
45
44
func TestReadAccountBlocks (t * testing.T ) {
46
45
chainDir := path .Join (common .HomeDir (), ".gvite/mockdata/ledger_2101_2" )
47
46
db , err := NewBlockDB (chainDir )
48
- assert .NilError (t , err )
47
+ assert .NoError (t , err )
49
48
statusList := db .GetStatus ()
50
49
for _ , status := range statusList {
51
50
t .Log (status .Name , status .Count , status .Size , status .Status )
@@ -59,7 +58,7 @@ func TestReadAccountBlocks(t *testing.T) {
59
58
if err == io .EOF {
60
59
break
61
60
}
62
- assert .NilError (t , err )
61
+ assert .NoError (t , err )
63
62
if nextLocation == nil {
64
63
break
65
64
}
@@ -74,7 +73,7 @@ func TestReadAccountBlocks(t *testing.T) {
74
73
func TestReadLocation (t * testing.T ) {
75
74
chainDir := path .Join (common .HomeDir (), ".gvite/mockdata/ledger_2101_1" )
76
75
db , err := NewBlockDB (chainDir )
77
- assert .NilError (t , err )
76
+ assert .NoError (t , err )
78
77
statusList := db .GetStatus ()
79
78
for _ , status := range statusList {
80
79
t .Log (status .Name , status .Count , status .Size , status .Status )
@@ -88,33 +87,33 @@ func TestDiffBlocksDB(t *testing.T) {
88
87
chainDirA := path .Join (common .HomeDir (), ".gvite/mockdata/ledger_2101_1" )
89
88
chainDirB := path .Join (common .HomeDir (), ".gvite/mockdata/ledger_2101_2" )
90
89
dbA , err := NewBlockDB (chainDirA )
91
- assert .NilError (t , err )
90
+ assert .NoError (t , err )
92
91
dbB , err := NewBlockDB (chainDirB )
93
- assert .NilError (t , err )
92
+ assert .NoError (t , err )
94
93
95
94
location := chain_file_manager .NewLocation (1 , 7333187 )
96
95
//printLocationContext(t, location, dbA)
97
96
//printLocationContext(t, location, dbB)
98
97
99
98
for {
100
99
bytA , nextLocationA , err := dbA .ReadUnitBytes (location )
101
- assert .NilError (t , err )
100
+ assert .NoError (t , err )
102
101
bytB , nextLocationB , err := dbB .ReadUnitBytes (location )
103
- assert .NilError (t , err )
102
+ assert .NoError (t , err )
104
103
105
104
t .Log (location .FileId , location .Offset )
106
105
assert .Equal (t , nextLocationA .FileId , nextLocationB .FileId , nextLocationA .String (), nextLocationB .String (), location .String ())
107
106
assert .Equal (t , nextLocationA .Offset , nextLocationB .Offset , nextLocationA .String (), nextLocationB .String (), location .String ())
108
107
assert .Equal (t , len (bytA ), len (bytB ))
109
- assert .DeepEqual (t , crypto .Hash256 (bytA ), crypto .Hash256 (bytB ))
108
+ assert .EqualValues (t , crypto .Hash256 (bytA ), crypto .Hash256 (bytB ))
110
109
111
110
location = nextLocationA
112
111
}
113
112
}
114
113
115
114
func printLocationContext (t * testing.T , location * chain_file_manager.Location , db * BlockDB ) {
116
115
sb , ab , nextLocation , err := db .ReadUnit (location )
117
- assert .NilError (t , err )
116
+ assert .NoError (t , err )
118
117
if sb != nil {
119
118
t .Log ("snapshot block" , sb .Height , sb .Hash )
120
119
}
0 commit comments