Files
lnd/payments/db/test_harness.go
T
ziggie 080fd78fb4 paymentsdb: introduce a harness interface
The design of the sql and kv db are a bit different. A harness
interface is introduced which allows us to unit most of the test
and keep the backend specific tests at a minimum.
2026-02-25 08:02:17 +01:00

27 lines
942 B
Go

package paymentsdb
import (
"testing"
"github.com/lightningnetwork/lnd/lntypes"
)
// TestHarness provides implementation-specific test utilities for the payments
// database. Different database backends (KV, SQL) have different internal
// structures and indexing mechanisms, so this interface allows tests to verify
// implementation-specific behavior without coupling the test logic to a
// particular backend.
type TestHarness interface {
// AssertPaymentIndex checks that a payment is correctly indexed.
// For KV: verifies the payment index bucket entry exists and points
// to the correct payment hash.
// For SQL: no-op (SQL doesn't use a separate index bucket).
AssertPaymentIndex(t *testing.T, expectedHash lntypes.Hash)
// AssertNoIndex checks that an index for a sequence number doesn't
// exist.
// For KV: verifies the index bucket entry is deleted.
// For SQL: no-op.
AssertNoIndex(t *testing.T, seqNr uint64)
}