Commit 8cbf49a1 authored by Hamdi Allam's avatar Hamdi Allam

fighting with CI. I think i fixed the postgres connection issues

parent 1fd2a70a
......@@ -36,6 +36,7 @@ type E2ETestSuite struct {
}
func createE2ETestSuite(t *testing.T) E2ETestSuite {
dbUser := os.Getenv("DB_USER")
dbName := setupTestDatabase(t)
// Replace the handler of the global logger with the testlog
......@@ -54,6 +55,7 @@ func createE2ETestSuite(t *testing.T) E2ETestSuite {
Host: "127.0.0.1",
Port: 5432,
Name: dbName,
User: dbUser,
},
RPCs: config.RPCsConfig{
L1RPC: opSys.Nodes["l1"].HTTPEndpoint(),
......@@ -62,7 +64,7 @@ func createE2ETestSuite(t *testing.T) E2ETestSuite {
Logger: logger,
}
db, err := database.NewDB(fmt.Sprintf("database=%s", dbName))
db, err := database.NewDB(fmt.Sprintf("postgres://%s@localhost:5432/%s?sslmode=disable", dbUser, dbName))
require.NoError(t, err)
indexer, err := indexer.NewIndexer(indexerCfg)
require.NoError(t, err)
......
......@@ -25,7 +25,14 @@ type Indexer struct {
// NewIndexer initializes an instance of the Indexer
func NewIndexer(cfg config.Config) (*Indexer, error) {
dsn := fmt.Sprintf("database=%s", cfg.DB.Name)
dsn := fmt.Sprintf("host=%s port=%d dbname=%s sslmode=disable", cfg.DB.Host, cfg.DB.Port, cfg.DB.Name)
if cfg.DB.User != "" {
dsn += fmt.Sprintf(" user=%s", cfg.DB.User)
}
if cfg.DB.Password != "" {
dsn += fmt.Sprintf(" password=%s", cfg.DB.Password)
}
db, err := database.NewDB(dsn)
if err != nil {
return nil, err
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment