@@ -26,6 +26,7 @@ import (
2626 "github.com/ipfs/go-cid"
2727 blockstore "github.com/ipfs/go-ipfs-blockstore"
2828 dshelp "github.com/ipfs/go-ipfs-ds-help"
29+ "github.com/jmoiron/sqlx"
2930 "github.com/multiformats/go-multihash"
3031 "github.com/stretchr/testify/require"
3132
@@ -190,7 +191,7 @@ func TestSQLXIndexer(t *testing.T) {
190191 BaseFee * int64 `db:"base_fee"`
191192 }
192193 header := new (res )
193- err = db .QueryRow (context .Background (), pgStr , mocks .BlockNumber .Uint64 ()).StructScan (header )
194+ err = db .QueryRow (context .Background (), pgStr , mocks .BlockNumber .Uint64 ()).( * sqlx. Row ). StructScan (header )
194195 if err != nil {
195196 t .Fatal (err )
196197 }
@@ -242,50 +243,47 @@ func TestSQLXIndexer(t *testing.T) {
242243 if err != nil {
243244 t .Fatal (err )
244245 }
246+ txTypePgStr := `SELECT tx_type FROM eth.transaction_cids WHERE cid = $1`
245247 switch c {
246248 case trx1CID .String ():
247249 test_helpers .ExpectEqual (t , data , tx1 )
248- var txType * uint8
249- pgStr = `SELECT tx_type FROM eth.transaction_cids WHERE cid = $1`
250- err = db .Get (context .Background (), & txType , pgStr , c )
250+ var txType uint8
251+ err = db .Get (context .Background (), & txType , txTypePgStr , c )
251252 if err != nil {
252253 t .Fatal (err )
253254 }
254- if txType != nil {
255- t .Fatalf ("expected nil tx_type , got %d" , * txType )
255+ if txType != 0 {
256+ t .Fatalf ("expected LegacyTxType (0) , got %d" , txType )
256257 }
257258 case trx2CID .String ():
258259 test_helpers .ExpectEqual (t , data , tx2 )
259- var txType * uint8
260- pgStr = `SELECT tx_type FROM eth.transaction_cids WHERE cid = $1`
261- err = db .Get (context .Background (), & txType , pgStr , c )
260+ var txType uint8
261+ err = db .Get (context .Background (), & txType , txTypePgStr , c )
262262 if err != nil {
263263 t .Fatal (err )
264264 }
265- if txType != nil {
266- t .Fatalf ("expected nil tx_type , got %d" , * txType )
265+ if txType != 0 {
266+ t .Fatalf ("expected LegacyTxType (0) , got %d" , txType )
267267 }
268268 case trx3CID .String ():
269269 test_helpers .ExpectEqual (t , data , tx3 )
270- var txType * uint8
271- pgStr = `SELECT tx_type FROM eth.transaction_cids WHERE cid = $1`
272- err = db .Get (context .Background (), & txType , pgStr , c )
270+ var txType uint8
271+ err = db .Get (context .Background (), & txType , txTypePgStr , c )
273272 if err != nil {
274273 t .Fatal (err )
275274 }
276- if txType != nil {
277- t .Fatalf ("expected nil tx_type , got %d" , * txType )
275+ if txType != 0 {
276+ t .Fatalf ("expected LegacyTxType (0) , got %d" , txType )
278277 }
279278 case trx4CID .String ():
280279 test_helpers .ExpectEqual (t , data , tx4 )
281- var txType * uint8
282- pgStr = `SELECT tx_type FROM eth.transaction_cids WHERE cid = $1`
283- err = db .Get (context .Background (), & txType , pgStr , c )
280+ var txType uint8
281+ err = db .Get (context .Background (), & txType , txTypePgStr , c )
284282 if err != nil {
285283 t .Fatal (err )
286284 }
287- if * txType != types .AccessListTxType {
288- t .Fatalf ("expected AccessListTxType (1), got %d" , * txType )
285+ if txType != types .AccessListTxType {
286+ t .Fatalf ("expected AccessListTxType (1), got %d" , txType )
289287 }
290288 accessListElementModels := make ([]models.AccessListElementModel , 0 )
291289 pgStr = `SELECT access_list_element.* FROM eth.access_list_element INNER JOIN eth.transaction_cids ON (tx_id = transaction_cids.id) WHERE cid = $1 ORDER BY access_list_element.index ASC`
@@ -310,8 +308,7 @@ func TestSQLXIndexer(t *testing.T) {
310308 case trx5CID .String ():
311309 test_helpers .ExpectEqual (t , data , tx5 )
312310 var txType * uint8
313- pgStr = `SELECT tx_type FROM eth.transaction_cids WHERE cid = $1`
314- err = db .Get (context .Background (), & txType , pgStr , c )
311+ err = db .Get (context .Background (), & txType , txTypePgStr , c )
315312 if err != nil {
316313 t .Fatal (err )
317314 }
@@ -423,7 +420,7 @@ func TestSQLXIndexer(t *testing.T) {
423420 if err != nil {
424421 t .Fatal (err )
425422 }
426-
423+ postStatePgStr := `SELECT post_state FROM eth.receipt_cids WHERE leaf_cid = $1`
427424 switch c {
428425 case rct1CID .String ():
429426 test_helpers .ExpectEqual (t , data , rct1 )
@@ -437,35 +434,31 @@ func TestSQLXIndexer(t *testing.T) {
437434 case rct2CID .String ():
438435 test_helpers .ExpectEqual (t , data , rct2 )
439436 var postState string
440- pgStr = `SELECT post_state FROM eth.receipt_cids WHERE leaf_cid = $1`
441- err = db .Get (context .Background (), & postState , pgStr , c )
437+ err = db .Get (context .Background (), & postState , postStatePgStr , c )
442438 if err != nil {
443439 t .Fatal (err )
444440 }
445441 test_helpers .ExpectEqual (t , postState , mocks .ExpectedPostState1 )
446442 case rct3CID .String ():
447443 test_helpers .ExpectEqual (t , data , rct3 )
448444 var postState string
449- pgStr = `SELECT post_state FROM eth.receipt_cids WHERE leaf_cid = $1`
450- err = db .Get (context .Background (), & postState , pgStr , c )
445+ err = db .Get (context .Background (), & postState , postStatePgStr , c )
451446 if err != nil {
452447 t .Fatal (err )
453448 }
454449 test_helpers .ExpectEqual (t , postState , mocks .ExpectedPostState2 )
455450 case rct4CID .String ():
456451 test_helpers .ExpectEqual (t , data , rct4 )
457452 var postState string
458- pgStr = `SELECT post_state FROM eth.receipt_cids WHERE leaf_cid = $1`
459- err = db .Get (context .Background (), & postState , pgStr , c )
453+ err = db .Get (context .Background (), & postState , postStatePgStr , c )
460454 if err != nil {
461455 t .Fatal (err )
462456 }
463457 test_helpers .ExpectEqual (t , postState , mocks .ExpectedPostState3 )
464458 case rct5CID .String ():
465459 test_helpers .ExpectEqual (t , data , rct5 )
466460 var postState string
467- pgStr = `SELECT post_state FROM eth.receipt_cids WHERE leaf_cid = $1`
468- err = db .Get (context .Background (), & postState , pgStr , c )
461+ err = db .Get (context .Background (), & postState , postStatePgStr , c )
469462 if err != nil {
470463 t .Fatal (err )
471464 }
0 commit comments