@@ -38,9 +38,7 @@ func TestHeaderStorage(t *testing.T) {
3838 t .Fatalf ("Non existent header returned: %v" , entry )
3939 }
4040 // Write and verify the header in the database
41- if err := WriteHeader (db , header ); err != nil {
42- t .Fatalf ("Failed to write header into database: %v" , err )
43- }
41+ rawdb .WriteHeader (db , header )
4442 if entry := GetHeader (db , header .Hash (), header .Number .Uint64 ()); entry == nil {
4543 t .Fatalf ("Stored header not found" )
4644 } else if entry .Hash () != header .Hash () {
@@ -78,9 +76,7 @@ func TestBodyStorage(t *testing.T) {
7876 t .Fatalf ("Non existent body returned: %v" , entry )
7977 }
8078 // Write and verify the body in the database
81- if err := WriteBody (db , hash , 0 , body ); err != nil {
82- t .Fatalf ("Failed to write body into database: %v" , err )
83- }
79+ rawdb .WriteBody (db , hash , 0 , body )
8480 if entry := GetBody (db , hash , 0 ); entry == nil {
8581 t .Fatalf ("Stored body not found" )
8682 } else if types .DeriveSha (types .Transactions (entry .Transactions )) != types .DeriveSha (types .Transactions (body .Transactions )) || types .CalcUncleHash (entry .Uncles ) != types .CalcUncleHash (body .Uncles ) {
@@ -124,9 +120,7 @@ func TestBlockStorage(t *testing.T) {
124120 t .Fatalf ("Non existent body returned: %v" , entry )
125121 }
126122 // Write and verify the block in the database
127- if err := WriteBlock (db , block ); err != nil {
128- t .Fatalf ("Failed to write block into database: %v" , err )
129- }
123+ rawdb .WriteBlock (db , block )
130124 if entry := GetBlock (db , block .Hash (), block .NumberU64 ()); entry == nil {
131125 t .Fatalf ("Stored block not found" )
132126 } else if entry .Hash () != block .Hash () {
@@ -165,30 +159,22 @@ func TestPartialBlockStorage(t *testing.T) {
165159 ReceiptHash : types .EmptyRootHash ,
166160 })
167161 // Store a header and check that it's not recognized as a block
168- if err := WriteHeader (db , block .Header ()); err != nil {
169- t .Fatalf ("Failed to write header into database: %v" , err )
170- }
162+ rawdb .WriteHeader (db , block .Header ())
171163 if entry := GetBlock (db , block .Hash (), block .NumberU64 ()); entry != nil {
172164 t .Fatalf ("Non existent block returned: %v" , entry )
173165 }
174166 DeleteHeader (db , block .Hash (), block .NumberU64 ())
175167
176168 // Store a body and check that it's not recognized as a block
177- if err := WriteBody (db , block .Hash (), block .NumberU64 (), block .Body ()); err != nil {
178- t .Fatalf ("Failed to write body into database: %v" , err )
179- }
169+ rawdb .WriteBody (db , block .Hash (), block .NumberU64 (), block .Body ())
180170 if entry := GetBlock (db , block .Hash (), block .NumberU64 ()); entry != nil {
181171 t .Fatalf ("Non existent block returned: %v" , entry )
182172 }
183173 DeleteBody (db , block .Hash (), block .NumberU64 ())
184174
185175 // Store a header and a body separately and check reassembly
186- if err := WriteHeader (db , block .Header ()); err != nil {
187- t .Fatalf ("Failed to write header into database: %v" , err )
188- }
189- if err := WriteBody (db , block .Hash (), block .NumberU64 (), block .Body ()); err != nil {
190- t .Fatalf ("Failed to write body into database: %v" , err )
191- }
176+ rawdb .WriteHeader (db , block .Header ())
177+ rawdb .WriteBody (db , block .Hash (), block .NumberU64 (), block .Body ())
192178 if entry := GetBlock (db , block .Hash (), block .NumberU64 ()); entry == nil {
193179 t .Fatalf ("Stored block not found" )
194180 } else if entry .Hash () != block .Hash () {
@@ -231,9 +217,7 @@ func TestCanonicalMappingStorage(t *testing.T) {
231217 t .Fatalf ("Non existent canonical mapping returned: %v" , entry )
232218 }
233219 // Write and verify the TD in the database
234- if err := WriteCanonicalHash (db , hash , number ); err != nil {
235- t .Fatalf ("Failed to write canonical mapping into database: %v" , err )
236- }
220+ rawdb .WriteCanonicalHash (db , hash , number )
237221 if entry := GetCanonicalHash (db , number ); entry == (common.Hash {}) {
238222 t .Fatalf ("Stored canonical mapping not found" )
239223 } else if entry != hash {
@@ -268,9 +252,7 @@ func TestHeadStorage(t *testing.T) {
268252 if err := WriteHeadHeaderHash (db , blockHead .Hash ()); err != nil {
269253 t .Fatalf ("Failed to write head header hash: %v" , err )
270254 }
271- if err := WriteHeadBlockHash (db , blockFull .Hash ()); err != nil {
272- t .Fatalf ("Failed to write head block hash: %v" , err )
273- }
255+ rawdb .WriteHeadBlockHash (db , blockFull .Hash ())
274256 if err := WriteHeadFastBlockHash (db , blockFast .Hash ()); err != nil {
275257 t .Fatalf ("Failed to write fast head block hash: %v" , err )
276258 }
@@ -304,9 +286,7 @@ func TestLookupStorage(t *testing.T) {
304286 }
305287 }
306288 // Insert all the transactions into the database, and verify contents
307- if err := WriteBlock (db , block ); err != nil {
308- t .Fatalf ("failed to write block contents: %v" , err )
309- }
289+ rawdb .WriteBlock (db , block )
310290 if err := WriteTxLookupEntries (db , block ); err != nil {
311291 t .Fatalf ("failed to write transactions: %v" , err )
312292 }
0 commit comments