@@ -22,6 +22,7 @@ import (
22
22
"github.com/golang/protobuf/proto"
23
23
"github.com/hyperledger/fabric/common/ledger/testutil"
24
24
"github.com/hyperledger/fabric/protos/common"
25
+ "github.com/stretchr/testify/assert"
25
26
)
26
27
27
28
func TestBlockfileStream (t * testing.T ) {
@@ -41,22 +42,22 @@ func testBlockfileStream(t *testing.T, numBlocks int) {
41
42
42
43
s , err := newBlockfileStream (w .blockfileMgr .rootDir , 0 , 0 )
43
44
defer s .close ()
44
- testutil . AssertNoError (t , err , "Error in constructing blockfile stream" )
45
+ assert . NoError (t , err , "Error in constructing blockfile stream" )
45
46
46
47
blockCount := 0
47
48
for {
48
49
blockBytes , err := s .nextBlockBytes ()
49
- testutil . AssertNoError (t , err , "Error in getting next block" )
50
+ assert . NoError (t , err , "Error in getting next block" )
50
51
if blockBytes == nil {
51
52
break
52
53
}
53
54
blockCount ++
54
55
}
55
56
// After the stream has been exhausted, both blockBytes and err should be nil
56
57
blockBytes , err := s .nextBlockBytes ()
57
- testutil . AssertNil (t , blockBytes )
58
- testutil . AssertNoError (t , err , "Error in getting next block after exhausting the file" )
59
- testutil . AssertEquals (t , blockCount , numBlocks )
58
+ assert . Nil (t , blockBytes )
59
+ assert . NoError (t , err , "Error in getting next block after exhausting the file" )
60
+ assert . Equal (t , numBlocks , blockCount )
60
61
}
61
62
62
63
func TestBlockFileStreamUnexpectedEOF (t * testing.T ) {
@@ -82,16 +83,16 @@ func testBlockFileStreamUnexpectedEOF(t *testing.T, numBlocks int, partialBlockB
82
83
w .close ()
83
84
s , err := newBlockfileStream (blockfileMgr .rootDir , 0 , 0 )
84
85
defer s .close ()
85
- testutil . AssertNoError (t , err , "Error in constructing blockfile stream" )
86
+ assert . NoError (t , err , "Error in constructing blockfile stream" )
86
87
87
88
for i := 0 ; i < numBlocks ; i ++ {
88
89
blockBytes , err := s .nextBlockBytes ()
89
- testutil . AssertNotNil (t , blockBytes )
90
- testutil . AssertNoError (t , err , "Error in getting next block" )
90
+ assert . NotNil (t , blockBytes )
91
+ assert . NoError (t , err , "Error in getting next block" )
91
92
}
92
93
blockBytes , err := s .nextBlockBytes ()
93
- testutil . AssertNil (t , blockBytes )
94
- testutil . AssertSame (t , err , ErrUnexpectedEndOfBlockfile )
94
+ assert . Nil (t , blockBytes )
95
+ assert . Exactly (t , ErrUnexpectedEndOfBlockfile , err )
95
96
}
96
97
97
98
func TestBlockStream (t * testing.T ) {
@@ -123,19 +124,19 @@ func testBlockStream(t *testing.T, numFiles int) {
123
124
}
124
125
s , err := newBlockStream (blockfileMgr .rootDir , 0 , 0 , numFiles - 1 )
125
126
defer s .close ()
126
- testutil . AssertNoError (t , err , "Error in constructing new block stream" )
127
+ assert . NoError (t , err , "Error in constructing new block stream" )
127
128
blockCount := 0
128
129
for {
129
130
blockBytes , err := s .nextBlockBytes ()
130
- testutil . AssertNoError (t , err , "Error in getting next block" )
131
+ assert . NoError (t , err , "Error in getting next block" )
131
132
if blockBytes == nil {
132
133
break
133
134
}
134
135
blockCount ++
135
136
}
136
137
// After the stream has been exhausted, both blockBytes and err should be nil
137
138
blockBytes , err := s .nextBlockBytes ()
138
- testutil . AssertNil (t , blockBytes )
139
- testutil . AssertNoError (t , err , "Error in getting next block after exhausting the file" )
140
- testutil . AssertEquals (t , blockCount , numFiles * numBlocksInEachFile )
139
+ assert . Nil (t , blockBytes )
140
+ assert . NoError (t , err , "Error in getting next block after exhausting the file" )
141
+ assert . Equal (t , numFiles * numBlocksInEachFile , blockCount )
141
142
}
0 commit comments