From 32205c0f8dbd94bec69a29d57f0766b739122883 Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Fri, 23 Jun 2023 19:00:07 +0800 Subject: [PATCH] clean up --- indexer/test_helpers/test_helpers.go | 56 ++++++++-------------------- 1 file changed, 16 insertions(+), 40 deletions(-) diff --git a/indexer/test_helpers/test_helpers.go b/indexer/test_helpers/test_helpers.go index 948e6de..1cb7b26 100644 --- a/indexer/test_helpers/test_helpers.go +++ b/indexer/test_helpers/test_helpers.go @@ -76,48 +76,24 @@ func TearDownDB(t *testing.T, db sql.Database) { t.Fatal(err) } - _, err = tx.Exec(ctx, `DELETE FROM eth.header_cids`) - if err != nil { - t.Fatal(err) + statements := []string{ + `TRUNCATE nodes`, + `TRUNCATE ipld.blocks`, + `TRUNCATE eth.header_cids`, + `TRUNCATE eth.uncle_cids`, + `TRUNCATE eth.transaction_cids`, + `TRUNCATE eth.receipt_cids`, + `TRUNCATE eth.state_cids`, + `TRUNCATE eth.storage_cids`, + `TRUNCATE eth.log_cids`, + `TRUNCATE eth_meta.watched_addresses`, } - _, err = tx.Exec(ctx, `DELETE FROM eth.uncle_cids`) - if err != nil { - t.Fatal(err) + for _, stm := range statements { + if _, err = tx.Exec(ctx, stm); err != nil { + t.Fatal(err) + } } - _, err = tx.Exec(ctx, `DELETE FROM eth.transaction_cids`) - if err != nil { - t.Fatal(err) - } - _, err = tx.Exec(ctx, `DELETE FROM eth.receipt_cids`) - if err != nil { - t.Fatal(err) - } - _, err = tx.Exec(ctx, `DELETE FROM eth.state_cids`) - if err != nil { - t.Fatal(err) - } - _, err = tx.Exec(ctx, `DELETE FROM eth.storage_cids`) - if err != nil { - t.Fatal(err) - } - _, err = tx.Exec(ctx, `DELETE FROM eth.log_cids`) - if err != nil { - t.Fatal(err) - } - _, err = tx.Exec(ctx, `DELETE FROM ipld.blocks`) - if err != nil { - t.Fatal(err) - } - _, err = tx.Exec(ctx, `DELETE FROM nodes`) - if err != nil { - t.Fatal(err) - } - _, err = tx.Exec(ctx, `DELETE FROM eth_meta.watched_addresses`) - if err != nil { - t.Fatal(err) - } - err = tx.Commit(ctx) - if err != nil { + if err = tx.Commit(ctx); err != nil { t.Fatal(err) } }