mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-30 15:40:59 +02:00
paymentsdb: use querypayments method to make test db agnostic
This commit is contained in:
@@ -2,11 +2,13 @@ package paymentsdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"math"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@@ -1372,9 +1374,21 @@ func assertPayments(t *testing.T, paymentDB *KVPaymentsDB,
|
|||||||
|
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
dbPayments, err := paymentDB.FetchPayments()
|
ctx := context.Background()
|
||||||
|
|
||||||
|
// We use the query method to fetch payments from the database which
|
||||||
|
// allows us to use this method db agnostic. We fetch all payments in
|
||||||
|
// one go.
|
||||||
|
queryResp, err := paymentDB.QueryPayments(ctx, Query{
|
||||||
|
IndexOffset: 0,
|
||||||
|
MaxPayments: math.MaxUint64,
|
||||||
|
Reversed: false,
|
||||||
|
IncludeIncomplete: true,
|
||||||
|
})
|
||||||
require.NoError(t, err, "could not fetch payments from db")
|
require.NoError(t, err, "could not fetch payments from db")
|
||||||
|
|
||||||
|
dbPayments := queryResp.Payments
|
||||||
|
|
||||||
// Make sure that the number of fetched payments is the same
|
// Make sure that the number of fetched payments is the same
|
||||||
// as expected.
|
// as expected.
|
||||||
require.Len(
|
require.Len(
|
||||||
|
Reference in New Issue
Block a user