From 47bec50f4e668e3e884c0286a0322597c5240597 Mon Sep 17 00:00:00 2001 From: PJ Date: Tue, 27 Feb 2024 18:03:12 +0100 Subject: [PATCH] testing: fix unit tests --- bus/client/client_test.go | 3 +++ stores/hostdb_test.go | 7 +------ stores/sql.go | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/bus/client/client_test.go b/bus/client/client_test.go index 5fe063414..0146a0d63 100644 --- a/bus/client/client_test.go +++ b/bus/client/client_test.go @@ -69,6 +69,7 @@ func newTestClient(dir string) (*client.Client, func() error, func(context.Conte } // create bus + network, genesis := build.Network() b, cleanup, _, err := node.NewBus(node.BusConfig{ Bus: config.Bus{ AnnouncementMaxAgeHours: 24 * 7 * 52, // 1 year @@ -77,6 +78,8 @@ func newTestClient(dir string) (*client.Client, func() error, func(context.Conte UsedUTXOExpiry: time.Minute, SlabBufferCompletionThreshold: 0, }, + Network: network, + Genesis: genesis, SlabPruningInterval: time.Minute, SlabPruningCooldown: time.Minute, }, filepath.Join(dir, "bus"), types.GeneratePrivateKey(), zap.New(zapcore.NewNopCore())) diff --git a/stores/hostdb_test.go b/stores/hostdb_test.go index d389961fd..bb130d1af 100644 --- a/stores/hostdb_test.go +++ b/stores/hostdb_test.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "os" "reflect" "testing" "time" @@ -711,11 +710,7 @@ func TestSQLHostAllowlist(t *testing.T) { } func TestSQLHostBlocklist(t *testing.T) { - cfg := defaultTestSQLStoreConfig - cfg.persistent = true - cfg.dir = "/Users/peterjan/testing" - os.RemoveAll(cfg.dir) - ss := newTestSQLStore(t, cfg) + ss := newTestSQLStore(t, defaultTestSQLStoreConfig) defer ss.Close() ctx := context.Background() diff --git a/stores/sql.go b/stores/sql.go index b581138bc..926a8cb43 100644 --- a/stores/sql.go +++ b/stores/sql.go @@ -160,7 +160,7 @@ func NewSQLStore(cfg Config) (*SQLStore, error) { } if err := os.MkdirAll(cfg.PartialSlabDir, 0700); err != nil { - return nil, fmt.Errorf("failed to create partial slab dir: %v", err) + return nil, fmt.Errorf("failed to create partial slab dir '%s': %v", cfg.PartialSlabDir, err) } db, err := gorm.Open(cfg.Conn, &gorm.Config{ Logger: cfg.GormLogger, // custom logger