@@ -66,17 +66,11 @@ func setupSQLX(t *testing.T) {
6666 test_helpers .ExpectEqual (t , tx .(* sql.BatchTx ).BlockNumber , mocks .BlockNumber .Uint64 ())
6767}
6868
69- func tearDown (t * testing.T ) {
70- sql .TearDownDB (t , db )
71- if err := ind .Close (); err != nil {
72- t .Fatal (err )
73- }
74- }
75-
7669func TestSQLXIndexer (t * testing.T ) {
7770 t .Run ("Publish and index header IPLDs in a single tx" , func (t * testing.T ) {
7871 setupSQLX (t )
7972 defer tearDown (t )
73+ defer checkTxClosure (t , 0 , 0 , 0 )
8074 pgStr := `SELECT cid, td, reward, block_hash, coinbase
8175 FROM eth.header_cids
8276 WHERE block_number = $1`
@@ -114,6 +108,7 @@ func TestSQLXIndexer(t *testing.T) {
114108 t .Run ("Publish and index transaction IPLDs in a single tx" , func (t * testing.T ) {
115109 setupSQLX (t )
116110 defer tearDown (t )
111+ defer checkTxClosure (t , 0 , 0 , 0 )
117112 // check that txs were properly indexed and published
118113 trxs := make ([]string , 0 )
119114 pgStr := `SELECT transaction_cids.cid FROM eth.transaction_cids INNER JOIN eth.header_cids ON (transaction_cids.header_id = header_cids.block_hash)
@@ -240,6 +235,7 @@ func TestSQLXIndexer(t *testing.T) {
240235 t .Run ("Publish and index log IPLDs for multiple receipt of a specific block" , func (t * testing.T ) {
241236 setupSQLX (t )
242237 defer tearDown (t )
238+ defer checkTxClosure (t , 0 , 0 , 0 )
243239
244240 rcts := make ([]string , 0 )
245241 rctsPgStr := `SELECT receipt_cids.leaf_cid FROM eth.receipt_cids, eth.transaction_cids, eth.header_cids
@@ -295,6 +291,7 @@ func TestSQLXIndexer(t *testing.T) {
295291 t .Run ("Publish and index receipt IPLDs in a single tx" , func (t * testing.T ) {
296292 setupSQLX (t )
297293 defer tearDown (t )
294+ defer checkTxClosure (t , 0 , 0 , 0 )
298295
299296 // check receipts were properly indexed and published
300297 rcts := make ([]string , 0 )
@@ -395,6 +392,7 @@ func TestSQLXIndexer(t *testing.T) {
395392 t .Run ("Publish and index state IPLDs in a single tx" , func (t * testing.T ) {
396393 setupSQLX (t )
397394 defer tearDown (t )
395+ defer checkTxClosure (t , 0 , 0 , 0 )
398396 // check that state nodes were properly indexed and published
399397 stateNodes := make ([]models.StateNodeModel , 0 )
400398 pgStr := `SELECT state_cids.cid, state_cids.state_leaf_key, state_cids.node_type, state_cids.state_path, state_cids.header_id
@@ -484,6 +482,7 @@ func TestSQLXIndexer(t *testing.T) {
484482 t .Run ("Publish and index storage IPLDs in a single tx" , func (t * testing.T ) {
485483 setupSQLX (t )
486484 defer tearDown (t )
485+ defer checkTxClosure (t , 0 , 0 , 0 )
487486 // check that storage nodes were properly indexed
488487 storageNodes := make ([]models.StorageNodeWithStateKeyModel , 0 )
489488 pgStr := `SELECT storage_cids.cid, state_cids.state_leaf_key, storage_cids.storage_leaf_key, storage_cids.node_type, storage_cids.storage_path
0 commit comments