use statediff indexer config; other nits

This commit is contained in:
2023-04-01 00:13:20 +08:00
parent 4695984e1d
commit 4a4ae2f2ea
4 changed files with 24 additions and 12 deletions
+16 -10
View File
@@ -16,22 +16,28 @@
package shared
import "github.com/jmoiron/sqlx"
import (
"github.com/jmoiron/sqlx"
/*
Hostname: "localhost",
Port: 8077,
DatabaseName: "cerc_testing",
Username: "vdbm",
Password: "password",
*/
"github.com/ethereum/go-ethereum/statediff/indexer/database/sql/postgres"
)
var (
testDBConfig, _ = postgres.Config{
Hostname: "localhost",
DatabaseName: "cerc_testing",
Username: "vdbm",
Password: "password",
Port: 8077,
Driver: "SQLX",
}.WithEnv()
)
// TestDB connect to the testing database
// it assumes the database has the IPFS ipld.blocks table present
// DO NOT use a production db for the test db, as it will remove all contents of the ipld.blocks table
func TestDB() (*sqlx.DB, error) {
connectStr := "postgresql://vdbm:password@localhost:8077/cerc_testing?sslmode=disable"
return sqlx.Connect("postgres", connectStr)
return sqlx.Connect("postgres", testDBConfig.DbConnectionString())
}
// ResetTestDB drops all rows in the test db ipld.blocks table