From fc90d260b1da59f3186a5cc612058b5dcfc04a0e Mon Sep 17 00:00:00 2001 From: tac0turtle Date: Tue, 24 Feb 2026 14:24:04 +0100 Subject: [PATCH] cleanup tests --- config/load_test.go | 27 ---------------------- pkg/api/health_test.go | 3 --- pkg/fetch/celestia_node_test.go | 17 -------------- pkg/metrics/metrics_test.go | 17 -------------- pkg/store/s3_test.go | 41 --------------------------------- pkg/store/sqlite_test.go | 12 ---------- pkg/sync/backfill_test.go | 37 ----------------------------- 7 files changed, 154 deletions(-) diff --git a/config/load_test.go b/config/load_test.go index 35a1099..11e965e 100644 --- a/config/load_test.go +++ b/config/load_test.go @@ -7,33 +7,6 @@ import ( "testing" ) -func TestDefaultConfigDefaults(t *testing.T) { - t.Parallel() - - cfg := DefaultConfig() - if cfg.Profiling.Enabled { - t.Fatal("profiling.enabled default = true, want false") - } - if cfg.Profiling.ListenAddr != "127.0.0.1:6061" { - t.Fatalf("profiling.listen_addr default = %q, want %q", cfg.Profiling.ListenAddr, "127.0.0.1:6061") - } - if cfg.Sync.BatchSize != 256 { - t.Fatalf("sync.batch_size default = %d, want %d", cfg.Sync.BatchSize, 256) - } - if cfg.Sync.Concurrency != 12 { - t.Fatalf("sync.concurrency default = %d, want %d", cfg.Sync.Concurrency, 12) - } - if cfg.RPC.ReadTimeout != 30 { - t.Fatalf("rpc.read_timeout default = %d, want 30", cfg.RPC.ReadTimeout) - } - if cfg.RPC.WriteTimeout != 30 { - t.Fatalf("rpc.write_timeout default = %d, want 30", cfg.RPC.WriteTimeout) - } - if cfg.Subscription.MaxSubscribers != 1024 { - t.Fatalf("subscription.max_subscribers default = %d, want 1024", cfg.Subscription.MaxSubscribers) - } -} - func TestLoadProfilingEnabledRequiresListenAddr(t *testing.T) { t.Parallel() diff --git a/pkg/api/health_test.go b/pkg/api/health_test.go index 4678bdb..ff52ce5 100644 --- a/pkg/api/health_test.go +++ b/pkg/api/health_test.go @@ -74,9 +74,6 @@ func TestHealthEndpoint(t *testing.T) { if hs.Healthy != tt.wantHealth { t.Errorf("healthy = %v, want %v", hs.Healthy, tt.wantHealth) } - if hs.SyncLag != 5 { - t.Errorf("sync_lag = %d, want 5", hs.SyncLag) - } }) } } diff --git a/pkg/fetch/celestia_node_test.go b/pkg/fetch/celestia_node_test.go index 1c2e7b0..376fa74 100644 --- a/pkg/fetch/celestia_node_test.go +++ b/pkg/fetch/celestia_node_test.go @@ -209,23 +209,6 @@ func TestGetBlobsRetriesTransient(t *testing.T) { } } -func TestNamespacesToBytes(t *testing.T) { - var ns1, ns2 types.Namespace - ns1[0] = 1 - ns2[0] = 2 - - out := namespacesToBytes([]types.Namespace{ns1, ns2}) - if len(out) != 2 { - t.Fatalf("got %d, want 2", len(out)) - } - if len(out[0]) != types.NamespaceSize { - t.Errorf("out[0] len = %d, want %d", len(out[0]), types.NamespaceSize) - } - if out[0][0] != 1 || out[1][0] != 2 { - t.Errorf("values mismatch: %v, %v", out[0], out[1]) - } -} - func TestJsonInt64(t *testing.T) { tests := []struct { input string diff --git a/pkg/metrics/metrics_test.go b/pkg/metrics/metrics_test.go index 5496b0b..7cca1ec 100644 --- a/pkg/metrics/metrics_test.go +++ b/pkg/metrics/metrics_test.go @@ -58,20 +58,3 @@ func TestPromRecorderRegisters(t *testing.T) { t.Error("apex_backfill_stage_errors_total metric not found") } } - -func TestNopRecorderDoesNotPanic(t *testing.T) { - r := Nop() - r.SetSyncState("streaming") - r.SetLatestHeight(100) - r.SetNetworkHeight(105) - r.IncBlobsProcessed(10) - r.IncHeadersProcessed(5) - r.ObserveBatchDuration(500 * time.Millisecond) - r.ObserveBackfillStageDuration("fetch_header", 3*time.Millisecond) - r.IncBackfillStageErrors("store_header") - r.IncAPIRequest("BlobGet", "ok") - r.ObserveAPIRequestDuration("BlobGet", 10*time.Millisecond) - r.ObserveStoreQueryDuration("GetBlobs", 2*time.Millisecond) - r.SetActiveSubscriptions(3) - r.IncEventsDropped() -} diff --git a/pkg/store/s3_test.go b/pkg/store/s3_test.go index ff7fe2c..8d64fd4 100644 --- a/pkg/store/s3_test.go +++ b/pkg/store/s3_test.go @@ -3,7 +3,6 @@ package store import ( "bytes" "context" - "encoding/hex" "io" "sync" "testing" @@ -513,43 +512,3 @@ func TestS3Store_BufferReadThrough(t *testing.T) { t.Errorf("blob data %q, want %q", gotB.Data, "buf") } } - -func TestS3Store_PrefixAndKeyFormat(t *testing.T) { - mock := newMockS3Client() - - // With prefix. - s := newS3Store(mock, "b", "myprefix", 64) - key := s.key("headers", chunkFileName(0)) - want := "myprefix/headers/chunk_0000000000000000.json" - if key != want { - t.Errorf("key with prefix = %q, want %q", key, want) - } - - // Without prefix. - s2 := newS3Store(mock, "b", "", 64) - key2 := s2.key("headers", chunkFileName(64)) - want2 := "headers/chunk_0000000000000064.json" - if key2 != want2 { - t.Errorf("key without prefix = %q, want %q", key2, want2) - } - - // Commitment index key. - commitHex := hex.EncodeToString([]byte("test")) - key3 := s.key("index", "commitments", commitHex+".json") - want3 := "myprefix/index/commitments/" + commitHex + ".json" - if key3 != want3 { - t.Errorf("commitment key = %q, want %q", key3, want3) - } -} - -func TestS3Store_EmptyPutBlobs(t *testing.T) { - ctx := context.Background() - s, _ := newTestS3Store(t) - - if err := s.PutBlobs(ctx, nil); err != nil { - t.Fatalf("PutBlobs nil: %v", err) - } - if err := s.PutBlobs(ctx, []types.Blob{}); err != nil { - t.Fatalf("PutBlobs empty: %v", err) - } -} diff --git a/pkg/store/sqlite_test.go b/pkg/store/sqlite_test.go index d57ebc6..5aa54f1 100644 --- a/pkg/store/sqlite_test.go +++ b/pkg/store/sqlite_test.go @@ -303,18 +303,6 @@ func TestMigrationsIdempotent(t *testing.T) { _ = s2.Close() } -func TestPutBlobsEmpty(t *testing.T) { - s := openTestDB(t) - ctx := context.Background() - - if err := s.PutBlobs(ctx, nil); err != nil { - t.Fatalf("PutBlobs(nil): %v", err) - } - if err := s.PutBlobs(ctx, []types.Blob{}); err != nil { - t.Fatalf("PutBlobs([]): %v", err) - } -} - func TestGetBlobsEmptyRange(t *testing.T) { s := openTestDB(t) ctx := context.Background() diff --git a/pkg/sync/backfill_test.go b/pkg/sync/backfill_test.go index 891ed78..033ba4f 100644 --- a/pkg/sync/backfill_test.go +++ b/pkg/sync/backfill_test.go @@ -42,21 +42,6 @@ func TestBackfiller(t *testing.T) { t.Errorf("header %d not stored: %v", h, err) } } - - st.mu.Lock() - blobCount := len(st.blobs) - st.mu.Unlock() - if blobCount != 10 { - t.Errorf("stored %d blobs, want 10", blobCount) - } - - ss, err := st.GetSyncState(context.Background()) - if err != nil { - t.Fatalf("GetSyncState: %v", err) - } - if ss.LatestHeight != 10 { - t.Errorf("checkpoint LatestHeight = %d, want 10", ss.LatestHeight) - } }) t.Run("ContextCancellation", func(t *testing.T) { @@ -104,26 +89,4 @@ func TestBackfiller(t *testing.T) { t.Fatal("expected error when fetcher returns not found") } }) - - t.Run("SingleHeight", func(t *testing.T) { - t.Parallel() - st := newMockStore() - ft := newMockFetcher(1) - ft.addHeader(makeHeader(1)) - - bf := &Backfiller{ - store: st, - fetcher: ft, - batchSize: 10, - concurrency: 4, - } - - if err := bf.Run(context.Background(), 1, 1); err != nil { - t.Fatalf("Run: %v", err) - } - - if _, err := st.GetHeader(context.Background(), 1); err != nil { - t.Errorf("header 1 not stored: %v", err) - } - }) }