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:
Abdul Rabbani
2022-04-20 18:12:44 -04:00
parent 827475f029
commit d7ad4108a7
11 changed files with 184 additions and 88 deletions
+1
View File
@@ -22,6 +22,7 @@ var DefaultConfig = Config{
DatabaseName: "vulcanize_testing",
Username: "vdbm",
Password: "password",
Driver: "PGX",
}
// ResolveDriverType resolves a DriverType from a provided string
+1 -1
View File
@@ -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")
}
+4 -2
View File
@@ -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 {