Updates post review

* remove StreamCodeAndCodeHash
* Makefile: local build target
* clean up comments & unused
This commit is contained in:
2023-07-14 13:16:39 +08:00
parent c96215f9be
commit c4f16290c7
30 changed files with 672 additions and 260 deletions
+8 -7
View File
@@ -31,8 +31,9 @@ import (
)
var (
pgConfig, _ = postgres.MakeConfig(postgres.TestConfig)
ctx = context.Background()
pgConfig, _ = postgres.TestConfig.WithEnv()
pgxConfig, _ = postgres.MakeConfig(pgConfig)
ctx = context.Background()
)
func expectContainsSubstring(t *testing.T, full string, sub string) {
@@ -43,9 +44,9 @@ func expectContainsSubstring(t *testing.T, full string, sub string) {
func TestPostgresPGX(t *testing.T) {
t.Run("connects to the sql", func(t *testing.T) {
dbPool, err := pgxpool.ConnectConfig(context.Background(), pgConfig)
dbPool, err := pgxpool.ConnectConfig(context.Background(), pgxConfig)
if err != nil {
t.Fatalf("failed to connect to db with connection string: %s err: %v", pgConfig.ConnString(), err)
t.Fatalf("failed to connect to db with connection string: %s err: %v", pgxConfig.ConnString(), err)
}
if dbPool == nil {
t.Fatal("DB pool is nil")
@@ -61,9 +62,9 @@ func TestPostgresPGX(t *testing.T) {
// sized int, so use string representation of big.Int
// and cast on insert
dbPool, err := pgxpool.ConnectConfig(context.Background(), pgConfig)
dbPool, err := pgxpool.ConnectConfig(context.Background(), pgxConfig)
if err != nil {
t.Fatalf("failed to connect to db with connection string: %s err: %v", pgConfig.ConnString(), err)
t.Fatalf("failed to connect to db with connection string: %s err: %v", pgxConfig.ConnString(), err)
}
defer dbPool.Close()
@@ -111,7 +112,7 @@ func TestPostgresPGX(t *testing.T) {
badHash := fmt.Sprintf("x %s", strings.Repeat("1", 100))
badInfo := node.Info{GenesisBlock: badHash, NetworkID: "1", ID: "x123", ClientName: "geth"}
_, err := postgres.NewPGXDriver(ctx, postgres.TestConfig, badInfo)
_, err := postgres.NewPGXDriver(ctx, pgConfig, badInfo)
if err == nil {
t.Fatal("Expected an error")
}
+3 -3
View File
@@ -35,7 +35,7 @@ func TestPostgresSQLX(t *testing.T) {
t.Run("connects to the database", func(t *testing.T) {
var err error
connStr := postgres.TestConfig.DbConnectionString()
connStr := pgConfig.DbConnectionString()
sqlxdb, err = sqlx.Connect("postgres", connStr)
if err != nil {
@@ -58,7 +58,7 @@ func TestPostgresSQLX(t *testing.T) {
// sized int, so use string representation of big.Int
// and cast on insert
connStr := postgres.TestConfig.DbConnectionString()
connStr := pgConfig.DbConnectionString()
db, err := sqlx.Connect("postgres", connStr)
if err != nil {
t.Fatal(err)
@@ -109,7 +109,7 @@ func TestPostgresSQLX(t *testing.T) {
badHash := fmt.Sprintf("x %s", strings.Repeat("1", 100))
badInfo := node.Info{GenesisBlock: badHash, NetworkID: "1", ID: "x123", ClientName: "geth"}
_, err := postgres.NewSQLXDriver(ctx, postgres.TestConfig, badInfo)
_, err := postgres.NewSQLXDriver(ctx, pgConfig, badInfo)
if err == nil {
t.Fatal("Expected an error")
}
@@ -25,7 +25,10 @@ import (
// SetupSQLXDB is used to setup a sqlx db for tests
func SetupSQLXDB() (sql.Database, error) {
conf := TestConfig
conf, err := TestConfig.WithEnv()
if err != nil {
return nil, err
}
conf.MaxIdle = 0
driver, err := NewSQLXDriver(context.Background(), conf, node.Info{})
if err != nil {