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
2 changes: 1 addition & 1 deletion client/http/witness_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"strings"

"github.com/transparency-dev/witness/api"
"github.com/transparency-dev/witness/internal/witness"
"github.com/transparency-dev/witness/witness"
"k8s.io/klog/v2"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/feedwitness/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (

"github.com/prometheus/client_golang/prometheus/promhttp"
w_http "github.com/transparency-dev/witness/client/http"
"github.com/transparency-dev/witness/internal/witness"
"github.com/transparency-dev/witness/witness"
"github.com/transparency-dev/witness/monitoring"
"github.com/transparency-dev/witness/monitoring/prometheus"
"github.com/transparency-dev/witness/omniwitness"
Expand Down
2 changes: 1 addition & 1 deletion cmd/feedwitness/run_feeders.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/transparency-dev/witness/internal/feeder/serverless"
"github.com/transparency-dev/witness/internal/feeder/sumdb"
"github.com/transparency-dev/witness/internal/feeder/tiles"
"github.com/transparency-dev/witness/internal/witness"
"github.com/transparency-dev/witness/witness"
"github.com/transparency-dev/witness/monitoring"
"github.com/transparency-dev/witness/omniwitness"
"golang.org/x/mod/sumdb/note"
Expand Down
2 changes: 1 addition & 1 deletion cmd/feedwitness/run_feeders_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
sclient "github.com/transparency-dev/serverless-log/client"
"github.com/transparency-dev/serverless-log/testdata"
"github.com/transparency-dev/witness/internal/feeder"
"github.com/transparency-dev/witness/internal/witness"
"github.com/transparency-dev/witness/witness"
"github.com/transparency-dev/witness/monitoring"
"golang.org/x/mod/sumdb/note"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/loadtest/loadtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
"github.com/transparency-dev/merkle/proof"
"github.com/transparency-dev/merkle/rfc6962"
wit_client "github.com/transparency-dev/witness/client/http"
"github.com/transparency-dev/witness/internal/witness"
"github.com/transparency-dev/witness/witness"
"github.com/transparency-dev/witness/omniwitness"
"golang.org/x/mod/sumdb/note"
"gopkg.in/yaml.v3"
Expand Down
16 changes: 6 additions & 10 deletions cmd/omniwitness_gcp/persistence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"cloud.google.com/go/spanner"
"cloud.google.com/go/spanner/spannertest"
"github.com/transparency-dev/formats/log"
"github.com/transparency-dev/witness/internal/persistence"
ptest "github.com/transparency-dev/witness/internal/persistence/testonly"
"github.com/transparency-dev/witness/omniwitness"
"golang.org/x/sync/errgroup"
Expand All @@ -48,9 +47,9 @@ func newSpannerServer(t *testing.T) (string, func()) {
return id, srv.Close
}

func mustNewPersistence(t *testing.T) func() (persistence.LogStatePersistence, func() error) {
func mustNewPersistence(t *testing.T) func() (*spannerPersistence, func() error) {
t.Helper()
return func() (persistence.LogStatePersistence, func() error) {
return func() (*spannerPersistence, func() error) {
spanner, spannerShutdown := newSpannerServer(t)
p, clientShutdown, err := newSpannerPersistence(t.Context(), spanner)
if err != nil {
Expand Down Expand Up @@ -110,17 +109,16 @@ func TestUpdateConcurrent(t *testing.T) {
}

func TestDisableLog(t *testing.T) {
p, shutdown := mustNewPersistence(t)()
sp, shutdown := mustNewPersistence(t)()
defer func() {
if err := shutdown(); err != nil {
t.Errorf("shutdown: %v", err)
}
}()
if err := p.Init(t.Context()); err != nil {
if err := sp.Init(t.Context()); err != nil {
t.Fatalf("Init(): %v", err)
}

sp := p.(*spannerPersistence)
sp.batchWrite = testBatchWrite

if err := sp.AddLogs(t.Context(),
Expand Down Expand Up @@ -161,13 +159,13 @@ func TestDisableLog(t *testing.T) {
}

func TestDisabledLogStaysDisabled(t *testing.T) {
p, shutdown := mustNewPersistence(t)()
sp, shutdown := mustNewPersistence(t)()
defer func() {
if err := shutdown(); err != nil {
t.Errorf("shutdown: %v", err)
}
}()
if err := p.Init(t.Context()); err != nil {
if err := sp.Init(t.Context()); err != nil {
t.Fatalf("Init(): %v", err)
}

Expand All @@ -178,8 +176,6 @@ func TestDisabledLogStaysDisabled(t *testing.T) {
},
}

sp := p.(*spannerPersistence)

if err := sp.AddLogs(t.Context(), logs); err != nil {
t.Fatalf("Failed to AddLogs: %v", err)
}
Expand Down
3 changes: 1 addition & 2 deletions internal/persistence/inmemory/inmemory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ import (
"strings"
"testing"

"github.com/transparency-dev/witness/internal/persistence"
ptest "github.com/transparency-dev/witness/internal/persistence/testonly"
"golang.org/x/sync/errgroup"
)

var nopClose = func() error { return nil }

func TestUpdate(t *testing.T) {
ptest.TestUpdate(t, func() (persistence.LogStatePersistence, func() error) {
ptest.TestUpdate(t, func() (*inMemoryPersistence, func() error) {
return NewPersistence(), nopClose
})
}
Expand Down
2 changes: 1 addition & 1 deletion internal/persistence/sql/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/mattn/go-sqlite3"
"github.com/transparency-dev/formats/log"
"github.com/transparency-dev/formats/note"
"github.com/transparency-dev/witness/internal/witness"
"github.com/transparency-dev/witness/witness"
"github.com/transparency-dev/witness/omniwitness"
"k8s.io/klog/v2"
)
Expand Down
5 changes: 2 additions & 3 deletions internal/persistence/sql/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ import (

_ "github.com/mattn/go-sqlite3" // Load drivers for sqlite3
"github.com/transparency-dev/formats/log"
"github.com/transparency-dev/witness/internal/persistence"
ptest "github.com/transparency-dev/witness/internal/persistence/testonly"
"github.com/transparency-dev/witness/omniwitness"
ptest "github.com/transparency-dev/witness/internal/persistence/testonly"
)

func TestUpdate(t *testing.T) {
ptest.TestUpdate(t, func() (persistence.LogStatePersistence, func() error) {
ptest.TestUpdate(t, func() (*sqlLogPersistence, func() error) {
db, close := mustCreateDB(t)
return NewPersistence(db), close
})
Expand Down
7 changes: 3 additions & 4 deletions internal/persistence/testonly/persistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ import (
"fmt"
"testing"

"github.com/transparency-dev/witness/internal/persistence"
"github.com/transparency-dev/witness/internal/witness"
"github.com/transparency-dev/witness/witness"
)

// TestUpdate exposes a test that can be invoked by tests for specific implementations of persistence.
func TestUpdate(t *testing.T, lspFactory func() (persistence.LogStatePersistence, func() error)) {
func TestUpdate[T witness.LogStatePersistence](t *testing.T, lspFactory func() (T, func() error)) {
t.Helper()
origin := "foo"

Expand Down Expand Up @@ -69,7 +68,7 @@ func TestUpdate(t *testing.T, lspFactory func() (persistence.LogStatePersistence
}
}

func checkAndSet(ctx context.Context, lsp persistence.LogStatePersistence, origin string, expect []byte, write []byte) error {
func checkAndSet(ctx context.Context, lsp witness.LogStatePersistence, origin string, expect []byte, write []byte) error {
if err := lsp.Update(ctx, origin, func(current []byte) ([]byte, error) {
if !bytes.Equal(current, expect) {
return nil, fmt.Errorf("got current %x, want %x", current, expect)
Expand Down
61 changes: 0 additions & 61 deletions internal/witness/proof.go

This file was deleted.

92 changes: 0 additions & 92 deletions internal/witness/proof_test.go

This file was deleted.

Loading
Loading