Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions config/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 0 additions & 3 deletions pkg/api/health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
}
}
Expand Down
17 changes: 0 additions & 17 deletions pkg/fetch/celestia_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 0 additions & 17 deletions pkg/metrics/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
41 changes: 0 additions & 41 deletions pkg/store/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package store
import (
"bytes"
"context"
"encoding/hex"
"io"
"sync"
"testing"
Expand Down Expand Up @@ -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)
}
}
12 changes: 0 additions & 12 deletions pkg/store/sqlite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
37 changes: 0 additions & 37 deletions pkg/sync/backfill_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}
})
}