mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-26 05:32:17 +02:00
multi: rename KVPaymentDB to KVStore
This matches the same naming as used in the graph package.
This commit is contained in:
@@ -1225,7 +1225,7 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
|
|||||||
cfg.KeepFailedPaymentAttempts,
|
cfg.KeepFailedPaymentAttempts,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
kvPaymentsDB, err := paymentsdb.NewKVPaymentsDB(
|
kvPaymentsDB, err := paymentsdb.NewKVStore(
|
||||||
dbs.ChanStateDB,
|
dbs.ChanStateDB,
|
||||||
paymentsDBOptions...,
|
paymentsDBOptions...,
|
||||||
)
|
)
|
||||||
|
@@ -118,8 +118,8 @@ var (
|
|||||||
paymentsIndexBucket = []byte("payments-index-bucket")
|
paymentsIndexBucket = []byte("payments-index-bucket")
|
||||||
)
|
)
|
||||||
|
|
||||||
// KVPaymentsDB implements persistence for payments and payment attempts.
|
// KVStore implements persistence for payments and payment attempts.
|
||||||
type KVPaymentsDB struct {
|
type KVStore struct {
|
||||||
// Sequence management for the kv store.
|
// Sequence management for the kv store.
|
||||||
seqMu sync.Mutex
|
seqMu sync.Mutex
|
||||||
currSeq uint64
|
currSeq uint64
|
||||||
@@ -140,9 +140,9 @@ func defaultKVStoreOptions() *StoreOptions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewKVPaymentsDB creates a new KVStore for payments.
|
// NewKVStore creates a new KVStore for payments.
|
||||||
func NewKVPaymentsDB(db kvdb.Backend,
|
func NewKVStore(db kvdb.Backend,
|
||||||
options ...OptionModifier) (*KVPaymentsDB, error) {
|
options ...OptionModifier) (*KVStore, error) {
|
||||||
|
|
||||||
opts := defaultKVStoreOptions()
|
opts := defaultKVStoreOptions()
|
||||||
for _, applyOption := range options {
|
for _, applyOption := range options {
|
||||||
@@ -155,7 +155,7 @@ func NewKVPaymentsDB(db kvdb.Backend,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &KVPaymentsDB{
|
return &KVStore{
|
||||||
db: db,
|
db: db,
|
||||||
keepFailedPaymentAttempts: opts.KeepFailedPaymentAttempts,
|
keepFailedPaymentAttempts: opts.KeepFailedPaymentAttempts,
|
||||||
}, nil
|
}, nil
|
||||||
@@ -190,7 +190,7 @@ func initKVStore(db kvdb.Backend) error {
|
|||||||
// making sure it does not already exist as an in-flight payment. When this
|
// making sure it does not already exist as an in-flight payment. When this
|
||||||
// method returns successfully, the payment is guaranteed to be in the InFlight
|
// method returns successfully, the payment is guaranteed to be in the InFlight
|
||||||
// state.
|
// state.
|
||||||
func (p *KVPaymentsDB) InitPayment(paymentHash lntypes.Hash,
|
func (p *KVStore) InitPayment(paymentHash lntypes.Hash,
|
||||||
info *PaymentCreationInfo) error {
|
info *PaymentCreationInfo) error {
|
||||||
|
|
||||||
// Obtain a new sequence number for this payment. This is used
|
// Obtain a new sequence number for this payment. This is used
|
||||||
@@ -293,8 +293,8 @@ func (p *KVPaymentsDB) InitPayment(paymentHash lntypes.Hash,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DeleteFailedAttempts deletes all failed htlcs for a payment if configured
|
// DeleteFailedAttempts deletes all failed htlcs for a payment if configured
|
||||||
// by the KVPaymentsDB db.
|
// by the KVStore db.
|
||||||
func (p *KVPaymentsDB) DeleteFailedAttempts(hash lntypes.Hash) error {
|
func (p *KVStore) DeleteFailedAttempts(hash lntypes.Hash) error {
|
||||||
if !p.keepFailedPaymentAttempts {
|
if !p.keepFailedPaymentAttempts {
|
||||||
const failedHtlcsOnly = true
|
const failedHtlcsOnly = true
|
||||||
err := p.DeletePayment(hash, failedHtlcsOnly)
|
err := p.DeletePayment(hash, failedHtlcsOnly)
|
||||||
@@ -361,7 +361,7 @@ func deserializePaymentIndex(r io.Reader) (lntypes.Hash, error) {
|
|||||||
|
|
||||||
// RegisterAttempt atomically records the provided HTLCAttemptInfo to the
|
// RegisterAttempt atomically records the provided HTLCAttemptInfo to the
|
||||||
// DB.
|
// DB.
|
||||||
func (p *KVPaymentsDB) RegisterAttempt(paymentHash lntypes.Hash,
|
func (p *KVStore) RegisterAttempt(paymentHash lntypes.Hash,
|
||||||
attempt *HTLCAttemptInfo) (*MPPayment, error) {
|
attempt *HTLCAttemptInfo) (*MPPayment, error) {
|
||||||
|
|
||||||
// Serialize the information before opening the db transaction.
|
// Serialize the information before opening the db transaction.
|
||||||
@@ -511,7 +511,7 @@ func (p *KVPaymentsDB) RegisterAttempt(paymentHash lntypes.Hash,
|
|||||||
// After invoking this method, InitPayment should always return an error to
|
// After invoking this method, InitPayment should always return an error to
|
||||||
// prevent us from making duplicate payments to the same payment hash. The
|
// prevent us from making duplicate payments to the same payment hash. The
|
||||||
// provided preimage is atomically saved to the DB for record keeping.
|
// provided preimage is atomically saved to the DB for record keeping.
|
||||||
func (p *KVPaymentsDB) SettleAttempt(hash lntypes.Hash,
|
func (p *KVStore) SettleAttempt(hash lntypes.Hash,
|
||||||
attemptID uint64, settleInfo *HTLCSettleInfo) (*MPPayment, error) {
|
attemptID uint64, settleInfo *HTLCSettleInfo) (*MPPayment, error) {
|
||||||
|
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
@@ -524,7 +524,7 @@ func (p *KVPaymentsDB) SettleAttempt(hash lntypes.Hash,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FailAttempt marks the given payment attempt failed.
|
// FailAttempt marks the given payment attempt failed.
|
||||||
func (p *KVPaymentsDB) FailAttempt(hash lntypes.Hash,
|
func (p *KVStore) FailAttempt(hash lntypes.Hash,
|
||||||
attemptID uint64, failInfo *HTLCFailInfo) (*MPPayment, error) {
|
attemptID uint64, failInfo *HTLCFailInfo) (*MPPayment, error) {
|
||||||
|
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
@@ -537,7 +537,7 @@ func (p *KVPaymentsDB) FailAttempt(hash lntypes.Hash,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// updateHtlcKey updates a database key for the specified htlc.
|
// updateHtlcKey updates a database key for the specified htlc.
|
||||||
func (p *KVPaymentsDB) updateHtlcKey(paymentHash lntypes.Hash,
|
func (p *KVStore) updateHtlcKey(paymentHash lntypes.Hash,
|
||||||
attemptID uint64, key, value []byte) (*MPPayment, error) {
|
attemptID uint64, key, value []byte) (*MPPayment, error) {
|
||||||
|
|
||||||
aid := make([]byte, 8)
|
aid := make([]byte, 8)
|
||||||
@@ -609,7 +609,7 @@ func (p *KVPaymentsDB) updateHtlcKey(paymentHash lntypes.Hash,
|
|||||||
// payment failed. After invoking this method, InitPayment should return nil on
|
// payment failed. After invoking this method, InitPayment should return nil on
|
||||||
// its next call for this payment hash, allowing the switch to make a
|
// its next call for this payment hash, allowing the switch to make a
|
||||||
// subsequent payment.
|
// subsequent payment.
|
||||||
func (p *KVPaymentsDB) Fail(paymentHash lntypes.Hash,
|
func (p *KVStore) Fail(paymentHash lntypes.Hash,
|
||||||
reason FailureReason) (*MPPayment, error) {
|
reason FailureReason) (*MPPayment, error) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -633,7 +633,7 @@ func (p *KVPaymentsDB) Fail(paymentHash lntypes.Hash,
|
|||||||
|
|
||||||
// We mark the payment as failed as long as it is known. This
|
// We mark the payment as failed as long as it is known. This
|
||||||
// lets the last attempt to fail with a terminal write its
|
// lets the last attempt to fail with a terminal write its
|
||||||
// failure to the KVPaymentsDB without synchronizing with
|
// failure to the KVStore without synchronizing with
|
||||||
// other attempts.
|
// other attempts.
|
||||||
_, err = fetchPaymentStatus(bucket)
|
_, err = fetchPaymentStatus(bucket)
|
||||||
if errors.Is(err, ErrPaymentNotInitiated) {
|
if errors.Is(err, ErrPaymentNotInitiated) {
|
||||||
@@ -666,7 +666,7 @@ func (p *KVPaymentsDB) Fail(paymentHash lntypes.Hash,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FetchPayment returns information about a payment from the database.
|
// FetchPayment returns information about a payment from the database.
|
||||||
func (p *KVPaymentsDB) FetchPayment(paymentHash lntypes.Hash) (
|
func (p *KVStore) FetchPayment(paymentHash lntypes.Hash) (
|
||||||
*MPPayment, error) {
|
*MPPayment, error) {
|
||||||
|
|
||||||
var payment *MPPayment
|
var payment *MPPayment
|
||||||
@@ -761,7 +761,7 @@ func fetchPaymentBucketUpdate(tx kvdb.RwTx, paymentHash lntypes.Hash) (
|
|||||||
|
|
||||||
// nextPaymentSequence returns the next sequence number to store for a new
|
// nextPaymentSequence returns the next sequence number to store for a new
|
||||||
// payment.
|
// payment.
|
||||||
func (p *KVPaymentsDB) nextPaymentSequence() ([]byte, error) {
|
func (p *KVStore) nextPaymentSequence() ([]byte, error) {
|
||||||
p.seqMu.Lock()
|
p.seqMu.Lock()
|
||||||
defer p.seqMu.Unlock()
|
defer p.seqMu.Unlock()
|
||||||
|
|
||||||
@@ -822,7 +822,7 @@ func fetchPaymentStatus(bucket kvdb.RBucket) (PaymentStatus, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FetchInFlightPayments returns all payments with status InFlight.
|
// FetchInFlightPayments returns all payments with status InFlight.
|
||||||
func (p *KVPaymentsDB) FetchInFlightPayments() ([]*MPPayment, error) {
|
func (p *KVStore) FetchInFlightPayments() ([]*MPPayment, error) {
|
||||||
var (
|
var (
|
||||||
inFlights []*MPPayment
|
inFlights []*MPPayment
|
||||||
start = time.Now()
|
start = time.Now()
|
||||||
@@ -895,7 +895,7 @@ func htlcBucketKey(prefix, id []byte) []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FetchPayments returns all sent payments found in the DB.
|
// FetchPayments returns all sent payments found in the DB.
|
||||||
func (p *KVPaymentsDB) FetchPayments() ([]*MPPayment, error) {
|
func (p *KVStore) FetchPayments() ([]*MPPayment, error) {
|
||||||
var payments []*MPPayment
|
var payments []*MPPayment
|
||||||
|
|
||||||
err := kvdb.View(p.db, func(tx kvdb.RTx) error {
|
err := kvdb.View(p.db, func(tx kvdb.RTx) error {
|
||||||
@@ -1135,7 +1135,7 @@ func fetchFailedHtlcKeys(bucket kvdb.RBucket) ([][]byte, error) {
|
|||||||
// QueryPayments is a query to the payments database which is restricted
|
// QueryPayments is a query to the payments database which is restricted
|
||||||
// to a subset of payments by the payments query, containing an offset
|
// to a subset of payments by the payments query, containing an offset
|
||||||
// index and a maximum number of returned payments.
|
// index and a maximum number of returned payments.
|
||||||
func (p *KVPaymentsDB) QueryPayments(_ context.Context,
|
func (p *KVStore) QueryPayments(_ context.Context,
|
||||||
query Query) (Response, error) {
|
query Query) (Response, error) {
|
||||||
|
|
||||||
var resp Response
|
var resp Response
|
||||||
@@ -1356,7 +1356,7 @@ func fetchPaymentWithSequenceNumber(tx kvdb.RTx, paymentHash lntypes.Hash,
|
|||||||
// DeletePayment deletes a payment from the DB given its payment hash. If
|
// DeletePayment deletes a payment from the DB given its payment hash. If
|
||||||
// failedHtlcsOnly is set, only failed HTLC attempts of the payment will be
|
// failedHtlcsOnly is set, only failed HTLC attempts of the payment will be
|
||||||
// deleted.
|
// deleted.
|
||||||
func (p *KVPaymentsDB) DeletePayment(paymentHash lntypes.Hash,
|
func (p *KVStore) DeletePayment(paymentHash lntypes.Hash,
|
||||||
failedHtlcsOnly bool) error {
|
failedHtlcsOnly bool) error {
|
||||||
|
|
||||||
return kvdb.Update(p.db, func(tx kvdb.RwTx) error {
|
return kvdb.Update(p.db, func(tx kvdb.RwTx) error {
|
||||||
@@ -1453,7 +1453,7 @@ func (p *KVPaymentsDB) DeletePayment(paymentHash lntypes.Hash,
|
|||||||
// failedHtlcsOnly is set, the payment itself won't be deleted, only failed HTLC
|
// failedHtlcsOnly is set, the payment itself won't be deleted, only failed HTLC
|
||||||
// attempts. The method returns the number of deleted payments, which is always
|
// attempts. The method returns the number of deleted payments, which is always
|
||||||
// 0 if failedHtlcsOnly is set.
|
// 0 if failedHtlcsOnly is set.
|
||||||
func (p *KVPaymentsDB) DeletePayments(failedOnly,
|
func (p *KVStore) DeletePayments(failedOnly,
|
||||||
failedHtlcsOnly bool) (int, error) {
|
failedHtlcsOnly bool) (int, error) {
|
||||||
|
|
||||||
var numPayments int
|
var numPayments int
|
||||||
|
@@ -18,9 +18,9 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestKVPaymentsDBDeleteNonInFlight checks that calling DeletePayments only
|
// TestKVStoreDeleteNonInFlight checks that calling DeletePayments only
|
||||||
// deletes payments from the database that are not in-flight.
|
// deletes payments from the database that are not in-flight.
|
||||||
func TestKVPaymentsDBDeleteNonInFlight(t *testing.T) {
|
func TestKVStoreDeleteNonInFlight(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
paymentDB := NewKVTestDB(t)
|
paymentDB := NewKVTestDB(t)
|
||||||
@@ -249,7 +249,7 @@ type htlcStatus struct {
|
|||||||
|
|
||||||
// fetchPaymentIndexEntry gets the payment hash for the sequence number provided
|
// fetchPaymentIndexEntry gets the payment hash for the sequence number provided
|
||||||
// from our payment indexes bucket.
|
// from our payment indexes bucket.
|
||||||
func fetchPaymentIndexEntry(_ *testing.T, p *KVPaymentsDB,
|
func fetchPaymentIndexEntry(_ *testing.T, p *KVStore,
|
||||||
sequenceNumber uint64) (*lntypes.Hash, error) {
|
sequenceNumber uint64) (*lntypes.Hash, error) {
|
||||||
|
|
||||||
var hash lntypes.Hash
|
var hash lntypes.Hash
|
||||||
@@ -287,7 +287,7 @@ func assertPaymentIndex(t *testing.T, p DB, expectedHash lntypes.Hash) {
|
|||||||
// Only the kv implementation uses the index so we exit early if the
|
// Only the kv implementation uses the index so we exit early if the
|
||||||
// payment db is not a kv implementation. This helps us to reuse the
|
// payment db is not a kv implementation. This helps us to reuse the
|
||||||
// same test for both implementations.
|
// same test for both implementations.
|
||||||
kvPaymentDB, ok := p.(*KVPaymentsDB)
|
kvPaymentDB, ok := p.(*KVStore)
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -307,7 +307,7 @@ func assertPaymentIndex(t *testing.T, p DB, expectedHash lntypes.Hash) {
|
|||||||
func assertNoIndex(t *testing.T, p DB, seqNr uint64) {
|
func assertNoIndex(t *testing.T, p DB, seqNr uint64) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
kvPaymentDB, ok := p.(*KVPaymentsDB)
|
kvPaymentDB, ok := p.(*KVStore)
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -929,7 +929,7 @@ func TestQueryPayments(t *testing.T) {
|
|||||||
paymentDB := NewKVTestDB(t)
|
paymentDB := NewKVTestDB(t)
|
||||||
|
|
||||||
// Initialize the payment database.
|
// Initialize the payment database.
|
||||||
paymentDB, err := NewKVPaymentsDB(paymentDB.db)
|
paymentDB, err := NewKVStore(paymentDB.db)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Make a preliminary query to make sure it's ok to
|
// Make a preliminary query to make sure it's ok to
|
||||||
|
@@ -16,16 +16,16 @@ func NewTestDB(t *testing.T, opts ...OptionModifier) DB {
|
|||||||
|
|
||||||
t.Cleanup(backendCleanup)
|
t.Cleanup(backendCleanup)
|
||||||
|
|
||||||
paymentDB, err := NewKVPaymentsDB(backend, opts...)
|
paymentDB, err := NewKVStore(backend, opts...)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
return paymentDB
|
return paymentDB
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewKVTestDB is a helper function that creates an BBolt database for testing
|
// NewKVTestDB is a helper function that creates an BBolt database for testing
|
||||||
// and there is no need to convert the interface to the KVPaymentsDB because for
|
// and there is no need to convert the interface to the KVStore because for
|
||||||
// some unit tests we still need access to the kvdb interface.
|
// some unit tests we still need access to the kvdb interface.
|
||||||
func NewKVTestDB(t *testing.T, opts ...OptionModifier) *KVPaymentsDB {
|
func NewKVTestDB(t *testing.T, opts ...OptionModifier) *KVStore {
|
||||||
backend, backendCleanup, err := kvdb.GetTestBackend(
|
backend, backendCleanup, err := kvdb.GetTestBackend(
|
||||||
t.TempDir(), "kvPaymentDB",
|
t.TempDir(), "kvPaymentDB",
|
||||||
)
|
)
|
||||||
@@ -33,7 +33,7 @@ func NewKVTestDB(t *testing.T, opts ...OptionModifier) *KVPaymentsDB {
|
|||||||
|
|
||||||
t.Cleanup(backendCleanup)
|
t.Cleanup(backendCleanup)
|
||||||
|
|
||||||
paymentDB, err := NewKVPaymentsDB(backend, opts...)
|
paymentDB, err := NewKVStore(backend, opts...)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
return paymentDB
|
return paymentDB
|
||||||
|
@@ -50,7 +50,7 @@ func TestControlTowerSubscribeUnknown(t *testing.T) {
|
|||||||
|
|
||||||
db := initDB(t)
|
db := initDB(t)
|
||||||
|
|
||||||
paymentDB, err := paymentsdb.NewKVPaymentsDB(
|
paymentDB, err := paymentsdb.NewKVStore(
|
||||||
db,
|
db,
|
||||||
paymentsdb.WithKeepFailedPaymentAttempts(true),
|
paymentsdb.WithKeepFailedPaymentAttempts(true),
|
||||||
)
|
)
|
||||||
@@ -70,7 +70,7 @@ func TestControlTowerSubscribeSuccess(t *testing.T) {
|
|||||||
|
|
||||||
db := initDB(t)
|
db := initDB(t)
|
||||||
|
|
||||||
paymentDB, err := paymentsdb.NewKVPaymentsDB(db)
|
paymentDB, err := paymentsdb.NewKVStore(db)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
pControl := NewControlTower(paymentDB)
|
pControl := NewControlTower(paymentDB)
|
||||||
@@ -174,33 +174,33 @@ func TestControlTowerSubscribeSuccess(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestKVPaymentsDBSubscribeFail tests that payment updates for a
|
// TestKVStoreSubscribeFail tests that payment updates for a
|
||||||
// failed payment are properly sent to subscribers.
|
// failed payment are properly sent to subscribers.
|
||||||
func TestKVPaymentsDBSubscribeFail(t *testing.T) {
|
func TestKVStoreSubscribeFail(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
t.Run("register attempt, keep failed payments", func(t *testing.T) {
|
t.Run("register attempt, keep failed payments", func(t *testing.T) {
|
||||||
testKVPaymentsDBSubscribeFail(t, true, true)
|
testKVStoreSubscribeFail(t, true, true)
|
||||||
})
|
})
|
||||||
t.Run("register attempt, delete failed payments", func(t *testing.T) {
|
t.Run("register attempt, delete failed payments", func(t *testing.T) {
|
||||||
testKVPaymentsDBSubscribeFail(t, true, false)
|
testKVStoreSubscribeFail(t, true, false)
|
||||||
})
|
})
|
||||||
t.Run("no register attempt, keep failed payments", func(t *testing.T) {
|
t.Run("no register attempt, keep failed payments", func(t *testing.T) {
|
||||||
testKVPaymentsDBSubscribeFail(t, false, true)
|
testKVStoreSubscribeFail(t, false, true)
|
||||||
})
|
})
|
||||||
t.Run("no register attempt, delete failed payments", func(t *testing.T) {
|
t.Run("no register attempt, delete failed payments", func(t *testing.T) {
|
||||||
testKVPaymentsDBSubscribeFail(t, false, false)
|
testKVStoreSubscribeFail(t, false, false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestKVPaymentsDBSubscribeAllSuccess tests that multiple payments are
|
// TestKVStoreSubscribeAllSuccess tests that multiple payments are
|
||||||
// properly sent to subscribers of TrackPayments.
|
// properly sent to subscribers of TrackPayments.
|
||||||
func TestKVPaymentsDBSubscribeAllSuccess(t *testing.T) {
|
func TestKVStoreSubscribeAllSuccess(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
db := initDB(t)
|
db := initDB(t)
|
||||||
|
|
||||||
paymentDB, err := paymentsdb.NewKVPaymentsDB(
|
paymentDB, err := paymentsdb.NewKVStore(
|
||||||
db,
|
db,
|
||||||
paymentsdb.WithKeepFailedPaymentAttempts(true),
|
paymentsdb.WithKeepFailedPaymentAttempts(true),
|
||||||
)
|
)
|
||||||
@@ -318,14 +318,14 @@ func TestKVPaymentsDBSubscribeAllSuccess(t *testing.T) {
|
|||||||
require.Equal(t, attempt2.Route, htlc2.Route, "unexpected htlc route.")
|
require.Equal(t, attempt2.Route, htlc2.Route, "unexpected htlc route.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestKVPaymentsDBSubscribeAllImmediate tests whether already inflight
|
// TestKVStoreSubscribeAllImmediate tests whether already inflight
|
||||||
// payments are reported at the start of the SubscribeAllPayments subscription.
|
// payments are reported at the start of the SubscribeAllPayments subscription.
|
||||||
func TestKVPaymentsDBSubscribeAllImmediate(t *testing.T) {
|
func TestKVStoreSubscribeAllImmediate(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
db := initDB(t)
|
db := initDB(t)
|
||||||
|
|
||||||
paymentDB, err := paymentsdb.NewKVPaymentsDB(
|
paymentDB, err := paymentsdb.NewKVStore(
|
||||||
db,
|
db,
|
||||||
paymentsdb.WithKeepFailedPaymentAttempts(true),
|
paymentsdb.WithKeepFailedPaymentAttempts(true),
|
||||||
)
|
)
|
||||||
@@ -367,14 +367,14 @@ func TestKVPaymentsDBSubscribeAllImmediate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestKVPaymentsDBUnsubscribeSuccess tests that when unsubscribed, there are
|
// TestKVStoreUnsubscribeSuccess tests that when unsubscribed, there are
|
||||||
// no more notifications to that specific subscription.
|
// no more notifications to that specific subscription.
|
||||||
func TestKVPaymentsDBUnsubscribeSuccess(t *testing.T) {
|
func TestKVStoreUnsubscribeSuccess(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
db := initDB(t)
|
db := initDB(t)
|
||||||
|
|
||||||
paymentDB, err := paymentsdb.NewKVPaymentsDB(
|
paymentDB, err := paymentsdb.NewKVStore(
|
||||||
db,
|
db,
|
||||||
paymentsdb.WithKeepFailedPaymentAttempts(true),
|
paymentsdb.WithKeepFailedPaymentAttempts(true),
|
||||||
)
|
)
|
||||||
@@ -444,12 +444,12 @@ func TestKVPaymentsDBUnsubscribeSuccess(t *testing.T) {
|
|||||||
require.Len(t, subscription2.Updates(), 0)
|
require.Len(t, subscription2.Updates(), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testKVPaymentsDBSubscribeFail(t *testing.T, registerAttempt,
|
func testKVStoreSubscribeFail(t *testing.T, registerAttempt,
|
||||||
keepFailedPaymentAttempts bool) {
|
keepFailedPaymentAttempts bool) {
|
||||||
|
|
||||||
db := initDB(t)
|
db := initDB(t)
|
||||||
|
|
||||||
paymentDB, err := paymentsdb.NewKVPaymentsDB(
|
paymentDB, err := paymentsdb.NewKVStore(
|
||||||
db,
|
db,
|
||||||
paymentsdb.WithKeepFailedPaymentAttempts(
|
paymentsdb.WithKeepFailedPaymentAttempts(
|
||||||
keepFailedPaymentAttempts,
|
keepFailedPaymentAttempts,
|
||||||
|
Reference in New Issue
Block a user