Handle conflicts (#244) * Handle conflicts * Update go mod file versions * Make lint changes Disassociate block number from the indexer object Update ipld-eth-db ref Refactor builder code to make it reusable Use prefix comparison for account selective statediffing Update builder unit tests Add mode to write to CSV files in statediff file writer (#249) * Change file writing mode to csv files * Implement writer interface for file indexer * Implement option for csv or sql in file mode * Close files in CSV writer * Add tests for CSV file mode * Implement CSV file for watched addresses * Separate test configs for CSV and SQL * Refactor common code for file indexer tests Update indexer to include block hash in receipts and logs (#256) * Update indexer to include block hash in receipts and logs * Upgrade ipld-eth-db image in docker-compose to run tests Use watched addresses from direct indexing params by default while serving statediff APIs (#262) * Use watched addresses from direct indexing params in statediff APIs by default * Avoid using indexer object when direct indexing is off * Add nil check before accessing watched addresses from direct indexing params
69 lines
1.3 KiB
Go
69 lines
1.3 KiB
Go
package file
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/jmoiron/sqlx"
|
|
)
|
|
|
|
// TearDownDB is used to tear down the watcher dbs after tests
|
|
func TearDownDB(t *testing.T, db *sqlx.DB) {
|
|
tx, err := db.Begin()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
_, err = tx.Exec(`DELETE FROM eth.header_cids`)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
_, err = tx.Exec(`DELETE FROM eth.uncle_cids`)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
_, err = tx.Exec(`DELETE FROM eth.transaction_cids`)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
_, err = tx.Exec(`DELETE FROM eth.receipt_cids`)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
_, err = tx.Exec(`DELETE FROM eth.state_cids`)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
_, err = tx.Exec(`DELETE FROM eth.storage_cids`)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
_, err = tx.Exec(`DELETE FROM eth.state_accounts`)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
_, err = tx.Exec(`DELETE FROM eth.access_list_elements`)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
_, err = tx.Exec(`DELETE FROM eth.log_cids`)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
_, err = tx.Exec(`DELETE FROM blocks`)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
_, err = tx.Exec(`DELETE FROM nodes`)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
_, err = tx.Exec(`DELETE FROM eth_meta.watched_addresses`)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
err = tx.Commit()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|