Code clean up + Beacon Chain Connection
This concludes all the code needed to connect to the DB and beacon node. We will no longer reference the lighthouse client because this application should work interchangeably with any beacon node. I have also standardized logging.
This commit is contained in:
@@ -22,6 +22,7 @@ var DefaultConfig = Config{
|
||||
DatabaseName: "vulcanize_testing",
|
||||
Username: "vdbm",
|
||||
Password: "password",
|
||||
Driver: "PGX",
|
||||
}
|
||||
|
||||
// ResolveDriverType resolves a DriverType from a provided string
|
||||
|
||||
@@ -38,7 +38,7 @@ func createDriver(c Config) (*pgxDriver, error) {
|
||||
log.Info("Successfully created a driver for PGX")
|
||||
return driver, nil
|
||||
default:
|
||||
log.Fatal("Couldnt find a driver to create for: ", c.Driver)
|
||||
log.Error("Couldnt find a driver to create for: ", c.Driver)
|
||||
return nil, fmt.Errorf("Can't find a driver to create")
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,9 @@ func TestPostgresPGX(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("throws error when can't connect to the database", func(t *testing.T) {
|
||||
_, err := NewPostgresDB(Config{}, "PGX")
|
||||
_, err := NewPostgresDB(Config{
|
||||
Driver: "PGX",
|
||||
})
|
||||
if err == nil {
|
||||
t.Fatal("Expected an error")
|
||||
}
|
||||
@@ -87,7 +89,7 @@ func TestPostgresPGX(t *testing.T) {
|
||||
expectContainsSubstring(t, err.Error(), sql.DbConnectionFailedMsg)
|
||||
})
|
||||
t.Run("Connect to the database", func(t *testing.T) {
|
||||
driver, err := NewPostgresDB(DefaultConfig, "pgx")
|
||||
driver, err := NewPostgresDB(DefaultConfig)
|
||||
defer driver.Close()
|
||||
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user