Merge pull request #10167 from starius/go124

multi: bump Go to 1.24.6
This commit is contained in:
Yong authored and GitHub committed 2025-09-01 20:03:54 +08:00
commit 84b2c20ea0
102 files changed
+461 -488

No files matched your search

+2 -2
View File
@@ -52,8 +52,8 @@ runs:
# The key is used to create and later look up the cache. It's made of # The key is used to create and later look up the cache. It's made of
# four parts: # four parts:
# - The base part is made from the OS name, Go version and a # - The base part is made from the OS name, Go version and a
# job-specified key prefix. Example: `linux-go-1.23.12-unit-test-`. # job-specified key prefix. Example: `linux-go-1.24.6-unit-test-`.
# It ensures that a job running on Linux with Go 1.23 only looks for # It ensures that a job running on Linux with Go 1.24 only looks for
# caches from the same environment. # caches from the same environment.
# - The unique part is the `hashFiles('**/go.sum')`, which calculates a # - The unique part is the `hashFiles('**/go.sum')`, which calculates a
# hash (a fingerprint) of the go.sum file. # hash (a fingerprint) of the go.sum file.
+1 -1
View File
@@ -40,7 +40,7 @@ env:
# If you change this please also update GO_VERSION in Makefile (then run # If you change this please also update GO_VERSION in Makefile (then run
# `make lint` to see where else it needs to be updated as well). # `make lint` to see where else it needs to be updated as well).
GO_VERSION: 1.23.12 GO_VERSION: 1.24.6
jobs: jobs:
static-checks: static-checks:
+1 -1
View File
@@ -12,7 +12,7 @@ defaults:
env: env:
# If you change this please also update GO_VERSION in Makefile (then run # If you change this please also update GO_VERSION in Makefile (then run
# `make lint` to see where else it needs to be updated as well). # `make lint` to see where else it needs to be updated as well).
GO_VERSION: 1.23.12 GO_VERSION: 1.24.6
jobs: jobs:
######################## ########################
+1 -1
View File
@@ -1,7 +1,7 @@
run: run:
# If you change this please also update GO_VERSION in Makefile (then run # If you change this please also update GO_VERSION in Makefile (then run
# `make lint` to see where else it needs to be updated as well). # `make lint` to see where else it needs to be updated as well).
go: "1.23.12" go: "1.24.6"
# Abort after 10 minutes. # Abort after 10 minutes.
timeout: 10m timeout: 10m
+1 -1
View File
@@ -1,6 +1,6 @@
# If you change this please also update GO_VERSION in Makefile (then run # If you change this please also update GO_VERSION in Makefile (then run
# `make lint` to see where else it needs to be updated as well). # `make lint` to see where else it needs to be updated as well).
FROM golang:1.23.12-alpine as builder FROM golang:1.24.6-alpine as builder
# Force Go to use the cgo based DNS resolver. This is required to ensure DNS # Force Go to use the cgo based DNS resolver. This is required to ensure DNS
# queries required to connect to linked containers succeed. # queries required to connect to linked containers succeed.
+1 -1
View File
@@ -28,7 +28,7 @@ ACTIVE_GO_VERSION_MINOR := $(shell echo $(ACTIVE_GO_VERSION) | cut -d. -f2)
# GO_VERSION is the Go version used for the release build, docker files, and # GO_VERSION is the Go version used for the release build, docker files, and
# GitHub Actions. This is the reference version for the project. All other Go # GitHub Actions. This is the reference version for the project. All other Go
# versions are checked against this version. # versions are checked against this version.
GO_VERSION = 1.23.12 GO_VERSION = 1.24.6
GOBUILD := $(GOCC) build -v GOBUILD := $(GOCC) build -v
GOINSTALL := $(GOCC) install -v GOINSTALL := $(GOCC) install -v
+2 -3
View File
@@ -1,7 +1,6 @@
package lnd package lnd
import ( import (
"context"
"testing" "testing"
"github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2"
@@ -490,7 +489,7 @@ func TestAssignPeerPermsBypassExisting(t *testing.T) {
func TestHasPeer(t *testing.T) { func TestHasPeer(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// Create a testing accessMan. // Create a testing accessMan.
a := &accessMan{ a := &accessMan{
@@ -708,7 +707,7 @@ func TestAddPeerAccessOutbound(t *testing.T) {
// accessman's internal state based on the peer's status. // accessman's internal state based on the peer's status.
func TestRemovePeerAccess(t *testing.T) { func TestRemovePeerAccess(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// Create a testing accessMan. // Create a testing accessMan.
a := &accessMan{ a := &accessMan{
+2 -3
View File
@@ -1,7 +1,6 @@
package autopilot package autopilot
import ( import (
"context"
"fmt" "fmt"
"testing" "testing"
@@ -32,7 +31,7 @@ func TestBetweennessCentralityMetricConstruction(t *testing.T) {
// Tests that empty graph results in empty centrality result. // Tests that empty graph results in empty centrality result.
func TestBetweennessCentralityEmptyGraph(t *testing.T) { func TestBetweennessCentralityEmptyGraph(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
centralityMetric, err := NewBetweennessCentralityMetric(1) centralityMetric, err := NewBetweennessCentralityMetric(1)
require.NoError( require.NoError(
@@ -64,7 +63,7 @@ func TestBetweennessCentralityEmptyGraph(t *testing.T) {
// Test betweenness centrality calculating using an example graph. // Test betweenness centrality calculating using an example graph.
func TestBetweennessCentralityWithNonEmptyGraph(t *testing.T) { func TestBetweennessCentralityWithNonEmptyGraph(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
workers := []int{1, 3, 9, 100} workers := []int{1, 3, 9, 100}
+1 -2
View File
@@ -1,7 +1,6 @@
package autopilot_test package autopilot_test
import ( import (
"context"
"testing" "testing"
"github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2"
@@ -23,7 +22,7 @@ func randKey() (*btcec.PublicKey, error) {
// ExternalScoreAttachment correctly reflects the scores we set last. // ExternalScoreAttachment correctly reflects the scores we set last.
func TestSetNodeScores(t *testing.T) { func TestSetNodeScores(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
const name = "externalscore" const name = "externalscore"
+4 -4
View File
@@ -76,7 +76,7 @@ var chanGraphs = []struct {
// empty graph, the NodeSores function always returns a score of 0. // empty graph, the NodeSores function always returns a score of 0.
func TestPrefAttachmentSelectEmptyGraph(t *testing.T) { func TestPrefAttachmentSelectEmptyGraph(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
prefAttach := NewPrefAttachment() prefAttach := NewPrefAttachment()
// Create a random public key, which we will query to get a score for. // Create a random public key, which we will query to get a score for.
@@ -116,7 +116,7 @@ func TestPrefAttachmentSelectEmptyGraph(t *testing.T) {
// and the funds are appropriately allocated across each peer. // and the funds are appropriately allocated across each peer.
func TestPrefAttachmentSelectTwoVertexes(t *testing.T) { func TestPrefAttachmentSelectTwoVertexes(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
prand.Seed(time.Now().Unix()) prand.Seed(time.Now().Unix())
@@ -203,7 +203,7 @@ func TestPrefAttachmentSelectTwoVertexes(t *testing.T) {
// allocate all funds to each vertex (up to the max channel size). // allocate all funds to each vertex (up to the max channel size).
func TestPrefAttachmentSelectGreedyAllocation(t *testing.T) { func TestPrefAttachmentSelectGreedyAllocation(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
prand.Seed(time.Now().Unix()) prand.Seed(time.Now().Unix())
@@ -316,7 +316,7 @@ func TestPrefAttachmentSelectGreedyAllocation(t *testing.T) {
// of zero during scoring. // of zero during scoring.
func TestPrefAttachmentSelectSkipNodes(t *testing.T) { func TestPrefAttachmentSelectSkipNodes(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
prand.Seed(time.Now().Unix()) prand.Seed(time.Now().Unix())
+1 -2
View File
@@ -1,7 +1,6 @@
package autopilot package autopilot
import ( import (
"context"
"testing" "testing"
"github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2"
@@ -59,7 +58,7 @@ func testTopCentrality(t *testing.T, graph testGraph,
// Attempt to get centrality scores and expect // Attempt to get centrality scores and expect
// that the result equals with the expected set. // that the result equals with the expected set.
scores, err := topCentrality.NodeScores( scores, err := topCentrality.NodeScores(
context.Background(), graph, channels, chanSize, nodes, t.Context(), graph, channels, chanSize, nodes,
) )
require.NoError(t, err) require.NoError(t, err)
+4 -5
View File
@@ -1,7 +1,6 @@
package batch package batch
import ( import (
"context"
"database/sql" "database/sql"
"encoding/binary" "encoding/binary"
"errors" "errors"
@@ -31,7 +30,7 @@ var batchTestIntervals = []time.Duration{
// TestRetry tests the retry logic of the batch scheduler. // TestRetry tests the retry logic of the batch scheduler.
func TestRetry(t *testing.T) { func TestRetry(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
dbDir := t.TempDir() dbDir := t.TempDir()
@@ -99,7 +98,7 @@ func TestRetry(t *testing.T) {
// and then continue to add a write transaction to the same batch. // and then continue to add a write transaction to the same batch.
func TestReadOnly(t *testing.T) { func TestReadOnly(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
t.Run("bbolt-ReadWrite", func(t *testing.T) { t.Run("bbolt-ReadWrite", func(t *testing.T) {
db, err := walletdb.Create( db, err := walletdb.Create(
@@ -455,7 +454,7 @@ func BenchmarkBoltBatching(b *testing.B) {
// batchTest benches the performance of the batch scheduler configured // batchTest benches the performance of the batch scheduler configured
// with/without the LazyAdd option and with the given commit interval. // with/without the LazyAdd option and with the given commit interval.
batchTest := func(b *testing.B, lazy bool, interval time.Duration) { batchTest := func(b *testing.B, lazy bool, interval time.Duration) {
ctx := context.Background() ctx := b.Context()
db := setUpDB(b) db := setUpDB(b)
@@ -549,7 +548,7 @@ func benchmarkSQLBatching(b *testing.B, sqlite bool) {
) )
} }
ctx := context.Background() ctx := b.Context()
opts := sqldb.WriteTxOpt() opts := sqldb.WriteTxOpt()
// writeRecord is a helper that adds a single new invoice to the // writeRecord is a helper that adds a single new invoice to the
+1 -1
View File
@@ -548,7 +548,7 @@ func (r *RPCAcceptor) validateAcceptorResponse(dustLimit btcutil.Amount,
// If we reject the channel, and have a custom error, then we use it. // If we reject the channel, and have a custom error, then we use it.
case haveCustomError: case haveCustomError:
return false, fmt.Errorf(req.Error), nil, nil return false, fmt.Errorf("%s", req.Error), nil, nil
// Otherwise, we have rejected the channel with no custom error, so we // Otherwise, we have rejected the channel with no custom error, so we
// just use a generic error to fail the channel. // just use a generic error to fail the channel.
+2 -3
View File
@@ -121,8 +121,7 @@ func TestFetchBackupForChan(t *testing.T) {
} }
for i, testCase := range testCases { for i, testCase := range testCases {
_, err := FetchBackupForChan( _, err := FetchBackupForChan(
context.Background(), testCase.chanPoint, chanSource, t.Context(), testCase.chanPoint, chanSource, chanSource,
chanSource,
) )
switch { switch {
// If this is a valid test case, and we failed, then we'll // If this is a valid test case, and we failed, then we'll
@@ -143,7 +142,7 @@ func TestFetchBackupForChan(t *testing.T) {
// channel source for all channels and construct a Single for each channel. // channel source for all channels and construct a Single for each channel.
func TestFetchStaticChanBackups(t *testing.T) { func TestFetchStaticChanBackups(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// First, we'll make the set of channels that we want to seed the // First, we'll make the set of channels that we want to seed the
// channel source with. Both channels will be fully populated in the // channel source with. Both channels will be fully populated in the
+3 -4
View File
@@ -81,7 +81,7 @@ func (m *mockChannelNotifier) SubscribeChans(_ context.Context,
// channel subscription, then the entire sub-swapper will fail to start. // channel subscription, then the entire sub-swapper will fail to start.
func TestNewSubSwapperSubscribeFail(t *testing.T) { func TestNewSubSwapperSubscribeFail(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
keyRing := &lnencrypt.MockKeyRing{} keyRing := &lnencrypt.MockKeyRing{}
@@ -159,7 +159,7 @@ func TestSubSwapperIdempotentStartStop(t *testing.T) {
swapper := newMockSwapper(keyRing) swapper := newMockSwapper(keyRing)
subSwapper, err := NewSubSwapper( subSwapper, err := NewSubSwapper(
context.Background(), nil, &chanNotifier, keyRing, swapper, t.Context(), nil, &chanNotifier, keyRing, swapper,
) )
require.NoError(t, err, "unable to init subSwapper") require.NoError(t, err, "unable to init subSwapper")
@@ -226,8 +226,7 @@ func TestSubSwapperUpdater(t *testing.T) {
// With our channel set created, we'll make a fresh sub swapper // With our channel set created, we'll make a fresh sub swapper
// instance to begin our test. // instance to begin our test.
subSwapper, err := NewSubSwapper( subSwapper, err := NewSubSwapper(
context.Background(), initialChanSet, chanNotifier, keyRing, t.Context(), initialChanSet, chanNotifier, keyRing, swapper,
swapper,
) )
require.NoError(t, err, "unable to make swapper") require.NoError(t, err, "unable to make swapper")
if err := subSwapper.Start(); err != nil { if err := subSwapper.Start(); err != nil {
+1 -1
View File
@@ -20,7 +20,7 @@ var (
// deduplicates the results of a set of AddrSource implementations. // deduplicates the results of a set of AddrSource implementations.
func TestMultiAddrSource(t *testing.T) { func TestMultiAddrSource(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
var pk1 = newTestPubKey(t) var pk1 = newTestPubKey(t)
+1 -2
View File
@@ -1,7 +1,6 @@
package channeldb package channeldb
import ( import (
"context"
"image/color" "image/color"
"math" "math"
"math/rand" "math/rand"
@@ -181,7 +180,7 @@ func TestFetchClosedChannelForID(t *testing.T) {
// channel db and graph db. // channel db and graph db.
func TestMultiSourceAddrsForNode(t *testing.T) { func TestMultiSourceAddrsForNode(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
fullDB, err := MakeTestDB(t) fullDB, err := MakeTestDB(t)
require.NoError(t, err, "unable to make test database") require.NoError(t, err, "unable to make test database")
@@ -76,7 +76,8 @@ func decodeBech32(bech string) (string, []byte, error) {
moreInfo = fmt.Sprintf("Expected %v, got %v.", moreInfo = fmt.Sprintf("Expected %v, got %v.",
expected, checksum) expected, checksum)
} }
return "", nil, fmt.Errorf("checksum failed. " + moreInfo)
return "", nil, fmt.Errorf("checksum failed. %s", moreInfo)
} }
// We exclude the last 6 bytes, which is the checksum. // We exclude the last 6 bytes, which is the checksum.
+2 -2
View File
@@ -46,7 +46,7 @@ func TestEtcdElector(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
t.Cleanup(cleanup) t.Cleanup(cleanup)
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(t.Context())
defer cancel() defer cancel()
const ( const (
@@ -70,7 +70,7 @@ func TestEtcdElector(t *testing.T) {
ch := make(chan *etcdLeaderElector) ch := make(chan *etcdLeaderElector)
wg.Add(2) wg.Add(2)
ctxb := context.Background() ctxb := t.Context()
go func() { go func() {
defer wg.Done() defer wg.Done()
+1 -1
View File
@@ -2070,7 +2070,7 @@ func assertBrarCleanup(t *testing.T, brar *BreachArbitrator,
}, 5*time.Second) }, 5*time.Second)
if err != nil { if err != nil {
t.Fatalf(err.Error()) t.Fatal(err)
} }
} }
+1 -1
View File
@@ -173,7 +173,7 @@ func TestChainWatcherRemoteUnilateralClosePendingCommit(t *testing.T) {
// With the HTLC added, we'll now manually initiate a state transition // With the HTLC added, we'll now manually initiate a state transition
// from Alice to Bob. // from Alice to Bob.
testQuit, testQuitFunc := context.WithCancel(context.Background()) testQuit, testQuitFunc := context.WithCancel(t.Context())
t.Cleanup(testQuitFunc) t.Cleanup(testQuitFunc)
_, err = aliceChannel.SignNextCommitment(testQuit) _, err = aliceChannel.SignNextCommitment(testQuit)
require.NoError(t, err) require.NoError(t, err)
+1 -1
View File
@@ -1,6 +1,6 @@
# If you change this please also update GO_VERSION in Makefile (then run # If you change this please also update GO_VERSION in Makefile (then run
# `make lint` to see where else it needs to be updated as well). # `make lint` to see where else it needs to be updated as well).
FROM golang:1.23.12-alpine AS builder FROM golang:1.24.6-alpine AS builder
LABEL maintainer="Olaoluwa Osuntokun <laolu@lightning.engineering>" LABEL maintainer="Olaoluwa Osuntokun <laolu@lightning.engineering>"
+27 -27
View File
@@ -1024,7 +1024,7 @@ func createTestCtx(t *testing.T, startHeight uint32, isChanPeer bool) (
// the router subsystem. // the router subsystem.
func TestProcessAnnouncement(t *testing.T) { func TestProcessAnnouncement(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
timestamp := testTimestamp timestamp := testTimestamp
tCtx, err := createTestCtx(t, 0, false) tCtx, err := createTestCtx(t, 0, false)
@@ -1140,7 +1140,7 @@ func TestProcessAnnouncement(t *testing.T) {
// propagated to the router subsystem. // propagated to the router subsystem.
func TestPrematureAnnouncement(t *testing.T) { func TestPrematureAnnouncement(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
timestamp := testTimestamp timestamp := testTimestamp
@@ -1176,7 +1176,7 @@ func TestPrematureAnnouncement(t *testing.T) {
// properly processes partial and fully announcement signatures message. // properly processes partial and fully announcement signatures message.
func TestSignatureAnnouncementLocalFirst(t *testing.T) { func TestSignatureAnnouncementLocalFirst(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
tCtx, err := createTestCtx(t, proofMatureDelta, false) tCtx, err := createTestCtx(t, proofMatureDelta, false)
require.NoError(t, err, "can't create context") require.NoError(t, err, "can't create context")
@@ -1355,7 +1355,7 @@ func TestSignatureAnnouncementLocalFirst(t *testing.T) {
// processes announcement with unknown channel ids. // processes announcement with unknown channel ids.
func TestOrphanSignatureAnnouncement(t *testing.T) { func TestOrphanSignatureAnnouncement(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
tCtx, err := createTestCtx(t, proofMatureDelta, false) tCtx, err := createTestCtx(t, proofMatureDelta, false)
require.NoError(t, err, "can't create context") require.NoError(t, err, "can't create context")
@@ -1547,7 +1547,7 @@ func TestOrphanSignatureAnnouncement(t *testing.T) {
// assembled. // assembled.
func TestSignatureAnnouncementRetryAtStartup(t *testing.T) { func TestSignatureAnnouncementRetryAtStartup(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
tCtx, err := createTestCtx(t, proofMatureDelta, false) tCtx, err := createTestCtx(t, proofMatureDelta, false)
require.NoError(t, err, "can't create context") require.NoError(t, err, "can't create context")
@@ -1783,7 +1783,7 @@ out:
// the full proof (ChannelAnnouncement) to the remote peer. // the full proof (ChannelAnnouncement) to the remote peer.
func TestSignatureAnnouncementFullProofWhenRemoteProof(t *testing.T) { func TestSignatureAnnouncementFullProofWhenRemoteProof(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
tCtx, err := createTestCtx(t, proofMatureDelta, false) tCtx, err := createTestCtx(t, proofMatureDelta, false)
require.NoError(t, err, "can't create context") require.NoError(t, err, "can't create context")
@@ -2225,7 +2225,7 @@ func TestDeDuplicatedAnnouncements(t *testing.T) {
// announcements for nodes who do not intend to publicly advertise themselves. // announcements for nodes who do not intend to publicly advertise themselves.
func TestForwardPrivateNodeAnnouncement(t *testing.T) { func TestForwardPrivateNodeAnnouncement(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
const ( const (
startingHeight = 100 startingHeight = 100
@@ -2334,7 +2334,7 @@ func TestForwardPrivateNodeAnnouncement(t *testing.T) {
// zombie edges. // zombie edges.
func TestRejectZombieEdge(t *testing.T) { func TestRejectZombieEdge(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// We'll start by creating our test context with a batch of // We'll start by creating our test context with a batch of
// announcements. // announcements.
@@ -2436,7 +2436,7 @@ func TestRejectZombieEdge(t *testing.T) {
// becomes live by receiving a fresh update. // becomes live by receiving a fresh update.
func TestProcessZombieEdgeNowLive(t *testing.T) { func TestProcessZombieEdgeNowLive(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// We'll start by creating our test context with a batch of // We'll start by creating our test context with a batch of
// announcements. // announcements.
@@ -2594,7 +2594,7 @@ func TestProcessZombieEdgeNowLive(t *testing.T) {
// be reprocessed later, after our ChannelAnnouncement. // be reprocessed later, after our ChannelAnnouncement.
func TestReceiveRemoteChannelUpdateFirst(t *testing.T) { func TestReceiveRemoteChannelUpdateFirst(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
tCtx, err := createTestCtx(t, proofMatureDelta, false) tCtx, err := createTestCtx(t, proofMatureDelta, false)
require.NoError(t, err, "can't create context") require.NoError(t, err, "can't create context")
@@ -2798,7 +2798,7 @@ func TestReceiveRemoteChannelUpdateFirst(t *testing.T) {
// currently know of. // currently know of.
func TestExtraDataChannelAnnouncementValidation(t *testing.T) { func TestExtraDataChannelAnnouncementValidation(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
tCtx, err := createTestCtx(t, 0, false) tCtx, err := createTestCtx(t, 0, false)
require.NoError(t, err, "can't create context") require.NoError(t, err, "can't create context")
@@ -2835,7 +2835,7 @@ func TestExtraDataChannelAnnouncementValidation(t *testing.T) {
// know of. // know of.
func TestExtraDataChannelUpdateValidation(t *testing.T) { func TestExtraDataChannelUpdateValidation(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
timestamp := testTimestamp timestamp := testTimestamp
tCtx, err := createTestCtx(t, 0, false) tCtx, err := createTestCtx(t, 0, false)
@@ -2896,7 +2896,7 @@ func TestExtraDataChannelUpdateValidation(t *testing.T) {
// currently know of. // currently know of.
func TestExtraDataNodeAnnouncementValidation(t *testing.T) { func TestExtraDataNodeAnnouncementValidation(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
tCtx, err := createTestCtx(t, 0, false) tCtx, err := createTestCtx(t, 0, false)
require.NoError(t, err, "can't create context") require.NoError(t, err, "can't create context")
@@ -2969,7 +2969,7 @@ func assertProcessAnnouncement(t *testing.T, result chan error) {
// the retransmit ticker ticks. // the retransmit ticker ticks.
func TestRetransmit(t *testing.T) { func TestRetransmit(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
tCtx, err := createTestCtx(t, proofMatureDelta, false) tCtx, err := createTestCtx(t, proofMatureDelta, false)
require.NoError(t, err, "can't create context") require.NoError(t, err, "can't create context")
@@ -3079,7 +3079,7 @@ func TestRetransmit(t *testing.T) {
// no existing channels in the graph do not get forwarded. // no existing channels in the graph do not get forwarded.
func TestNodeAnnouncementNoChannels(t *testing.T) { func TestNodeAnnouncementNoChannels(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
tCtx, err := createTestCtx(t, 0, false) tCtx, err := createTestCtx(t, 0, false)
require.NoError(t, err, "can't create context") require.NoError(t, err, "can't create context")
@@ -3171,7 +3171,7 @@ func TestNodeAnnouncementNoChannels(t *testing.T) {
// validate the msg flags and max HTLC field of a ChannelUpdate. // validate the msg flags and max HTLC field of a ChannelUpdate.
func TestOptionalFieldsChannelUpdateValidation(t *testing.T) { func TestOptionalFieldsChannelUpdateValidation(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
tCtx, err := createTestCtx(t, 0, false) tCtx, err := createTestCtx(t, 0, false)
require.NoError(t, err, "can't create context") require.NoError(t, err, "can't create context")
@@ -3269,7 +3269,7 @@ func TestOptionalFieldsChannelUpdateValidation(t *testing.T) {
// channel is always sent upon the remote party reconnecting. // channel is always sent upon the remote party reconnecting.
func TestSendChannelUpdateReliably(t *testing.T) { func TestSendChannelUpdateReliably(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// We'll start by creating our test context and a batch of // We'll start by creating our test context and a batch of
// announcements. // announcements.
@@ -3587,7 +3587,7 @@ func sendRemoteMsg(t *testing.T, ctx *testCtx, msg lnwire.Message,
select { select {
case err := <-ctx.gossiper.ProcessRemoteAnnouncement( case err := <-ctx.gossiper.ProcessRemoteAnnouncement(
context.Background(), msg, remotePeer, t.Context(), msg, remotePeer,
): ):
if err != nil { if err != nil {
t.Fatalf("unable to process channel msg: %v", err) t.Fatalf("unable to process channel msg: %v", err)
@@ -3718,7 +3718,7 @@ out:
// policy of all of them. // policy of all of them.
const newTimeLockDelta = 100 const newTimeLockDelta = 100
var edgesToUpdate []EdgeWithInfo var edgesToUpdate []EdgeWithInfo
err = ctx.router.ForAllOutgoingChannels(context.Background(), func( err = ctx.router.ForAllOutgoingChannels(t.Context(), func(
info *models.ChannelEdgeInfo, info *models.ChannelEdgeInfo,
edge *models.ChannelEdgePolicy) error { edge *models.ChannelEdgePolicy) error {
@@ -3986,7 +3986,7 @@ func (m *SyncManager) markGraphSyncing() {
// initial historical sync has completed. // initial historical sync has completed.
func TestBroadcastAnnsAfterGraphSynced(t *testing.T) { func TestBroadcastAnnsAfterGraphSynced(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
tCtx, err := createTestCtx(t, 10, false) tCtx, err := createTestCtx(t, 10, false)
require.NoError(t, err, "can't create context") require.NoError(t, err, "can't create context")
@@ -4064,7 +4064,7 @@ func TestBroadcastAnnsAfterGraphSynced(t *testing.T) {
// is tested by TestRateLimitChannelUpdates. // is tested by TestRateLimitChannelUpdates.
func TestRateLimitDeDup(t *testing.T) { func TestRateLimitDeDup(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// Create our test harness. // Create our test harness.
const blockHeight = 100 const blockHeight = 100
@@ -4261,7 +4261,7 @@ func TestRateLimitDeDup(t *testing.T) {
// channel updates. // channel updates.
func TestRateLimitChannelUpdates(t *testing.T) { func TestRateLimitChannelUpdates(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// Create our test harness. // Create our test harness.
const blockHeight = 100 const blockHeight = 100
@@ -4416,7 +4416,7 @@ func TestRateLimitChannelUpdates(t *testing.T) {
// about our own channels when coming from a remote peer. // about our own channels when coming from a remote peer.
func TestIgnoreOwnAnnouncement(t *testing.T) { func TestIgnoreOwnAnnouncement(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
tCtx, err := createTestCtx(t, proofMatureDelta, false) tCtx, err := createTestCtx(t, proofMatureDelta, false)
require.NoError(t, err, "can't create context") require.NoError(t, err, "can't create context")
@@ -4563,7 +4563,7 @@ func TestIgnoreOwnAnnouncement(t *testing.T) {
// error. // error.
func TestRejectCacheChannelAnn(t *testing.T) { func TestRejectCacheChannelAnn(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
tCtx, err := createTestCtx(t, proofMatureDelta, false) tCtx, err := createTestCtx(t, proofMatureDelta, false)
require.NoError(t, err, "can't create context") require.NoError(t, err, "can't create context")
@@ -4644,7 +4644,7 @@ func TestFutureMsgCacheEviction(t *testing.T) {
// channel announcements are banned properly. // channel announcements are banned properly.
func TestChanAnnBanningNonChanPeer(t *testing.T) { func TestChanAnnBanningNonChanPeer(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
tCtx, err := createTestCtx(t, 1000, false) tCtx, err := createTestCtx(t, 1000, false)
require.NoError(t, err, "can't create context") require.NoError(t, err, "can't create context")
@@ -4739,7 +4739,7 @@ func TestChanAnnBanningNonChanPeer(t *testing.T) {
// get disconnected. // get disconnected.
func TestChanAnnBanningChanPeer(t *testing.T) { func TestChanAnnBanningChanPeer(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
tCtx, err := createTestCtx(t, 1000, true) tCtx, err := createTestCtx(t, 1000, true)
require.NoError(t, err, "can't create context") require.NoError(t, err, "can't create context")
@@ -4832,7 +4832,7 @@ func assertChanChainRejection(t *testing.T, ctx *testCtx,
} }
_, added := ctx.gossiper.handleChanAnnouncement( _, added := ctx.gossiper.handleChanAnnouncement(
context.Background(), nMsg, edge, t.Context(), nMsg, edge,
) )
require.False(t, added) require.False(t, added)
+2 -2
View File
@@ -71,7 +71,7 @@ func assertMsgsSent(t *testing.T, msgChan chan lnwire.Message,
// a peer while taking into account its connection lifecycle works as expected. // a peer while taking into account its connection lifecycle works as expected.
func TestReliableSenderFlow(t *testing.T) { func TestReliableSenderFlow(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
reliableSender := newTestReliableSender(t) reliableSender := newTestReliableSender(t)
@@ -188,7 +188,7 @@ func TestReliableSenderFlow(t *testing.T) {
// them as stale. // them as stale.
func TestReliableSenderStaleMessages(t *testing.T) { func TestReliableSenderStaleMessages(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
reliableSender := newTestReliableSender(t) reliableSender := newTestReliableSender(t)
+1 -1
View File
@@ -15,7 +15,7 @@ import (
// backlog at a time using the atomic flag. // backlog at a time using the atomic flag.
func TestGossipSyncerSingleBacklogSend(t *testing.T) { func TestGossipSyncerSingleBacklogSend(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// Track how many goroutines are actively sending. // Track how many goroutines are actively sending.
var ( var (
+15 -15
View File
@@ -232,7 +232,7 @@ func newTestSyncer(hID lnwire.ShortChannelID,
// doesn't have a horizon set, then we won't send any incoming messages to it. // doesn't have a horizon set, then we won't send any incoming messages to it.
func TestGossipSyncerFilterGossipMsgsNoHorizon(t *testing.T) { func TestGossipSyncerFilterGossipMsgsNoHorizon(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// First, we'll create a GossipSyncer instance with a canned sendToPeer // First, we'll create a GossipSyncer instance with a canned sendToPeer
// message to allow us to intercept their potential sends. // message to allow us to intercept their potential sends.
@@ -278,7 +278,7 @@ func unixStamp(a int64) uint32 {
// channel ann that already has a channel update on disk. // channel ann that already has a channel update on disk.
func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) { func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// First, we'll create a GossipSyncer instance with a canned sendToPeer // First, we'll create a GossipSyncer instance with a canned sendToPeer
// message to allow us to intercept their potential sends. // message to allow us to intercept their potential sends.
@@ -421,7 +421,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
// messages which are within their desired time horizon. // messages which are within their desired time horizon.
func TestGossipSyncerApplyNoHistoricalGossipFilter(t *testing.T) { func TestGossipSyncerApplyNoHistoricalGossipFilter(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// First, we'll create a GossipSyncer instance with a canned sendToPeer // First, we'll create a GossipSyncer instance with a canned sendToPeer
// message to allow us to intercept their potential sends. // message to allow us to intercept their potential sends.
@@ -473,7 +473,7 @@ func TestGossipSyncerApplyNoHistoricalGossipFilter(t *testing.T) {
// filter. // filter.
err := <-errChan err := <-errChan
if err != nil { if err != nil {
t.Fatalf(err.Error()) t.Fatal(err)
} }
} }
@@ -482,7 +482,7 @@ func TestGossipSyncerApplyNoHistoricalGossipFilter(t *testing.T) {
// within their desired time horizon. // within their desired time horizon.
func TestGossipSyncerApplyGossipFilter(t *testing.T) { func TestGossipSyncerApplyGossipFilter(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// First, we'll create a GossipSyncer instance with a canned sendToPeer // First, we'll create a GossipSyncer instance with a canned sendToPeer
// message to allow us to intercept their potential sends. // message to allow us to intercept their potential sends.
@@ -602,7 +602,7 @@ func TestGossipSyncerApplyGossipFilter(t *testing.T) {
// channels and complete=0. // channels and complete=0.
func TestGossipSyncerQueryChannelRangeWrongChainHash(t *testing.T) { func TestGossipSyncerQueryChannelRangeWrongChainHash(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// First, we'll create a GossipSyncer instance with a canned sendToPeer // First, we'll create a GossipSyncer instance with a canned sendToPeer
// message to allow us to intercept their potential sends. // message to allow us to intercept their potential sends.
@@ -655,7 +655,7 @@ func TestGossipSyncerQueryChannelRangeWrongChainHash(t *testing.T) {
// complete=0. // complete=0.
func TestGossipSyncerReplyShortChanIDsWrongChainHash(t *testing.T) { func TestGossipSyncerReplyShortChanIDsWrongChainHash(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// First, we'll create a GossipSyncer instance with a canned sendToPeer // First, we'll create a GossipSyncer instance with a canned sendToPeer
// message to allow us to intercept their potential sends. // message to allow us to intercept their potential sends.
@@ -705,7 +705,7 @@ func TestGossipSyncerReplyShortChanIDsWrongChainHash(t *testing.T) {
// announcements, as well as an ending ReplyShortChanIDsEnd message. // announcements, as well as an ending ReplyShortChanIDsEnd message.
func TestGossipSyncerReplyShortChanIDs(t *testing.T) { func TestGossipSyncerReplyShortChanIDs(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// First, we'll create a GossipSyncer instance with a canned sendToPeer // First, we'll create a GossipSyncer instance with a canned sendToPeer
// message to allow us to intercept their potential sends. // message to allow us to intercept their potential sends.
@@ -811,7 +811,7 @@ func TestGossipSyncerReplyShortChanIDs(t *testing.T) {
// the remote peer. // the remote peer.
func TestGossipSyncerReplyChanRangeQuery(t *testing.T) { func TestGossipSyncerReplyChanRangeQuery(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// We'll use a smaller chunk size so we can easily test all the edge // We'll use a smaller chunk size so we can easily test all the edge
// cases. // cases.
@@ -983,7 +983,7 @@ func TestGossipSyncerReplyChanRangeQuery(t *testing.T) {
// executed with the correct block range. // executed with the correct block range.
func TestGossipSyncerReplyChanRangeQueryBlockRange(t *testing.T) { func TestGossipSyncerReplyChanRangeQueryBlockRange(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// First create our test gossip syncer that will handle and // First create our test gossip syncer that will handle and
// respond to the test queries // respond to the test queries
@@ -1097,7 +1097,7 @@ func TestGossipSyncerReplyChanRangeQueryBlockRange(t *testing.T) {
// back a single response that signals completion. // back a single response that signals completion.
func TestGossipSyncerReplyChanRangeQueryNoNewChans(t *testing.T) { func TestGossipSyncerReplyChanRangeQueryNoNewChans(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// We'll now create our test gossip syncer that will shortly respond to // We'll now create our test gossip syncer that will shortly respond to
// our canned query. // our canned query.
@@ -1177,7 +1177,7 @@ func TestGossipSyncerReplyChanRangeQueryNoNewChans(t *testing.T) {
// channel ID, we properly generate an correct initial channel range response. // channel ID, we properly generate an correct initial channel range response.
func TestGossipSyncerGenChanRangeQuery(t *testing.T) { func TestGossipSyncerGenChanRangeQuery(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// First, we'll create a GossipSyncer instance with a canned sendToPeer // First, we'll create a GossipSyncer instance with a canned sendToPeer
// message to allow us to intercept their potential sends. // message to allow us to intercept their potential sends.
@@ -1238,7 +1238,7 @@ func TestGossipSyncerProcessChanRangeReply(t *testing.T) {
// each reply instead. // each reply instead.
func testGossipSyncerProcessChanRangeReply(t *testing.T, legacy bool) { func testGossipSyncerProcessChanRangeReply(t *testing.T, legacy bool) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// First, we'll create a GossipSyncer instance with a canned sendToPeer // First, we'll create a GossipSyncer instance with a canned sendToPeer
// message to allow us to intercept their potential sends. // message to allow us to intercept their potential sends.
@@ -1499,7 +1499,7 @@ func TestGossipSyncerSynchronizeChanIDs(t *testing.T) {
for i := 0; i < chunkSize*2; i += 2 { for i := 0; i < chunkSize*2; i += 2 {
// With our set up complete, we'll request a sync of chan ID's. // With our set up complete, we'll request a sync of chan ID's.
done := syncer.synchronizeChanIDs(context.Background()) done := syncer.synchronizeChanIDs(t.Context())
// At this point, we shouldn't yet be done as only 2 items // At this point, we shouldn't yet be done as only 2 items
// should have been queried for. // should have been queried for.
@@ -1546,7 +1546,7 @@ func TestGossipSyncerSynchronizeChanIDs(t *testing.T) {
} }
// If we issue another query, the syncer should tell us that it's done. // If we issue another query, the syncer should tell us that it's done.
done := syncer.synchronizeChanIDs(context.Background()) done := syncer.synchronizeChanIDs(t.Context())
if done { if done {
t.Fatalf("syncer should be finished!") t.Fatalf("syncer should be finished!")
} }
+1 -1
View File
@@ -1,6 +1,6 @@
# If you change this please also update GO_VERSION in Makefile (then run # If you change this please also update GO_VERSION in Makefile (then run
# `make lint` to see where else it needs to be updated as well). # `make lint` to see where else it needs to be updated as well).
FROM golang:1.23.12-alpine as builder FROM golang:1.24.6-alpine as builder
LABEL maintainer="Olaoluwa Osuntokun <laolu@lightning.engineering>" LABEL maintainer="Olaoluwa Osuntokun <laolu@lightning.engineering>"
+33 -33
View File
@@ -88,29 +88,29 @@ recommended for mainnet. The `master` branch can at times be unstable and
running your node off of it can prevent it to go back to a previous, stable running your node off of it can prevent it to go back to a previous, stable
version if there are database migrations present. version if there are database migrations present.
In order to work with [`lnd`](https://github.com/lightningnetwork/lnd), the In order to work with [`lnd`](https://github.com/lightningnetwork/lnd), the
following build dependencies are required: following build dependencies are required:
### Installing Go ### Installing Go
`lnd` is written in Go, with a minimum version of `1.23.12` (or, in case this `lnd` is written in Go, with a minimum version of `1.24.6` (or, in case this
document gets out of date, whatever the Go version in the main `go.mod` file document gets out of date, whatever the Go version in the main `go.mod` file
requires). To install, run one of the following commands for your OS: requires). To install, run one of the following commands for your OS:
<details> <details>
<summary>Linux (x86-64)</summary> <summary>Linux (x86-64)</summary>
``` ```
wget https://dl.google.com/go/go1.23.12.linux-amd64.tar.gz wget https://dl.google.com/go/go1.24.6.linux-amd64.tar.gz
sha256sum go1.23.12.linux-amd64.tar.gz | awk -F " " '{ print $1 }' sha256sum go1.24.6.linux-amd64.tar.gz | awk -F " " '{ print $1 }'
``` ```
The final output of the command above should be The final output of the command above should be
`d3847fef834e9db11bf64e3fb34db9c04db14e068eeb064f49af747010454f90`. If it `bbca37cc395c974ffa4893ee35819ad23ebb27426df87af92e93a9ec66ef8712`. If it
isn't, then the target REPO HAS BEEN MODIFIED, and you shouldn't install isn't, then the target REPO HAS BEEN MODIFIED, and you shouldn't install
this version of Go. If it matches, then proceed to install Go: this version of Go. If it matches, then proceed to install Go:
``` ```
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.23.12.linux-amd64.tar.gz sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.24.6.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin export PATH=$PATH:/usr/local/go/bin
``` ```
</details> </details>
@@ -119,16 +119,16 @@ requires). To install, run one of the following commands for your OS:
<summary>Linux (ARMv6)</summary> <summary>Linux (ARMv6)</summary>
``` ```
wget https://dl.google.com/go/go1.23.12.linux-armv6l.tar.gz wget https://dl.google.com/go/go1.24.6.linux-armv6l.tar.gz
sha256sum go1.23.12.linux-armv6l.tar.gz | awk -F " " '{ print $1 }' sha256sum go1.24.6.linux-armv6l.tar.gz | awk -F " " '{ print $1 }'
``` ```
The final output of the command above should be The final output of the command above should be
`9704eba01401a3793f54fac162164b9c5d8cc6f3cab5cee72684bb72294d9f41`. If it `7feb4d25f5e72f94fda81c99d4adb6630dfa2c35211e0819417d53af6e71809e`. If it
isn't, then the target REPO HAS BEEN MODIFIED, and you shouldn't install isn't, then the target REPO HAS BEEN MODIFIED, and you shouldn't install
this version of Go. If it matches, then proceed to install Go: this version of Go. If it matches, then proceed to install Go:
``` ```
sudo rm -rf /usr/local/go && tar -C /usr/local -xzf go1.23.12.linux-armv6l.tar.gz sudo rm -rf /usr/local/go && tar -C /usr/local -xzf go1.24.6.linux-armv6l.tar.gz
export PATH=$PATH:/usr/local/go/bin export PATH=$PATH:/usr/local/go/bin
``` ```
@@ -136,7 +136,7 @@ requires). To install, run one of the following commands for your OS:
<details> <details>
<summary>macOS</summary> <summary>macOS</summary>
First, install [Homebrew](https://brew.sh) if you don't already have it. First, install [Homebrew](https://brew.sh) if you don't already have it.
Then Then
@@ -149,7 +149,7 @@ requires). To install, run one of the following commands for your OS:
<details> <details>
<summary>FreeBSD</summary> <summary>FreeBSD</summary>
``` ```
pkg install go pkg install go
``` ```
@@ -172,14 +172,14 @@ export GOPATH=~/go
export PATH=$PATH:$GOPATH/bin export PATH=$PATH:$GOPATH/bin
``` ```
--- ---
We recommend placing the above in your `.bashrc`, `.zshrc` or in a setup script We recommend placing the above in your `.bashrc`, `.zshrc` or in a setup script
so that you can avoid typing this every time you open a new terminal window. so that you can avoid typing this every time you open a new terminal window.
### Go modules ### Go modules
This project uses [Go modules](https://github.com/golang/go/wiki/Modules) This project uses [Go modules](https://github.com/golang/go/wiki/Modules)
to manage dependencies as well as to provide *reproducible builds*. to manage dependencies as well as to provide *reproducible builds*.
Usage of Go modules (with Go 1.13) means that you no longer need to clone Usage of Go modules (with Go 1.13) means that you no longer need to clone
@@ -188,8 +188,8 @@ repo can now live anywhere!
--- ---
Note: For mobile development, having the source code in `$GOPATH` is still Note: For mobile development, having the source code in `$GOPATH` is still
required due to a current limitation in required due to a current limitation in
[Go mobile](https://pkg.go.dev/golang.org/x/mobile). Take a look at the [Go mobile](https://pkg.go.dev/golang.org/x/mobile). Take a look at the
documentation for [building mobile libraries](../mobile) to learn more. documentation for [building mobile libraries](../mobile) to learn more.
--- ---
@@ -209,7 +209,7 @@ wish to install a tagged release of `lnd` (as the master branch can at times be
unstable), then [visit the release page to locate the latest unstable), then [visit the release page to locate the latest
release](https://github.com/lightningnetwork/lnd/releases). Assuming the name release](https://github.com/lightningnetwork/lnd/releases). Assuming the name
of the release is `v0.x.x`, then you can compile this release from source with of the release is `v0.x.x`, then you can compile this release from source with
a small modification to the above command: a small modification to the above command:
```shell ```shell
git clone https://github.com/lightningnetwork/lnd git clone https://github.com/lightningnetwork/lnd
cd lnd cd lnd
@@ -299,7 +299,7 @@ in the system's `$PATH` variable. Otherwise, some tests will fail.
**Command-line completion for `lncli`** **Command-line completion for `lncli`**
_Bash_: See `contrib/lncli.bash-completion` _Bash_: See `contrib/lncli.bash-completion`
_Fish_: Run: `lncli fish-completion > $HOME/.config/fish/completions/lncli.fish` _Fish_: Run: `lncli fish-completion > $HOME/.config/fish/completions/lncli.fish`
# Available Backend Operating Modes # Available Backend Operating Modes
@@ -309,7 +309,7 @@ time of writing of this document, there are three available chain backends:
`btcd`, `neutrino`, `bitcoind`. All including neutrino can run on mainnet with `btcd`, `neutrino`, `bitcoind`. All including neutrino can run on mainnet with
an out of the box `lnd` instance. We don't require `--txindex` when running an out of the box `lnd` instance. We don't require `--txindex` when running
with `bitcoind` or `btcd` but activating the `txindex` will generally make with `bitcoind` or `btcd` but activating the `txindex` will generally make
`lnd` run faster. Note that since version 0.13 pruned nodes are supported, `lnd` run faster. Note that since version 0.13 pruned nodes are supported,
although they cause performance penalty and higher network usage. although they cause performance penalty and higher network usage.
The set of arguments for each of the backend modes is as follows: The set of arguments for each of the backend modes is as follows:
@@ -439,8 +439,8 @@ in `--bitcoin.simnet` if needed), and also your own `btcd` node if available:
## Using bitcoind ## Using bitcoind
Note that adding `-txindex` is optional, as it will take longer to sync the Note that adding `-txindex` is optional, as it will take longer to sync the
node, but then `lnd` will generally operate faster as it can hit the index node, but then `lnd` will generally operate faster as it can hit the index
directly, rather than scanning blocks or BIP 158 filters for relevant items. directly, rather than scanning blocks or BIP 158 filters for relevant items.
To configure your bitcoind backend for use with lnd, first complete and verify To configure your bitcoind backend for use with lnd, first complete and verify
@@ -449,10 +449,10 @@ the following:
- Since `lnd` uses - Since `lnd` uses
[ZeroMQ](https://github.com/bitcoin/bitcoin/blob/master/doc/zmq.md) to [ZeroMQ](https://github.com/bitcoin/bitcoin/blob/master/doc/zmq.md) to
interface with `bitcoind`, *your `bitcoind` installation must be compiled with interface with `bitcoind`, *your `bitcoind` installation must be compiled with
ZMQ*. Note that if you installed `bitcoind` from source and ZMQ was not present, ZMQ*. Note that if you installed `bitcoind` from source and ZMQ was not present,
then ZMQ support will be disabled, and `lnd` will quit on a `connection refused` error. then ZMQ support will be disabled, and `lnd` will quit on a `connection refused` error.
If you installed `bitcoind` via Homebrew in the past ZMQ may not be included If you installed `bitcoind` via Homebrew in the past ZMQ may not be included
([this has now been fixed](https://github.com/Homebrew/homebrew-core/pull/23088) ([this has now been fixed](https://github.com/Homebrew/homebrew-core/pull/23088)
in the latest Homebrew recipe for bitcoin) in the latest Homebrew recipe for bitcoin)
- Configure the `bitcoind` instance for ZMQ with `-zmqpubrawblock` and - Configure the `bitcoind` instance for ZMQ with `-zmqpubrawblock` and
`-zmqpubrawtx`. These options must each use their own unique address in order `-zmqpubrawtx`. These options must each use their own unique address in order
@@ -461,10 +461,10 @@ the following:
`-zmqpubrawtx=tcp://127.0.0.1:28333`). `-zmqpubrawtx=tcp://127.0.0.1:28333`).
- Make sure the config setting `-rpcserialversion` in `bitcoind` is either set - Make sure the config setting `-rpcserialversion` in `bitcoind` is either set
to 1 or NOT used because bitcoind's default behaviour is already correct to 1 or NOT used because bitcoind's default behaviour is already correct
(see [bitcoin/issues/28730](https://github.com/bitcoin/bitcoin/issues/28730) (see [bitcoin/issues/28730](https://github.com/bitcoin/bitcoin/issues/28730)
for more info). Lightning depends on segwit transactions therefore we need for more info). Lightning depends on segwit transactions therefore we need
the witness data when querying the bitcoind backend for transaction details. the witness data when querying the bitcoind backend for transaction details.
- Start `bitcoind` running against testnet, and let it complete a full sync with - Start `bitcoind` running against testnet, and let it complete a full sync with
the testnet chain (alternatively, use `--bitcoind.regtest` instead). the testnet chain (alternatively, use `--bitcoind.regtest` instead).
@@ -544,8 +544,8 @@ bearer credentials allowing for delegation, attenuation, and other cool
features. You can learn more about them in Alex Akselrod's [writeup on features. You can learn more about them in Alex Akselrod's [writeup on
GitHub](https://github.com/lightningnetwork/lnd/issues/20). GitHub](https://github.com/lightningnetwork/lnd/issues/20).
Running `lncli create` to create a wallet, will by default generate Running `lncli create` to create a wallet, will by default generate
the `admin.macaroon`, `read_only.macaroon`, and `macaroons.db` the `admin.macaroon`, `read_only.macaroon`, and `macaroons.db`
files that are used to authenticate files that are used to authenticate
into `lnd`. They will be stored in the network directory (default: into `lnd`. They will be stored in the network directory (default:
`lnddir/data/chain/bitcoin/mainnet`) so that it's possible to use a distinct `lnddir/data/chain/bitcoin/mainnet`) so that it's possible to use a distinct
@@ -617,5 +617,5 @@ Notice the `[Bitcoin]` section. This section houses the parameters for the
Bitcoin chain. See a more detailed sample config file available Bitcoin chain. See a more detailed sample config file available
[here](https://github.com/lightningnetwork/lnd/blob/master/sample-lnd.conf) [here](https://github.com/lightningnetwork/lnd/blob/master/sample-lnd.conf)
and explore the other sections for node configuration, including `[Btcd]`, and explore the other sections for node configuration, including `[Btcd]`,
`[Bitcoind]` and `[Neutrino]` depending on which chain and node type you're `[Bitcoind]` and `[Neutrino]` depending on which chain and node type you're
using. using.
+10 -10
View File
@@ -20,7 +20,7 @@ func TestContextGuard(t *testing.T) {
t.Run("Parent context is cancelled", func(t *testing.T) { t.Run("Parent context is cancelled", func(t *testing.T) {
t.Parallel() t.Parallel()
var ( var (
ctx, cancel = context.WithCancel(context.Background()) ctx, cancel = context.WithCancel(t.Context())
g = NewContextGuard() g = NewContextGuard()
) )
@@ -42,7 +42,7 @@ func TestContextGuard(t *testing.T) {
t.Run("Derived context is cancelled", func(t *testing.T) { t.Run("Derived context is cancelled", func(t *testing.T) {
t.Parallel() t.Parallel()
var ( var (
ctx = context.Background() ctx = t.Context()
g = NewContextGuard() g = NewContextGuard()
) )
@@ -66,7 +66,7 @@ func TestContextGuard(t *testing.T) {
t.Parallel() t.Parallel()
var ( var (
ctx = context.Background() ctx = t.Context()
g = NewContextGuard() g = NewContextGuard()
) )
ctxc, _ := g.Create(ctx) ctxc, _ := g.Create(ctx)
@@ -87,7 +87,7 @@ func TestContextGuard(t *testing.T) {
t.Parallel() t.Parallel()
var ( var (
ctx, cancel = context.WithCancel(context.Background()) ctx, cancel = context.WithCancel(t.Context())
g = NewContextGuard() g = NewContextGuard()
) )
cancel() cancel()
@@ -107,7 +107,7 @@ func TestContextGuard(t *testing.T) {
t.Parallel() t.Parallel()
var ( var (
ctx = context.Background() ctx = t.Context()
g = NewContextGuard() g = NewContextGuard()
) )
@@ -130,7 +130,7 @@ func TestContextGuard(t *testing.T) {
t.Parallel() t.Parallel()
var ( var (
ctx, cancel = context.WithCancel(context.Background()) ctx, cancel = context.WithCancel(t.Context())
g = NewContextGuard() g = NewContextGuard()
task = make(chan struct{}) task = make(chan struct{})
done = make(chan struct{}) done = make(chan struct{})
@@ -172,7 +172,7 @@ func TestContextGuard(t *testing.T) {
t.Parallel() t.Parallel()
var ( var (
ctx = context.Background() ctx = t.Context()
g = NewContextGuard() g = NewContextGuard()
task = make(chan struct{}) task = make(chan struct{})
done = make(chan struct{}) done = make(chan struct{})
@@ -218,7 +218,7 @@ func TestContextGuard(t *testing.T) {
t.Parallel() t.Parallel()
var ( var (
ctx = context.Background() ctx = t.Context()
g = NewContextGuard() g = NewContextGuard()
task = make(chan struct{}) task = make(chan struct{})
done = make(chan struct{}) done = make(chan struct{})
@@ -316,7 +316,7 @@ func TestContextGuard(t *testing.T) {
t.Parallel() t.Parallel()
var ( var (
ctx = context.Background() ctx = t.Context()
g = NewContextGuard() g = NewContextGuard()
task = make(chan struct{}) task = make(chan struct{})
done = make(chan struct{}) done = make(chan struct{})
@@ -452,7 +452,7 @@ func TestContextGuardCountGoroutines(t *testing.T) {
g := NewContextGuard() g := NewContextGuard()
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(t.Context())
// Count goroutines before contexts are created. // Count goroutines before contexts are created.
count1 := runtime.NumGoroutine() count1 := runtime.NumGoroutine()
+3 -3
View File
@@ -18,7 +18,7 @@ func TestGoroutineManager(t *testing.T) {
t.Parallel() t.Parallel()
var ( var (
ctx = context.Background() ctx = t.Context()
m = NewGoroutineManager() m = NewGoroutineManager()
taskChan = make(chan struct{}) taskChan = make(chan struct{})
) )
@@ -61,7 +61,7 @@ func TestGoroutineManager(t *testing.T) {
t.Parallel() t.Parallel()
var ( var (
ctx = context.Background() ctx = t.Context()
m = NewGoroutineManager() m = NewGoroutineManager()
taskChan = make(chan struct{}) taskChan = make(chan struct{})
) )
@@ -114,7 +114,7 @@ func TestGoroutineManager(t *testing.T) {
t.Parallel() t.Parallel()
var ( var (
ctx = context.Background() ctx = t.Context()
m = NewGoroutineManager() m = NewGoroutineManager()
stopChan = make(chan struct{}) stopChan = make(chan struct{})
) )
+1 -1
View File
@@ -359,7 +359,7 @@ func TestBatchFund(t *testing.T) {
MinConfs: 1, MinConfs: 1,
} }
updates, err := h.batcher.BatchFund( updates, err := h.batcher.BatchFund(
context.Background(), req, t.Context(), req,
) )
if tc.failUpdate1 || tc.failUpdate2 || tc.failPublish { if tc.failUpdate1 || tc.failUpdate2 || tc.failPublish {
+2 -2
View File
@@ -54,7 +54,6 @@ require (
golang.org/x/crypto v0.37.0 golang.org/x/crypto v0.37.0
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028 golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028
golang.org/x/net v0.39.0
golang.org/x/sync v0.13.0 golang.org/x/sync v0.13.0
golang.org/x/term v0.31.0 golang.org/x/term v0.31.0
golang.org/x/time v0.3.0 golang.org/x/time v0.3.0
@@ -182,6 +181,7 @@ require (
go.uber.org/multierr v1.6.0 // indirect go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.17.0 // indirect go.uber.org/zap v1.17.0 // indirect
golang.org/x/mod v0.17.0 // indirect golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.39.0 // indirect
golang.org/x/sys v0.32.0 // indirect golang.org/x/sys v0.32.0 // indirect
golang.org/x/text v0.24.0 // indirect golang.org/x/text v0.24.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
@@ -220,6 +220,6 @@ replace google.golang.org/protobuf => github.com/lightninglabs/protobuf-go-hex-d
// If you change this please also update docs/INSTALL.md and GO_VERSION in // If you change this please also update docs/INSTALL.md and GO_VERSION in
// Makefile (then run `make lint` to see where else it needs to be updated as // Makefile (then run `make lint` to see where else it needs to be updated as
// well). // well).
go 1.23.12 go 1.24.6
retract v0.0.2 retract v0.0.2
+13 -14
View File
@@ -2,7 +2,6 @@ package graph
import ( import (
"bytes" "bytes"
"context"
"crypto/sha256" "crypto/sha256"
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
@@ -44,7 +43,7 @@ const (
// info was added to the database. // info was added to the database.
func TestAddProof(t *testing.T) { func TestAddProof(t *testing.T) {
t.Parallel() t.Parallel()
ctxb := context.Background() ctxb := t.Context()
ctx := createTestCtxSingleNode(t, 0) ctx := createTestCtxSingleNode(t, 0)
@@ -109,7 +108,7 @@ func TestIgnoreNodeAnnouncement(t *testing.T) {
} }
copy(node.PubKeyBytes[:], pub.SerializeCompressed()) copy(node.PubKeyBytes[:], pub.SerializeCompressed())
err := ctx.builder.AddNode(context.Background(), node) err := ctx.builder.AddNode(t.Context(), node)
if !IsError(err, ErrIgnored) { if !IsError(err, ErrIgnored) {
t.Fatalf("expected to get ErrIgnore, instead got: %v", err) t.Fatalf("expected to get ErrIgnore, instead got: %v", err)
} }
@@ -119,7 +118,7 @@ func TestIgnoreNodeAnnouncement(t *testing.T) {
// ignore a channel policy for a channel not in the graph. // ignore a channel policy for a channel not in the graph.
func TestIgnoreChannelEdgePolicyForUnknownChannel(t *testing.T) { func TestIgnoreChannelEdgePolicyForUnknownChannel(t *testing.T) {
t.Parallel() t.Parallel()
ctxb := context.Background() ctxb := t.Context()
const startingBlockHeight = 101 const startingBlockHeight = 101
@@ -194,7 +193,7 @@ func TestIgnoreChannelEdgePolicyForUnknownChannel(t *testing.T) {
// confirmed on the stale chain, and resync to the main chain. // confirmed on the stale chain, and resync to the main chain.
func TestWakeUpOnStaleBranch(t *testing.T) { func TestWakeUpOnStaleBranch(t *testing.T) {
t.Parallel() t.Parallel()
ctxb := context.Background() ctxb := t.Context()
const startingBlockHeight = 101 const startingBlockHeight = 101
ctx := createTestCtxSingleNode(t, startingBlockHeight) ctx := createTestCtxSingleNode(t, startingBlockHeight)
@@ -354,7 +353,7 @@ func TestWakeUpOnStaleBranch(t *testing.T) {
// Give time to process new blocks. // Give time to process new blocks.
time.Sleep(time.Millisecond * 500) time.Sleep(time.Millisecond * 500)
selfNode, err := ctx.graph.SourceNode(context.Background()) selfNode, err := ctx.graph.SourceNode(t.Context())
require.NoError(t, err) require.NoError(t, err)
// Create new router with same graph database. // Create new router with same graph database.
@@ -408,7 +407,7 @@ func TestWakeUpOnStaleBranch(t *testing.T) {
// it is active. // it is active.
func TestDisconnectedBlocks(t *testing.T) { func TestDisconnectedBlocks(t *testing.T) {
t.Parallel() t.Parallel()
ctxb := context.Background() ctxb := t.Context()
const startingBlockHeight = 101 const startingBlockHeight = 101
ctx := createTestCtxSingleNode(t, startingBlockHeight) ctx := createTestCtxSingleNode(t, startingBlockHeight)
@@ -609,7 +608,7 @@ func TestDisconnectedBlocks(t *testing.T) {
// ChannelRouter, then the channels are properly pruned. // ChannelRouter, then the channels are properly pruned.
func TestChansClosedOfflinePruneGraph(t *testing.T) { func TestChansClosedOfflinePruneGraph(t *testing.T) {
t.Parallel() t.Parallel()
ctxb := context.Background() ctxb := t.Context()
const startingBlockHeight = 101 const startingBlockHeight = 101
ctx := createTestCtxSingleNode(t, startingBlockHeight) ctx := createTestCtxSingleNode(t, startingBlockHeight)
@@ -1037,7 +1036,7 @@ func testPruneChannelGraphDoubleDisabled(t *testing.T, assumeValid bool) {
// node announcements. // node announcements.
func TestIsStaleNode(t *testing.T) { func TestIsStaleNode(t *testing.T) {
t.Parallel() t.Parallel()
ctxb := context.Background() ctxb := t.Context()
const startingBlockHeight = 101 const startingBlockHeight = 101
ctx := createTestCtxSingleNode(t, startingBlockHeight) ctx := createTestCtxSingleNode(t, startingBlockHeight)
@@ -1095,7 +1094,7 @@ func TestIsStaleNode(t *testing.T) {
Features: testFeatures, Features: testFeatures,
} }
copy(n1.PubKeyBytes[:], priv1.PubKey().SerializeCompressed()) copy(n1.PubKeyBytes[:], priv1.PubKey().SerializeCompressed())
if err := ctx.builder.AddNode(context.Background(), n1); err != nil { if err := ctx.builder.AddNode(t.Context(), n1); err != nil {
t.Fatalf("could not add node: %v", err) t.Fatalf("could not add node: %v", err)
} }
@@ -1117,7 +1116,7 @@ func TestIsStaleNode(t *testing.T) {
// channel announcements. // channel announcements.
func TestIsKnownEdge(t *testing.T) { func TestIsKnownEdge(t *testing.T) {
t.Parallel() t.Parallel()
ctxb := context.Background() ctxb := t.Context()
const startingBlockHeight = 101 const startingBlockHeight = 101
ctx := createTestCtxSingleNode(t, startingBlockHeight) ctx := createTestCtxSingleNode(t, startingBlockHeight)
@@ -1167,7 +1166,7 @@ func TestIsKnownEdge(t *testing.T) {
// stale channel edge update announcements. // stale channel edge update announcements.
func TestIsStaleEdgePolicy(t *testing.T) { func TestIsStaleEdgePolicy(t *testing.T) {
t.Parallel() t.Parallel()
ctxb := context.Background() ctxb := t.Context()
const startingBlockHeight = 101 const startingBlockHeight = 101
ctx := createTestCtxFromFile(t, startingBlockHeight, basicGraphFilePath) ctx := createTestCtxFromFile(t, startingBlockHeight, basicGraphFilePath)
@@ -1359,7 +1358,7 @@ func createTestCtxFromFile(t *testing.T,
func parseTestGraph(t *testing.T, useCache bool, path string) ( func parseTestGraph(t *testing.T, useCache bool, path string) (
*testGraphInstance, error) { *testGraphInstance, error) {
ctx := context.Background() ctx := t.Context()
graphJSON, err := os.ReadFile(path) graphJSON, err := os.ReadFile(path)
if err != nil { if err != nil {
@@ -1751,7 +1750,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
testChannels []*testChannel, source string) (*testGraphInstance, testChannels []*testChannel, source string) (*testGraphInstance,
error) { error) {
ctx := context.Background() ctx := t.Context()
// We'll use this fake address for the IP address of all the nodes in // We'll use this fake address for the IP address of all the nodes in
// our tests. This value isn't needed for path finding so it doesn't // our tests. This value isn't needed for path finding so it doesn't
+9 -9
View File
@@ -189,7 +189,7 @@ func sqlSQLite(t testing.TB, dbPath, file string) BatchedSQLQueries {
// database for testing purposes. // database for testing purposes.
func kvdbPostgres(t testing.TB, dsn string) kvdb.Backend { func kvdbPostgres(t testing.TB, dsn string) kvdb.Backend {
kvStore, err := kvdb.Open( kvStore, err := kvdb.Open(
kvdb.PostgresBackendName, context.Background(), kvdb.PostgresBackendName, t.Context(),
&postgres.Config{ &postgres.Config{
Dsn: dsn, Dsn: dsn,
MaxConnections: testMaxPostgresConnections, MaxConnections: testMaxPostgresConnections,
@@ -217,7 +217,7 @@ func connectKVDBPostgres(t testing.TB, dsn string) V1Store {
func kvdbSqlite(t testing.TB, dbPath, fileName string) kvdb.Backend { func kvdbSqlite(t testing.TB, dbPath, fileName string) kvdb.Backend {
sqlbase.Init(testMaxSQLiteConnections) sqlbase.Init(testMaxSQLiteConnections)
kvStore, err := kvdb.Open( kvStore, err := kvdb.Open(
kvdb.SqliteBackendName, context.Background(), kvdb.SqliteBackendName, t.Context(),
&sqlite.Config{ &sqlite.Config{
BusyTimeout: testSQLBusyTimeout, BusyTimeout: testSQLBusyTimeout,
MaxConnections: testMaxSQLiteConnections, MaxConnections: testMaxSQLiteConnections,
@@ -273,7 +273,7 @@ func newKVStore(t testing.TB, backend kvdb.Backend) V1Store {
// provided sqldb.DB instance. // provided sqldb.DB instance.
func newSQLExecutor(t testing.TB, db sqldb.DB) BatchedSQLQueries { func newSQLExecutor(t testing.TB, db sqldb.DB) BatchedSQLQueries {
err := db.ApplyAllMigrations( err := db.ApplyAllMigrations(
context.Background(), sqldb.GetMigrations(), t.Context(), sqldb.GetMigrations(),
) )
require.NoError(t, err) require.NoError(t, err)
@@ -317,7 +317,7 @@ func newSQLStore(t testing.TB, cfg *sqldb.QueryConfig,
// very long to sync the graph. // very long to sync the graph.
func TestPopulateDBs(t *testing.T) { func TestPopulateDBs(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// NOTE: uncomment the line below to run this test locally, then provide // NOTE: uncomment the line below to run this test locally, then provide
// the desired source database (and make sure the destination Postgres // the desired source database (and make sure the destination Postgres
@@ -539,7 +539,7 @@ func TestPopulateViaMigration(t *testing.T) {
// Use the graph migration to populate the SQL graph from the // Use the graph migration to populate the SQL graph from the
// kvdb graph. // kvdb graph.
ctx := context.Background() ctx := t.Context()
err := dstSQL.ExecTx( err := dstSQL.ExecTx(
ctx, sqldb.WriteTxOpt(), func(queries SQLQueries) error { ctx, sqldb.WriteTxOpt(), func(queries SQLQueries) error {
return MigrateGraphToSQL( return MigrateGraphToSQL(
@@ -556,7 +556,7 @@ func TestPopulateViaMigration(t *testing.T) {
// syncGraph synchronizes the source graph with the destination graph by // syncGraph synchronizes the source graph with the destination graph by
// copying all nodes and channels from the source to the destination. // copying all nodes and channels from the source to the destination.
func syncGraph(t *testing.T, src, dest *ChannelGraph) { func syncGraph(t *testing.T, src, dest *ChannelGraph) {
ctx := context.Background() ctx := t.Context()
var ( var (
s = rate.Sometimes{ s = rate.Sometimes{
@@ -683,7 +683,7 @@ func syncGraph(t *testing.T, src, dest *ChannelGraph) {
// NOTE: the TestPopulateDBs test helper can be used to populate a set of test // NOTE: the TestPopulateDBs test helper can be used to populate a set of test
// DBs from a single source db. // DBs from a single source db.
func BenchmarkCacheLoading(b *testing.B) { func BenchmarkCacheLoading(b *testing.B) {
ctx := context.Background() ctx := b.Context()
tests := []dbConnection{ tests := []dbConnection{
kvdbBBoltConn, kvdbBBoltConn,
@@ -723,7 +723,7 @@ func BenchmarkCacheLoading(b *testing.B) {
// NOTE: the TestPopulateDBs test helper can be used to populate a set of test // NOTE: the TestPopulateDBs test helper can be used to populate a set of test
// DBs from a single source db. // DBs from a single source db.
func BenchmarkGraphReadMethods(b *testing.B) { func BenchmarkGraphReadMethods(b *testing.B) {
ctx := context.Background() ctx := b.Context()
backends := []dbConnection{ backends := []dbConnection{
kvdbBBoltConn, kvdbBBoltConn,
@@ -900,7 +900,7 @@ func BenchmarkFindOptimalSQLQueryConfig(b *testing.B) {
for _, size := range testSizes { for _, size := range testSizes {
b.Run(fmt.Sprintf("%s-%s-%d", configOption, dbName, size), b.Run(fmt.Sprintf("%s-%s-%d", configOption, dbName, size),
func(b *testing.B) { func(b *testing.B) {
ctx := context.Background() ctx := b.Context()
cfg := sqldb.DefaultSQLiteConfig() cfg := sqldb.DefaultSQLiteConfig()
if testPostgres { if testPostgres {
+37 -37
View File
@@ -100,7 +100,7 @@ func createTestVertex(t testing.TB) *models.LightningNode {
// TestNodeInsertionAndDeletion tests the CRUD operations for a LightningNode. // TestNodeInsertionAndDeletion tests the CRUD operations for a LightningNode.
func TestNodeInsertionAndDeletion(t *testing.T) { func TestNodeInsertionAndDeletion(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -276,7 +276,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
// only the pubkey is known to the database. // only the pubkey is known to the database.
func TestPartialNode(t *testing.T) { func TestPartialNode(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -344,7 +344,7 @@ func TestPartialNode(t *testing.T) {
// TestAliasLookup tests the alias lookup functionality of the graph store. // TestAliasLookup tests the alias lookup functionality of the graph store.
func TestAliasLookup(t *testing.T) { func TestAliasLookup(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -375,7 +375,7 @@ func TestAliasLookup(t *testing.T) {
// TestSourceNode tests the source node functionality of the graph store. // TestSourceNode tests the source node functionality of the graph store.
func TestSourceNode(t *testing.T) { func TestSourceNode(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -402,7 +402,7 @@ func TestSourceNode(t *testing.T) {
// TestEdgeInsertionDeletion tests the basic CRUD operations for channel edges. // TestEdgeInsertionDeletion tests the basic CRUD operations for channel edges.
func TestEdgeInsertionDeletion(t *testing.T) { func TestEdgeInsertionDeletion(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -527,7 +527,7 @@ func createEdge(height, txIndex uint32, txPosition uint16, outPointIndex uint32,
// database is what we expect after calling DisconnectBlockAtHeight. // database is what we expect after calling DisconnectBlockAtHeight.
func TestDisconnectBlockAtHeight(t *testing.T) { func TestDisconnectBlockAtHeight(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -818,7 +818,7 @@ func createChannelEdge(node1, node2 *models.LightningNode,
func TestEdgeInfoUpdates(t *testing.T) { func TestEdgeInfoUpdates(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -914,7 +914,7 @@ func TestEdgeInfoUpdates(t *testing.T) {
// TestEdgePolicyCRUD tests basic CRUD operations for edge policies. // TestEdgePolicyCRUD tests basic CRUD operations for edge policies.
func TestEdgePolicyCRUD(t *testing.T) { func TestEdgePolicyCRUD(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -1208,7 +1208,7 @@ func newEdgePolicy(chanID uint64, updateTime int64) *models.ChannelEdgePolicy {
// TestAddEdgeProof tests the ability to add an edge proof to an existing edge. // TestAddEdgeProof tests the ability to add an edge proof to an existing edge.
func TestAddEdgeProof(t *testing.T) { func TestAddEdgeProof(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -1267,7 +1267,7 @@ func TestAddEdgeProof(t *testing.T) {
// correctly iterates through the channels of the set source node. // correctly iterates through the channels of the set source node.
func TestForEachSourceNodeChannel(t *testing.T) { func TestForEachSourceNodeChannel(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -1356,7 +1356,7 @@ func TestForEachSourceNodeChannel(t *testing.T) {
func TestGraphTraversal(t *testing.T) { func TestGraphTraversal(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -1455,7 +1455,7 @@ func TestGraphTraversal(t *testing.T) {
// working correctly. // working correctly.
func TestGraphTraversalCacheable(t *testing.T) { func TestGraphTraversalCacheable(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -1582,7 +1582,7 @@ func TestGraphCacheTraversal(t *testing.T) {
func fillTestGraph(t testing.TB, graph *ChannelGraph, numNodes, func fillTestGraph(t testing.TB, graph *ChannelGraph, numNodes,
numChannels int) (map[uint64]struct{}, []*models.LightningNode) { numChannels int) (map[uint64]struct{}, []*models.LightningNode) {
ctx := context.Background() ctx := t.Context()
nodes := make([]*models.LightningNode, numNodes) nodes := make([]*models.LightningNode, numNodes)
nodeIndex := map[string]struct{}{} nodeIndex := map[string]struct{}{}
@@ -1694,7 +1694,7 @@ func assertPruneTip(t *testing.T, graph *ChannelGraph,
func assertNumChans(t *testing.T, graph *ChannelGraph, n int) { func assertNumChans(t *testing.T, graph *ChannelGraph, n int) {
numChans := 0 numChans := 0
err := graph.ForEachChannel( err := graph.ForEachChannel(
context.Background(), func(*models.ChannelEdgeInfo, t.Context(), func(*models.ChannelEdgeInfo,
*models.ChannelEdgePolicy, *models.ChannelEdgePolicy,
*models.ChannelEdgePolicy) error { *models.ChannelEdgePolicy) error {
@@ -1710,7 +1710,7 @@ func assertNumChans(t *testing.T, graph *ChannelGraph, n int) {
func assertNumNodes(t *testing.T, graph *ChannelGraph, n int) { func assertNumNodes(t *testing.T, graph *ChannelGraph, n int) {
numNodes := 0 numNodes := 0
err := graph.ForEachNode(context.Background(), err := graph.ForEachNode(t.Context(),
func(_ *models.LightningNode) error { func(_ *models.LightningNode) error {
numNodes++ numNodes++
@@ -1772,7 +1772,7 @@ func assertChanViewEqualChanPoints(t *testing.T, a []EdgePoint,
func TestGraphPruning(t *testing.T) { func TestGraphPruning(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -1963,7 +1963,7 @@ func TestGraphPruning(t *testing.T) {
// known channel ID in the database. // known channel ID in the database.
func TestHighestChanID(t *testing.T) { func TestHighestChanID(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -2023,7 +2023,7 @@ func TestHighestChanID(t *testing.T) {
// insertion of a new edge, the edge update index is updated properly. // insertion of a new edge, the edge update index is updated properly.
func TestChanUpdatesInHorizon(t *testing.T) { func TestChanUpdatesInHorizon(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -2181,7 +2181,7 @@ func TestChanUpdatesInHorizon(t *testing.T) {
// the most recent node updates within a particular time horizon. // the most recent node updates within a particular time horizon.
func TestNodeUpdatesInHorizon(t *testing.T) { func TestNodeUpdatesInHorizon(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -2352,7 +2352,7 @@ func TestFilterKnownChanIDsZombieRevival(t *testing.T) {
// know of on disk. // know of on disk.
func TestFilterKnownChanIDs(t *testing.T) { func TestFilterKnownChanIDs(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -2535,7 +2535,7 @@ func TestStressTestChannelGraphAPI(t *testing.T) {
t.Skipf("Skipping test in short mode") t.Skipf("Skipping test in short mode")
} }
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -2824,7 +2824,7 @@ func TestStressTestChannelGraphAPI(t *testing.T) {
// set of short channel ID's for a given block range. // set of short channel ID's for a given block range.
func TestFilterChannelRange(t *testing.T) { func TestFilterChannelRange(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -3043,7 +3043,7 @@ func TestFilterChannelRange(t *testing.T) {
// of ChannelEdge structs for a given set of short channel ID's. // of ChannelEdge structs for a given set of short channel ID's.
func TestFetchChanInfos(t *testing.T) { func TestFetchChanInfos(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -3146,7 +3146,7 @@ func TestFetchChanInfos(t *testing.T) {
// both sides. // both sides.
func TestIncompleteChannelPolicies(t *testing.T) { func TestIncompleteChannelPolicies(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -3239,7 +3239,7 @@ func TestIncompleteChannelPolicies(t *testing.T) {
// up. // up.
func TestChannelEdgePruningUpdateIndexDeletion(t *testing.T) { func TestChannelEdgePruningUpdateIndexDeletion(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -3387,7 +3387,7 @@ func TestChannelEdgePruningUpdateIndexDeletion(t *testing.T) {
// PruneSyncState method. // PruneSyncState method.
func TestPruneGraphNodes(t *testing.T) { func TestPruneGraphNodes(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -3453,7 +3453,7 @@ func TestPruneGraphNodes(t *testing.T) {
// database, then shell edges are created for each node if needed. // database, then shell edges are created for each node if needed.
func TestAddChannelEdgeShellNodes(t *testing.T) { func TestAddChannelEdgeShellNodes(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -3492,7 +3492,7 @@ func TestAddChannelEdgeShellNodes(t *testing.T) {
// well. // well.
func TestNodePruningUpdateIndexDeletion(t *testing.T) { func TestNodePruningUpdateIndexDeletion(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -3553,7 +3553,7 @@ func nextUpdateTime() time.Time {
// public within the network graph. // public within the network graph.
func TestNodeIsPublic(t *testing.T) { func TestNodeIsPublic(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// We'll start off the test by creating a small network of 3 // We'll start off the test by creating a small network of 3
// participants with the following graph: // participants with the following graph:
@@ -3688,7 +3688,7 @@ func TestNodeIsPublic(t *testing.T) {
// DisabledChannelIDs is correct. // DisabledChannelIDs is correct.
func TestDisabledChannelIDs(t *testing.T) { func TestDisabledChannelIDs(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -3773,7 +3773,7 @@ func TestDisabledChannelIDs(t *testing.T) {
// receive the proper update. // receive the proper update.
func TestEdgePolicyMissingMaxHTLC(t *testing.T) { func TestEdgePolicyMissingMaxHTLC(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -3916,7 +3916,7 @@ func assertNumZombies(t *testing.T, graph *ChannelGraph, expZombies uint64) {
// TestGraphZombieIndex ensures that we can mark edges correctly as zombie/live. // TestGraphZombieIndex ensures that we can mark edges correctly as zombie/live.
func TestGraphZombieIndex(t *testing.T) { func TestGraphZombieIndex(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// We'll start by creating our test graph along with a test edge. // We'll start by creating our test graph along with a test edge.
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -4103,7 +4103,7 @@ func TestComputeFee(t *testing.T) {
// executes multiple AddChannelEdge requests in a single txn. // executes multiple AddChannelEdge requests in a single txn.
func TestBatchedAddChannelEdge(t *testing.T) { func TestBatchedAddChannelEdge(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -4180,7 +4180,7 @@ func TestBatchedAddChannelEdge(t *testing.T) {
// executes multiple UpdateEdgePolicy requests in a single txn. // executes multiple UpdateEdgePolicy requests in a single txn.
func TestBatchedUpdateEdgePolicy(t *testing.T) { func TestBatchedUpdateEdgePolicy(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -4233,7 +4233,7 @@ func TestBatchedUpdateEdgePolicy(t *testing.T) {
// allocations and the total memory consumed by the full graph traversal. // allocations and the total memory consumed by the full graph traversal.
func BenchmarkForEachChannel(b *testing.B) { func BenchmarkForEachChannel(b *testing.B) {
graph := MakeTestGraph(b) graph := MakeTestGraph(b)
ctx := context.Background() ctx := b.Context()
const numNodes = 100 const numNodes = 100
const numChannels = 4 const numChannels = 4
@@ -4286,7 +4286,7 @@ func BenchmarkForEachChannel(b *testing.B) {
// method works as expected, and is able to handle nil self edges. // method works as expected, and is able to handle nil self edges.
func TestGraphCacheForEachNodeChannel(t *testing.T) { func TestGraphCacheForEachNodeChannel(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
@@ -4448,7 +4448,7 @@ var testNodeAnn = "01012674c2e7ef68c73a086b7de2603f4ef1567358df84bb4edaa06c" +
// that the two messages are equal. // that the two messages are equal.
func TestLightningNodePersistence(t *testing.T) { func TestLightningNodePersistence(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// Create a new test graph instance. // Create a new test graph instance.
graph := MakeTestGraph(t) graph := MakeTestGraph(t)
+9 -10
View File
@@ -5,7 +5,6 @@ package graphdb
import ( import (
"bytes" "bytes"
"cmp" "cmp"
"context"
"crypto/rand" "crypto/rand"
"errors" "errors"
"fmt" "fmt"
@@ -65,7 +64,7 @@ var (
// ensure that the migration can handle this. // ensure that the migration can handle this.
func TestMigrateGraphToSQL(t *testing.T) { func TestMigrateGraphToSQL(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
dbFixture := NewTestDBFixture(t) dbFixture := NewTestDBFixture(t)
@@ -459,7 +458,7 @@ func assertInSync(t *testing.T, kvDB *KVStore, sqlDB *SQLStore,
func fetchAllNodes(t *testing.T, store V1Store) []*models.LightningNode { func fetchAllNodes(t *testing.T, store V1Store) []*models.LightningNode {
nodes := make([]*models.LightningNode, 0) nodes := make([]*models.LightningNode, 0)
err := store.ForEachNode(context.Background(), err := store.ForEachNode(t.Context(),
func(node *models.LightningNode) error { func(node *models.LightningNode) error {
// Call PubKey to ensure the objects cached pubkey is set so that // Call PubKey to ensure the objects cached pubkey is set so that
@@ -489,7 +488,7 @@ func fetchAllNodes(t *testing.T, store V1Store) []*models.LightningNode {
// fetchSourceNode retrieves the source node from the given store. // fetchSourceNode retrieves the source node from the given store.
func fetchSourceNode(t *testing.T, store V1Store) *models.LightningNode { func fetchSourceNode(t *testing.T, store V1Store) *models.LightningNode {
node, err := store.SourceNode(context.Background()) node, err := store.SourceNode(t.Context())
if errors.Is(err, ErrSourceNodeNotSet) { if errors.Is(err, ErrSourceNodeNotSet) {
return nil return nil
} else { } else {
@@ -527,7 +526,7 @@ func (c chanSet) CountPolicies() int {
// fetchAllChannelsAndPolicies retrieves all channels and their policies // fetchAllChannelsAndPolicies retrieves all channels and their policies
// from the given store and returns them sorted by their channel ID. // from the given store and returns them sorted by their channel ID.
func fetchAllChannelsAndPolicies(t *testing.T, store V1Store) chanSet { func fetchAllChannelsAndPolicies(t *testing.T, store V1Store) chanSet {
ctx := context.Background() ctx := t.Context()
channels := make(chanSet, 0) channels := make(chanSet, 0)
err := store.ForEachChannel(ctx, func(info *models.ChannelEdgeInfo, err := store.ForEachChannel(ctx, func(info *models.ChannelEdgeInfo,
p1 *models.ChannelEdgePolicy, p1 *models.ChannelEdgePolicy,
@@ -572,7 +571,7 @@ func checkKVPruneLogEntries(t *testing.T, kv *KVStore, sql *SQLStore,
err := forEachPruneLogEntry( err := forEachPruneLogEntry(
kv.db, func(height uint32, hash *chainhash.Hash) error { kv.db, func(height uint32, hash *chainhash.Hash) error {
sqlHash, err := sql.db.GetPruneHashByHeight( sqlHash, err := sql.db.GetPruneHashByHeight(
context.Background(), int64(height), t.Context(), int64(height),
) )
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, hash[:], sqlHash) require.Equal(t, hash[:], sqlHash)
@@ -804,7 +803,7 @@ func makeTestPolicy(chanID uint64, toNode route.Vertex, isNode1 bool,
// and set the "fileName" variable to the name of the channel database file you // and set the "fileName" variable to the name of the channel database file you
// want to use for the migration test. // want to use for the migration test.
func TestMigrationWithChannelDB(t *testing.T) { func TestMigrationWithChannelDB(t *testing.T) {
ctx := context.Background() ctx := t.Context()
// NOTE: comment this line out to run the test. // NOTE: comment this line out to run the test.
t.Skipf("skipping test meant for local debugging only") t.Skipf("skipping test meant for local debugging only")
@@ -923,7 +922,7 @@ func TestMigrationWithChannelDB(t *testing.T) {
// will differ slightly. // will differ slightly.
func TestSQLMigrationEdgeCases(t *testing.T) { func TestSQLMigrationEdgeCases(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
var invalidTLVData = []byte{0x01, 0x02, 0x03} var invalidTLVData = []byte{0x01, 0x02, 0x03}
@@ -1183,7 +1182,7 @@ func TestSQLMigrationEdgeCases(t *testing.T) {
func runTestMigration(t *testing.T, populateKV func(t *testing.T, db *KVStore), func runTestMigration(t *testing.T, populateKV func(t *testing.T, db *KVStore),
expState dbState) { expState dbState) {
ctx := context.Background() ctx := t.Context()
// Set up our source kvdb DB. // Set up our source kvdb DB.
kvDB := setUpKVStore(t) kvDB := setUpKVStore(t)
@@ -1278,7 +1277,7 @@ func TestMigrateGraphToSQLRapid(t *testing.T) {
func testMigrateGraphToSQLRapidOnce(t *testing.T, rt *rapid.T, func testMigrateGraphToSQLRapidOnce(t *testing.T, rt *rapid.T,
dbFixture *sqldb.TestPgFixture, maxNumNodes, maxNumChannels int) { dbFixture *sqldb.TestPgFixture, maxNumNodes, maxNumChannels int) {
ctx := context.Background() ctx := t.Context()
// Set up our source kvdb DB. // Set up our source kvdb DB.
kvDB := setUpKVStore(t) kvDB := setUpKVStore(t)
+7 -8
View File
@@ -2,7 +2,6 @@ package graph
import ( import (
"bytes" "bytes"
"context"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"image/color" "image/color"
@@ -422,7 +421,7 @@ func (m *mockChainView) FilterBlock(blockHash *chainhash.Hash) (*chainview.Filte
// a proper notification is sent of to all registered clients. // a proper notification is sent of to all registered clients.
func TestEdgeUpdateNotification(t *testing.T) { func TestEdgeUpdateNotification(t *testing.T) {
t.Parallel() t.Parallel()
ctxb := context.Background() ctxb := t.Context()
ctx := createTestCtxSingleNode(t, 0) ctx := createTestCtxSingleNode(t, 0)
@@ -611,7 +610,7 @@ func TestEdgeUpdateNotification(t *testing.T) {
// attributes with new data. // attributes with new data.
func TestNodeUpdateNotification(t *testing.T) { func TestNodeUpdateNotification(t *testing.T) {
t.Parallel() t.Parallel()
ctxb := context.Background() ctxb := t.Context()
const startingBlockHeight = 101 const startingBlockHeight = 101
ctx := createTestCtxSingleNode(t, startingBlockHeight) ctx := createTestCtxSingleNode(t, startingBlockHeight)
@@ -795,7 +794,7 @@ func TestNodeUpdateNotification(t *testing.T) {
// when the client wishes to exit. // when the client wishes to exit.
func TestNotificationCancellation(t *testing.T) { func TestNotificationCancellation(t *testing.T) {
t.Parallel() t.Parallel()
ctxb := context.Background() ctxb := t.Context()
const startingBlockHeight = 101 const startingBlockHeight = 101
ctx := createTestCtxSingleNode(t, startingBlockHeight) ctx := createTestCtxSingleNode(t, startingBlockHeight)
@@ -879,7 +878,7 @@ func TestNotificationCancellation(t *testing.T) {
// properly dispatched to all registered clients. // properly dispatched to all registered clients.
func TestChannelCloseNotification(t *testing.T) { func TestChannelCloseNotification(t *testing.T) {
t.Parallel() t.Parallel()
ctxb := context.Background() ctxb := t.Context()
const startingBlockHeight = 101 const startingBlockHeight = 101
ctx := createTestCtxSingleNode(t, startingBlockHeight) ctx := createTestCtxSingleNode(t, startingBlockHeight)
@@ -1067,7 +1066,7 @@ func createTestCtxSingleNode(t *testing.T,
sourceNode := createTestNode(t) sourceNode := createTestNode(t)
require.NoError(t, require.NoError(t,
graph.SetSourceNode(context.Background(), sourceNode), graph.SetSourceNode(t.Context(), sourceNode),
"failed to set source node", "failed to set source node",
) )
@@ -1083,7 +1082,7 @@ func createTestCtxSingleNode(t *testing.T,
func (c *testCtx) RestartBuilder(t *testing.T) { func (c *testCtx) RestartBuilder(t *testing.T) {
c.chainView.Reset() c.chainView.Reset()
selfNode, err := c.graph.SourceNode(context.Background()) selfNode, err := c.graph.SourceNode(t.Context())
require.NoError(t, err) require.NoError(t, err)
// With the chainView reset, we'll now re-create the builder itself, and // With the chainView reset, we'll now re-create the builder itself, and
@@ -1156,7 +1155,7 @@ func createTestCtxFromGraphInstanceAssumeValid(t *testing.T,
ConfChan: make(chan *chainntnfs.TxConfirmation), ConfChan: make(chan *chainntnfs.TxConfirmation),
} }
selfnode, err := graphInstance.graph.SourceNode(context.Background()) selfnode, err := graphInstance.graph.SourceNode(t.Context())
require.NoError(t, err) require.NoError(t, err)
graphBuilder, err := NewBuilder(&Config{ graphBuilder, err := NewBuilder(&Config{
+1 -1
View File
@@ -24,4 +24,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )
go 1.23.12 go 1.24.6
+8 -8
View File
@@ -1801,7 +1801,7 @@ func (l *channelLink) handleUpstreamMsg(ctx context.Context,
case *lnwire.Stfu: case *lnwire.Stfu:
err = l.handleStfu(msg) err = l.handleStfu(msg)
if err != nil { if err != nil {
l.stfuFailf("handleStfu: %v", err.Error()) l.stfuFailf("handleStfu: %v", err)
} }
// In the case where we receive a warning message from our peer, just // In the case where we receive a warning message from our peer, just
@@ -3126,7 +3126,7 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg) {
if err != nil { if err != nil {
l.failf(LinkFailureError{ l.failf(LinkFailureError{
code: ErrInternalError, code: ErrInternalError,
}, err.Error()) //nolint }, "%v", err)
return return
} }
@@ -3795,7 +3795,7 @@ func (l *channelLink) handleQuiescenceReq(req StfuReq) error {
err := l.quiescer.SendOwedStfu() err := l.quiescer.SendOwedStfu()
if err != nil { if err != nil {
l.stfuFailf("SendOwedStfu: %s", err.Error()) l.stfuFailf("SendOwedStfu: %v", err)
res := fn.Err[lntypes.ChannelParty](err) res := fn.Err[lntypes.ChannelParty](err)
req.Resolve(res) req.Resolve(res)
} }
@@ -3989,7 +3989,7 @@ func (l *channelLink) processRemoteUpdateAddHTLC(
FailureAction: LinkFailureDisconnect, FailureAction: LinkFailureDisconnect,
PermanentFailure: false, PermanentFailure: false,
Warning: true, Warning: true,
}, err.Error(), }, "%v", err,
) )
return err return err
@@ -4004,7 +4004,7 @@ func (l *channelLink) processRemoteUpdateAddHTLC(
err := errors.New("blinding point included when route " + err := errors.New("blinding point included when route " +
"blinding is disabled") "blinding is disabled")
l.failf(LinkFailureError{code: ErrInvalidUpdate}, err.Error()) l.failf(LinkFailureError{code: ErrInvalidUpdate}, "%v", err)
return err return err
} }
@@ -4015,7 +4015,7 @@ func (l *channelLink) processRemoteUpdateAddHTLC(
if l.isOverexposedWithHtlc(msg, true) { if l.isOverexposedWithHtlc(msg, true) {
err := errors.New("peer sent us an HTLC that exceeded our " + err := errors.New("peer sent us an HTLC that exceeded our " +
"max fee exposure") "max fee exposure")
l.failf(LinkFailureError{code: ErrInternalError}, err.Error()) l.failf(LinkFailureError{code: ErrInternalError}, "%v", err)
return err return err
} }
@@ -4059,7 +4059,7 @@ func (l *channelLink) processRemoteUpdateFulfillHTLC(
if !lockedin { if !lockedin {
err := errors.New("unable to handle upstream settle") err := errors.New("unable to handle upstream settle")
l.failf(LinkFailureError{code: ErrInvalidUpdate}, err.Error()) l.failf(LinkFailureError{code: ErrInvalidUpdate}, "%v", err)
return err return err
} }
@@ -4367,7 +4367,7 @@ func (l *channelLink) processRemoteCommitSig(ctx context.Context,
if l.noDanglingUpdates(lntypes.Local) { if l.noDanglingUpdates(lntypes.Local) {
err = l.quiescer.SendOwedStfu() err = l.quiescer.SendOwedStfu()
if err != nil { if err != nil {
l.stfuFailf("sendOwedStfu: %v", err.Error()) l.stfuFailf("sendOwedStfu: %v", err)
} }
} }
+1 -1
View File
@@ -95,7 +95,7 @@ func (l *linkTestContext) receiveHtlcAliceToBob() {
func (l *linkTestContext) sendCommitSigBobToAlice(expHtlcs int) { func (l *linkTestContext) sendCommitSigBobToAlice(expHtlcs int) {
l.t.Helper() l.t.Helper()
testQuit, testQuitFunc := context.WithCancel(context.Background()) testQuit, testQuitFunc := context.WithCancel(l.t.Context())
defer testQuitFunc() defer testQuitFunc()
sigs, err := l.bobChannel.SignNextCommitment(testQuit) sigs, err := l.bobChannel.SignNextCommitment(testQuit)
if err != nil { if err != nil {
+23 -23
View File
@@ -498,7 +498,7 @@ func TestChannelLinkSingleHopPayment(t *testing.T) {
// Check that alice invoice was settled and bandwidth of HTLC // Check that alice invoice was settled and bandwidth of HTLC
// links was changed. // links was changed.
invoice, err := receiver.registry.LookupInvoice( invoice, err := receiver.registry.LookupInvoice(
context.Background(), rhash, t.Context(), rhash,
) )
require.NoError(t, err, "unable to get invoice") require.NoError(t, err, "unable to get invoice")
if invoice.State != invpkg.ContractSettled { if invoice.State != invpkg.ContractSettled {
@@ -618,7 +618,7 @@ func testChannelLinkMultiHopPayment(t *testing.T,
// Check that Carol invoice was settled and bandwidth of HTLC // Check that Carol invoice was settled and bandwidth of HTLC
// links were changed. // links were changed.
invoice, err := receiver.registry.LookupInvoice( invoice, err := receiver.registry.LookupInvoice(
context.Background(), rhash, t.Context(), rhash,
) )
require.NoError(t, err, "unable to get invoice") require.NoError(t, err, "unable to get invoice")
if invoice.State != invpkg.ContractSettled { if invoice.State != invpkg.ContractSettled {
@@ -811,7 +811,7 @@ func testChannelLinkInboundFee(t *testing.T, //nolint:thelper
// Check that Carol invoice was settled and bandwidth of HTLC // Check that Carol invoice was settled and bandwidth of HTLC
// links were changed. // links were changed.
invoice, err := receiver.registry.LookupInvoice( invoice, err := receiver.registry.LookupInvoice(
context.Background(), rhash, t.Context(), rhash,
) )
require.NoError(t, err, "unable to get invoice") require.NoError(t, err, "unable to get invoice")
require.Equal(t, invpkg.ContractSettled, invoice.State, require.Equal(t, invpkg.ContractSettled, invoice.State,
@@ -929,7 +929,7 @@ func TestChannelLinkCancelFullCommitment(t *testing.T) {
// to settle. // to settle.
err = wait.NoError(func() error { err = wait.NoError(func() error {
return n.bobServer.registry.SettleHodlInvoice( return n.bobServer.registry.SettleHodlInvoice(
context.Background(), preimage, t.Context(), preimage,
) )
}, time.Minute) }, time.Minute)
if err != nil { if err != nil {
@@ -1397,7 +1397,7 @@ func TestUpdateForwardingPolicy(t *testing.T) {
// Carol's invoice should now be shown as settled as the payment // Carol's invoice should now be shown as settled as the payment
// succeeded. // succeeded.
invoice, err := n.carolServer.registry.LookupInvoice( invoice, err := n.carolServer.registry.LookupInvoice(
context.Background(), payResp, t.Context(), payResp,
) )
require.NoError(t, err, "unable to get invoice") require.NoError(t, err, "unable to get invoice")
if invoice.State != invpkg.ContractSettled { if invoice.State != invpkg.ContractSettled {
@@ -1553,7 +1553,7 @@ func TestChannelLinkMultiHopInsufficientPayment(t *testing.T) {
// Check that alice invoice wasn't settled and bandwidth of htlc // Check that alice invoice wasn't settled and bandwidth of htlc
// links hasn't been changed. // links hasn't been changed.
invoice, err := receiver.registry.LookupInvoice( invoice, err := receiver.registry.LookupInvoice(
context.Background(), rhash, t.Context(), rhash,
) )
require.NoError(t, err, "unable to get invoice") require.NoError(t, err, "unable to get invoice")
if invoice.State == invpkg.ContractSettled { if invoice.State == invpkg.ContractSettled {
@@ -1733,7 +1733,7 @@ func TestChannelLinkMultiHopUnknownNextHop(t *testing.T) {
// Check that alice invoice wasn't settled and bandwidth of htlc // Check that alice invoice wasn't settled and bandwidth of htlc
// links hasn't been changed. // links hasn't been changed.
invoice, err := receiver.registry.LookupInvoice( invoice, err := receiver.registry.LookupInvoice(
context.Background(), rhash, t.Context(), rhash,
) )
require.NoError(t, err, "unable to get invoice") require.NoError(t, err, "unable to get invoice")
if invoice.State == invpkg.ContractSettled { if invoice.State == invpkg.ContractSettled {
@@ -1843,7 +1843,7 @@ func TestChannelLinkMultiHopDecodeError(t *testing.T) {
// Check that alice invoice wasn't settled and bandwidth of htlc // Check that alice invoice wasn't settled and bandwidth of htlc
// links hasn't been changed. // links hasn't been changed.
invoice, err := receiver.registry.LookupInvoice( invoice, err := receiver.registry.LookupInvoice(
context.Background(), rhash, t.Context(), rhash,
) )
require.NoError(t, err, "unable to get invoice") require.NoError(t, err, "unable to get invoice")
if invoice.State == invpkg.ContractSettled { if invoice.State == invpkg.ContractSettled {
@@ -2716,7 +2716,7 @@ func TestChannelLinkBandwidthConsistency(t *testing.T) {
) )
require.NoError(t, err, "unable to create payment") require.NoError(t, err, "unable to create payment")
ctxb := context.Background() ctxb := t.Context()
// We must add the invoice to the registry, such that Alice expects // We must add the invoice to the registry, such that Alice expects
// this payment. // this payment.
err = coreLink.cfg.Registry.(*mockInvoiceRegistry).AddInvoice( err = coreLink.cfg.Registry.(*mockInvoiceRegistry).AddInvoice(
@@ -4067,7 +4067,7 @@ func TestChannelRetransmission(t *testing.T) {
// Check that alice invoice wasn't settled and // Check that alice invoice wasn't settled and
// bandwidth of htlc links hasn't been changed. // bandwidth of htlc links hasn't been changed.
invoice, err = receiver.registry.LookupInvoice( invoice, err = receiver.registry.LookupInvoice(
context.Background(), rhash, t.Context(), rhash,
) )
if err != nil { if err != nil {
err = fmt.Errorf( err = fmt.Errorf(
@@ -4552,7 +4552,7 @@ func TestChannelLinkAcceptDuplicatePayment(t *testing.T) {
} }
err = n.carolServer.registry.AddInvoice( err = n.carolServer.registry.AddInvoice(
context.Background(), *invoice, htlc.PaymentHash, t.Context(), *invoice, htlc.PaymentHash,
) )
require.NoError(t, err, "unable to add invoice in carol registry") require.NoError(t, err, "unable to add invoice in carol registry")
@@ -4642,7 +4642,7 @@ func TestChannelLinkAcceptOverpay(t *testing.T) {
// Even though we sent 2x what was asked for, Carol should still have // Even though we sent 2x what was asked for, Carol should still have
// accepted the payment and marked it as settled. // accepted the payment and marked it as settled.
invoice, err := receiver.registry.LookupInvoice( invoice, err := receiver.registry.LookupInvoice(
context.Background(), rhash, t.Context(), rhash,
) )
require.NoError(t, err, "unable to get invoice") require.NoError(t, err, "unable to get invoice")
if invoice.State != invpkg.ContractSettled { if invoice.State != invpkg.ContractSettled {
@@ -4973,7 +4973,7 @@ func generateHtlc(t *testing.T, coreLink *channelLink,
// We must add the invoice to the registry, such that Alice // We must add the invoice to the registry, such that Alice
// expects this payment. // expects this payment.
err := coreLink.cfg.Registry.(*mockInvoiceRegistry).AddInvoice( err := coreLink.cfg.Registry.(*mockInvoiceRegistry).AddInvoice(
context.Background(), *invoice, htlc.PaymentHash, t.Context(), *invoice, htlc.PaymentHash,
) )
require.NoError(t, err, "unable to add invoice to registry") require.NoError(t, err, "unable to add invoice to registry")
@@ -5933,7 +5933,7 @@ func TestChannelLinkFail(t *testing.T) {
// Sign a commitment that will include // Sign a commitment that will include
// signature for the HTLC just sent. // signature for the HTLC just sent.
quitCtx, done := c.cg.Create( quitCtx, done := c.cg.Create(
context.Background(), t.Context(),
) )
defer done() defer done()
@@ -5982,7 +5982,7 @@ func TestChannelLinkFail(t *testing.T) {
// Sign a commitment that will include // Sign a commitment that will include
// signature for the HTLC just sent. // signature for the HTLC just sent.
quitCtx, done := c.cg.Create( quitCtx, done := c.cg.Create(
context.Background(), t.Context(),
) )
defer done() defer done()
@@ -6388,7 +6388,7 @@ func TestChannelLinkCanceledInvoice(t *testing.T) {
// Cancel the invoice at bob's end. // Cancel the invoice at bob's end.
hash := invoice.Terms.PaymentPreimage.Hash() hash := invoice.Terms.PaymentPreimage.Hash()
err = n.bobServer.registry.CancelInvoice(context.Background(), hash) err = n.bobServer.registry.CancelInvoice(t.Context(), hash)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@@ -6506,7 +6506,7 @@ func TestChannelLinkHoldInvoiceSettle(t *testing.T) {
} }
err = ctx.n.bobServer.registry.SettleHodlInvoice( err = ctx.n.bobServer.registry.SettleHodlInvoice(
context.Background(), ctx.preimage, t.Context(), ctx.preimage,
) )
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@@ -6552,7 +6552,7 @@ func TestChannelLinkHoldInvoiceCancel(t *testing.T) {
} }
err = ctx.n.bobServer.registry.CancelInvoice( err = ctx.n.bobServer.registry.CancelInvoice(
context.Background(), ctx.hash, t.Context(), ctx.hash,
) )
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@@ -6608,7 +6608,7 @@ func TestChannelLinkHoldInvoiceRestart(t *testing.T) {
// We must add the invoice to the registry, such that Alice // We must add the invoice to the registry, such that Alice
// expects this payment. // expects this payment.
err = registry.AddInvoice( err = registry.AddInvoice(
context.Background(), *invoice, htlc.PaymentHash, t.Context(), *invoice, htlc.PaymentHash,
) )
require.NoError(t, err, "unable to add invoice to registry") require.NoError(t, err, "unable to add invoice to registry")
@@ -6644,7 +6644,7 @@ func TestChannelLinkHoldInvoiceRestart(t *testing.T) {
<-registry.settleChan <-registry.settleChan
// Settle the invoice with the preimage. // Settle the invoice with the preimage.
err = registry.SettleHodlInvoice(context.Background(), *preimage) err = registry.SettleHodlInvoice(t.Context(), *preimage)
require.NoError(t, err, "settle hodl invoice") require.NoError(t, err, "settle hodl invoice")
// Expect alice to send a settle and commitsig message to bob. // Expect alice to send a settle and commitsig message to bob.
@@ -6703,7 +6703,7 @@ func TestChannelLinkRevocationWindowRegular(t *testing.T) {
htlc1, invoice1 := generateHtlcAndInvoice(t, 0) htlc1, invoice1 := generateHtlcAndInvoice(t, 0)
htlc2, invoice2 := generateHtlcAndInvoice(t, 1) htlc2, invoice2 := generateHtlcAndInvoice(t, 1)
ctxb := context.Background() ctxb := t.Context()
// We must add the invoice to the registry, such that Alice // We must add the invoice to the registry, such that Alice
// expects this payment. // expects this payment.
err = registry.AddInvoice(ctxb, *invoice1, htlc1.PaymentHash) err = registry.AddInvoice(ctxb, *invoice1, htlc1.PaymentHash)
@@ -6789,7 +6789,7 @@ func TestChannelLinkRevocationWindowHodl(t *testing.T) {
invoice2.Terms.PaymentPreimage = nil invoice2.Terms.PaymentPreimage = nil
invoice2.HodlInvoice = true invoice2.HodlInvoice = true
ctxb := context.Background() ctxb := t.Context()
// We must add the invoices to the registry, such that Alice // We must add the invoices to the registry, such that Alice
// expects the payments. // expects the payments.
err = registry.AddInvoice(ctxb, *invoice1, htlc1.PaymentHash) err = registry.AddInvoice(ctxb, *invoice1, htlc1.PaymentHash)
@@ -7106,7 +7106,7 @@ func TestPipelineSettle(t *testing.T) {
// Add the invoice to Alice's registry so she expects it. // Add the invoice to Alice's registry so she expects it.
aliceReg := alice.coreLink.cfg.Registry.(*mockInvoiceRegistry) aliceReg := alice.coreLink.cfg.Registry.(*mockInvoiceRegistry)
err = aliceReg.AddInvoice( err = aliceReg.AddInvoice(
context.Background(), *invoice1, htlc1.PaymentHash, t.Context(), *invoice1, htlc1.PaymentHash,
) )
require.NoError(t, err) require.NoError(t, err)
+15 -16
View File
@@ -1,7 +1,6 @@
package htlcswitch package htlcswitch
import ( import (
"context"
"crypto/rand" "crypto/rand"
"crypto/sha256" "crypto/sha256"
"errors" "errors"
@@ -1087,11 +1086,11 @@ func TestSwitchForwardFailAfterFullAdd(t *testing.T) {
// Now we will restart bob, leaving the forwarding decision for this // Now we will restart bob, leaving the forwarding decision for this
// htlc is in the half-added state. // htlc is in the half-added state.
if err := s.Stop(); err != nil { if err := s.Stop(); err != nil {
t.Fatalf(err.Error()) t.Fatal(err)
} }
if err := cdb.Close(); err != nil { if err := cdb.Close(); err != nil {
t.Fatalf(err.Error()) t.Fatal(err)
} }
cdb2 := channeldb.OpenForTesting(t, tempPath) cdb2 := channeldb.OpenForTesting(t, tempPath)
@@ -1139,7 +1138,7 @@ func TestSwitchForwardFailAfterFullAdd(t *testing.T) {
// Send the fail packet from the remote peer through the switch. // Send the fail packet from the remote peer through the switch.
if err := s2.ForwardPackets(nil, fail); err != nil { if err := s2.ForwardPackets(nil, fail); err != nil {
t.Fatalf(err.Error()) t.Fatal(err)
} }
// Pull packet from alice's link, as it should have gone through // Pull packet from alice's link, as it should have gone through
@@ -1273,11 +1272,11 @@ func TestSwitchForwardSettleAfterFullAdd(t *testing.T) {
// Now we will restart bob, leaving the forwarding decision for this // Now we will restart bob, leaving the forwarding decision for this
// htlc is in the half-added state. // htlc is in the half-added state.
if err := s.Stop(); err != nil { if err := s.Stop(); err != nil {
t.Fatalf(err.Error()) t.Fatal(err)
} }
if err := cdb.Close(); err != nil { if err := cdb.Close(); err != nil {
t.Fatalf(err.Error()) t.Fatal(err)
} }
cdb2 := channeldb.OpenForTesting(t, tempPath) cdb2 := channeldb.OpenForTesting(t, tempPath)
@@ -1327,7 +1326,7 @@ func TestSwitchForwardSettleAfterFullAdd(t *testing.T) {
// Send the settle packet from the remote peer through the switch. // Send the settle packet from the remote peer through the switch.
if err := s2.ForwardPackets(nil, settle); err != nil { if err := s2.ForwardPackets(nil, settle); err != nil {
t.Fatalf(err.Error()) t.Fatal(err)
} }
// Pull packet from alice's link, as it should have gone through // Pull packet from alice's link, as it should have gone through
@@ -1454,11 +1453,11 @@ func TestSwitchForwardDropAfterFullAdd(t *testing.T) {
// Now we will restart bob, leaving the forwarding decision for this // Now we will restart bob, leaving the forwarding decision for this
// htlc is in the half-added state. // htlc is in the half-added state.
if err := s.Stop(); err != nil { if err := s.Stop(); err != nil {
t.Fatalf(err.Error()) t.Fatal(err)
} }
if err := cdb.Close(); err != nil { if err := cdb.Close(); err != nil {
t.Fatalf(err.Error()) t.Fatal(err)
} }
cdb2 := channeldb.OpenForTesting(t, tempPath) cdb2 := channeldb.OpenForTesting(t, tempPath)
@@ -1601,11 +1600,11 @@ func TestSwitchForwardFailAfterHalfAdd(t *testing.T) {
// Now we will restart bob, leaving the forwarding decision for this // Now we will restart bob, leaving the forwarding decision for this
// htlc is in the half-added state. // htlc is in the half-added state.
if err := s.Stop(); err != nil { if err := s.Stop(); err != nil {
t.Fatalf(err.Error()) t.Fatal(err)
} }
if err := cdb.Close(); err != nil { if err := cdb.Close(); err != nil {
t.Fatalf(err.Error()) t.Fatal(err)
} }
cdb2 := channeldb.OpenForTesting(t, tempPath) cdb2 := channeldb.OpenForTesting(t, tempPath)
@@ -1753,11 +1752,11 @@ func TestSwitchForwardCircuitPersistence(t *testing.T) {
} }
if err := s.Stop(); err != nil { if err := s.Stop(); err != nil {
t.Fatalf(err.Error()) t.Fatal(err)
} }
if err := cdb.Close(); err != nil { if err := cdb.Close(); err != nil {
t.Fatalf(err.Error()) t.Fatal(err)
} }
cdb2 := channeldb.OpenForTesting(t, tempPath) cdb2 := channeldb.OpenForTesting(t, tempPath)
@@ -1847,7 +1846,7 @@ func TestSwitchForwardCircuitPersistence(t *testing.T) {
} }
if err := cdb2.Close(); err != nil { if err := cdb2.Close(); err != nil {
t.Fatalf(err.Error()) t.Fatal(err)
} }
cdb3 := channeldb.OpenForTesting(t, tempPath) cdb3 := channeldb.OpenForTesting(t, tempPath)
@@ -3547,7 +3546,7 @@ func (n *threeHopNetwork) sendThreeHopPayment(t *testing.T) (*lnwire.UpdateAddHT
} }
err = n.carolServer.registry.AddInvoice( err = n.carolServer.registry.AddInvoice(
context.Background(), *invoice, htlc.PaymentHash, t.Context(), *invoice, htlc.PaymentHash,
) )
require.NoError(t, err, "unable to add invoice in carol registry") require.NoError(t, err, "unable to add invoice in carol registry")
@@ -3869,7 +3868,7 @@ func (c *interceptableSwitchTestContext) createTestPacket() *htlcPacket {
func (c *interceptableSwitchTestContext) finish() { func (c *interceptableSwitchTestContext) finish() {
if err := c.s.Stop(); err != nil { if err := c.s.Stop(); err != nil {
c.t.Fatalf(err.Error()) c.t.Fatal(err)
} }
} }
+18 -19
View File
@@ -1,7 +1,6 @@
package invoices_test package invoices_test
import ( import (
"context"
"crypto/rand" "crypto/rand"
"database/sql" "database/sql"
"fmt" "fmt"
@@ -194,7 +193,7 @@ func testSettleInvoice(t *testing.T,
ctx := newTestContext(t, nil, makeDB) ctx := newTestContext(t, nil, makeDB)
ctxb := context.Background() ctxb := t.Context()
allSubscriptions, err := ctx.registry.SubscribeNotifications(ctxb, 0, 0) allSubscriptions, err := ctx.registry.SubscribeNotifications(ctxb, 0, 0)
require.Nil(t, err) require.Nil(t, err)
defer allSubscriptions.Cancel() defer allSubscriptions.Cancel()
@@ -383,7 +382,7 @@ func testCancelInvoiceImpl(t *testing.T, gc bool,
cfg.GcCanceledInvoicesOnTheFly = gc cfg.GcCanceledInvoicesOnTheFly = gc
ctx := newTestContext(t, &cfg, makeDB) ctx := newTestContext(t, &cfg, makeDB)
ctxb := context.Background() ctxb := t.Context()
allSubscriptions, err := ctx.registry.SubscribeNotifications(ctxb, 0, 0) allSubscriptions, err := ctx.registry.SubscribeNotifications(ctxb, 0, 0)
require.Nil(t, err) require.Nil(t, err)
defer allSubscriptions.Cancel() defer allSubscriptions.Cancel()
@@ -547,7 +546,7 @@ func testSettleHoldInvoice(t *testing.T,
require.NoError(t, err) require.NoError(t, err)
defer registry.Stop() defer registry.Stop()
ctxb := context.Background() ctxb := t.Context()
allSubscriptions, err := registry.SubscribeNotifications(ctxb, 0, 0) allSubscriptions, err := registry.SubscribeNotifications(ctxb, 0, 0)
require.Nil(t, err) require.Nil(t, err)
defer allSubscriptions.Cancel() defer allSubscriptions.Cancel()
@@ -720,7 +719,7 @@ func testCancelHoldInvoice(t *testing.T,
require.NoError(t, registry.Stop()) require.NoError(t, registry.Stop())
}) })
ctxb := context.Background() ctxb := t.Context()
// Add the invoice. // Add the invoice.
invoice := newInvoice(t, true, false) invoice := newInvoice(t, true, false)
@@ -824,7 +823,7 @@ func testKeySendImpl(t *testing.T, keySendEnabled bool,
ctx := newTestContext(t, &cfg, makeDB) ctx := newTestContext(t, &cfg, makeDB)
allSubscriptions, err := ctx.registry.SubscribeNotifications( allSubscriptions, err := ctx.registry.SubscribeNotifications(
context.Background(), 0, 0, t.Context(), 0, 0,
) )
require.NoError(t, err) require.NoError(t, err)
defer allSubscriptions.Cancel() defer allSubscriptions.Cancel()
@@ -959,7 +958,7 @@ func testHoldKeysendImpl(t *testing.T, timeoutKeysend bool,
cfg.KeysendHoldTime = holdDuration cfg.KeysendHoldTime = holdDuration
ctx := newTestContext(t, &cfg, makeDB) ctx := newTestContext(t, &cfg, makeDB)
ctxb := context.Background() ctxb := t.Context()
allSubscriptions, err := ctx.registry.SubscribeNotifications(ctxb, 0, 0) allSubscriptions, err := ctx.registry.SubscribeNotifications(ctxb, 0, 0)
require.NoError(t, err) require.NoError(t, err)
defer allSubscriptions.Cancel() defer allSubscriptions.Cancel()
@@ -1047,7 +1046,7 @@ func testMppPayment(t *testing.T,
defer timeout()() defer timeout()()
ctx := newTestContext(t, nil, makeDB) ctx := newTestContext(t, nil, makeDB)
ctxb := context.Background() ctxb := t.Context()
// Add the invoice. // Add the invoice.
testInvoice := newInvoice(t, false, false) testInvoice := newInvoice(t, false, false)
@@ -1143,7 +1142,7 @@ func testMppPaymentWithOverpayment(t *testing.T,
t.Parallel() t.Parallel()
ctxb := context.Background() ctxb := t.Context()
f := func(overpaymentRand uint64) bool { f := func(overpaymentRand uint64) bool {
ctx := newTestContext(t, nil, makeDB) ctx := newTestContext(t, nil, makeDB)
@@ -1241,7 +1240,7 @@ func testInvoiceExpiryWithRegistry(t *testing.T,
t, testTime, 0, numExpired, numPending, t, testTime, 0, numExpired, numPending,
) )
ctxb := context.Background() ctxb := t.Context()
var expectedCancellations []lntypes.Hash var expectedCancellations []lntypes.Hash
expiredInvoices := existingInvoices.expiredInvoices expiredInvoices := existingInvoices.expiredInvoices
@@ -1351,7 +1350,7 @@ func testOldInvoiceRemovalOnStart(t *testing.T,
t, testTime, 0, numExpired, numPending, t, testTime, 0, numExpired, numPending,
) )
ctxb := context.Background() ctxb := t.Context()
i := 0 i := 0
for paymentHash, invoice := range existingInvoices.expiredInvoices { for paymentHash, invoice := range existingInvoices.expiredInvoices {
@@ -1443,7 +1442,7 @@ func testHeightExpiryWithRegistryImpl(t *testing.T, numParts int, settle bool,
testInvoice.HodlInvoice = true testInvoice.HodlInvoice = true
testInvoice.PaymentRequest = []byte{1, 2, 3} testInvoice.PaymentRequest = []byte{1, 2, 3}
ctxb := context.Background() ctxb := t.Context()
_, err := ctx.registry.AddInvoice( _, err := ctx.registry.AddInvoice(
ctxb, testInvoice, testInvoicePaymentHash, ctxb, testInvoice, testInvoicePaymentHash,
) )
@@ -1554,7 +1553,7 @@ func testMultipleSetHeightExpiry(t *testing.T,
// Add a hold invoice. // Add a hold invoice.
testInvoice := newInvoice(t, true, false) testInvoice := newInvoice(t, true, false)
ctxb := context.Background() ctxb := t.Context()
_, err := ctx.registry.AddInvoice( _, err := ctx.registry.AddInvoice(
ctxb, testInvoice, testInvoicePaymentHash, ctxb, testInvoice, testInvoicePaymentHash,
) )
@@ -1646,7 +1645,7 @@ func testSettleInvoicePaymentAddrRequired(t *testing.T,
t.Parallel() t.Parallel()
ctx := newTestContext(t, nil, makeDB) ctx := newTestContext(t, nil, makeDB)
ctxb := context.Background() ctxb := t.Context()
allSubscriptions, err := ctx.registry.SubscribeNotifications(ctxb, 0, 0) allSubscriptions, err := ctx.registry.SubscribeNotifications(ctxb, 0, 0)
require.NoError(t, err) require.NoError(t, err)
@@ -1738,7 +1737,7 @@ func testSettleInvoicePaymentAddrRequiredOptionalGrace(t *testing.T,
t.Parallel() t.Parallel()
ctx := newTestContext(t, nil, makeDB) ctx := newTestContext(t, nil, makeDB)
ctxb := context.Background() ctxb := t.Context()
allSubscriptions, err := ctx.registry.SubscribeNotifications(ctxb, 0, 0) allSubscriptions, err := ctx.registry.SubscribeNotifications(ctxb, 0, 0)
require.NoError(t, err) require.NoError(t, err)
@@ -1946,7 +1945,7 @@ func testSpontaneousAmpPaymentImpl(
cfg := defaultRegistryConfig() cfg := defaultRegistryConfig()
cfg.AcceptAMP = ampEnabled cfg.AcceptAMP = ampEnabled
ctx := newTestContext(t, &cfg, makeDB) ctx := newTestContext(t, &cfg, makeDB)
ctxb := context.Background() ctxb := t.Context()
allSubscriptions, err := ctx.registry.SubscribeNotifications(ctxb, 0, 0) allSubscriptions, err := ctx.registry.SubscribeNotifications(ctxb, 0, 0)
require.Nil(t, err) require.Nil(t, err)
@@ -2132,7 +2131,7 @@ func testFailPartialMPPPaymentExternal(t *testing.T,
// Add an invoice which we are going to pay via a MPP set. // Add an invoice which we are going to pay via a MPP set.
testInvoice := newInvoice(t, false, false) testInvoice := newInvoice(t, false, false)
ctxb := context.Background() ctxb := t.Context()
_, err := ctx.registry.AddInvoice( _, err := ctx.registry.AddInvoice(
ctxb, testInvoice, testInvoicePaymentHash, ctxb, testInvoice, testInvoicePaymentHash,
) )
@@ -2243,7 +2242,7 @@ func testFailPartialAMPPayment(t *testing.T,
t.Parallel() t.Parallel()
ctx := newTestContext(t, nil, makeDB) ctx := newTestContext(t, nil, makeDB)
ctxb := context.Background() ctxb := t.Context()
const ( const (
expiry = uint32(testCurrentHeight + 20) expiry = uint32(testCurrentHeight + 20)
@@ -2449,7 +2448,7 @@ func testCancelAMPInvoicePendingHTLCs(t *testing.T,
t.Parallel() t.Parallel()
ctx := newTestContext(t, nil, makeDB) ctx := newTestContext(t, nil, makeDB)
ctxb := context.Background() ctxb := t.Context()
const ( const (
expiry = uint32(testCurrentHeight + 20) expiry = uint32(testCurrentHeight + 20)
+21 -22
View File
@@ -1,7 +1,6 @@
package invoices_test package invoices_test
import ( import (
"context"
"crypto/rand" "crypto/rand"
"database/sql" "database/sql"
"fmt" "fmt"
@@ -373,7 +372,7 @@ func testInvoiceWorkflowImpl(t *testing.T, test invWorkflowTest,
ref = invpkg.InvoiceRefByHash(payHash) ref = invpkg.InvoiceRefByHash(payHash)
} }
ctxb := context.Background() ctxb := t.Context()
// Add the invoice to the database, this should succeed as there aren't // Add the invoice to the database, this should succeed as there aren't
// any existing invoices within the database with the same payment // any existing invoices within the database with the same payment
// hash. // hash.
@@ -498,7 +497,7 @@ func testAddDuplicatePayAddr(t *testing.T,
require.NoError(t, err) require.NoError(t, err)
invoice2.Terms.PaymentAddr = invoice1.Terms.PaymentAddr invoice2.Terms.PaymentAddr = invoice1.Terms.PaymentAddr
ctxb := context.Background() ctxb := t.Context()
// First insert should succeed. // First insert should succeed.
inv1Hash := invoice1.Terms.PaymentPreimage.Hash() inv1Hash := invoice1.Terms.PaymentPreimage.Hash()
@@ -529,7 +528,7 @@ func testAddDuplicateKeysendPayAddr(t *testing.T,
require.NoError(t, err) require.NoError(t, err)
invoice2.Terms.PaymentAddr = invpkg.BlankPayAddr invoice2.Terms.PaymentAddr = invpkg.BlankPayAddr
ctxb := context.Background() ctxb := t.Context()
// Inserting both should succeed without a duplicate payment address // Inserting both should succeed without a duplicate payment address
// failure. // failure.
@@ -573,7 +572,7 @@ func testFailInvoiceLookupMPPPayAddrOnly(t *testing.T,
payHash := invoice.Terms.PaymentPreimage.Hash() payHash := invoice.Terms.PaymentPreimage.Hash()
payAddr := invoice.Terms.PaymentAddr payAddr := invoice.Terms.PaymentAddr
ctxb := context.Background() ctxb := t.Context()
_, err = db.AddInvoice(ctxb, invoice, payHash) _, err = db.AddInvoice(ctxb, invoice, payHash)
require.NoError(t, err) require.NoError(t, err)
@@ -601,7 +600,7 @@ func testInvRefEquivocation(t *testing.T,
invoice1, err := randInvoice(1000) invoice1, err := randInvoice(1000)
require.NoError(t, err) require.NoError(t, err)
ctxb := context.Background() ctxb := t.Context()
inv1Hash := invoice1.Terms.PaymentPreimage.Hash() inv1Hash := invoice1.Terms.PaymentPreimage.Hash()
_, err = db.AddInvoice(ctxb, invoice1, inv1Hash) _, err = db.AddInvoice(ctxb, invoice1, inv1Hash)
require.NoError(t, err) require.NoError(t, err)
@@ -651,7 +650,7 @@ func testInvoiceCancelSingleHtlc(t *testing.T,
}, },
} }
ctxb := context.Background() ctxb := t.Context()
if _, err := db.AddInvoice(ctxb, testInvoice, paymentHash); err != nil { if _, err := db.AddInvoice(ctxb, testInvoice, paymentHash); err != nil {
t.Fatalf("unable to find invoice: %v", err) t.Fatalf("unable to find invoice: %v", err)
} }
@@ -729,7 +728,7 @@ func testInvoiceCancelSingleHtlcAMP(t *testing.T,
// preimages. // preimages.
invoice.Terms.Features = ampFeatures invoice.Terms.Features = ampFeatures
ctxb := context.Background() ctxb := t.Context()
preimage := *invoice.Terms.PaymentPreimage preimage := *invoice.Terms.PaymentPreimage
payHash := preimage.Hash() payHash := preimage.Hash()
_, err = db.AddInvoice(ctxb, invoice, payHash) _, err = db.AddInvoice(ctxb, invoice, payHash)
@@ -898,7 +897,7 @@ func testInvoiceAddTimeSeries(t *testing.T,
t.Parallel() t.Parallel()
db := makeDB(t) db := makeDB(t)
ctxb := context.Background() ctxb := t.Context()
_, err := db.InvoicesAddedSince(ctxb, 0) _, err := db.InvoicesAddedSince(ctxb, 0)
require.NoError(t, err) require.NoError(t, err)
@@ -1073,7 +1072,7 @@ func testSettleIndexAmpPayments(t *testing.T,
// Add the invoice to the DB, we use a dummy payment hash here but the // Add the invoice to the DB, we use a dummy payment hash here but the
// invoice will have a valid payment address set. // invoice will have a valid payment address set.
ctxb := context.Background() ctxb := t.Context()
preimage := *testInvoice.Terms.PaymentPreimage preimage := *testInvoice.Terms.PaymentPreimage
payHash := preimage.Hash() payHash := preimage.Hash()
_, err = db.AddInvoice(ctxb, testInvoice, payHash) _, err = db.AddInvoice(ctxb, testInvoice, payHash)
@@ -1236,7 +1235,7 @@ func testFetchPendingInvoices(t *testing.T,
t.Parallel() t.Parallel()
db := makeDB(t) db := makeDB(t)
ctxb := context.Background() ctxb := t.Context()
// Make sure that fetching pending invoices from an empty database // Make sure that fetching pending invoices from an empty database
// returns an empty result and no errors. // returns an empty result and no errors.
@@ -1305,7 +1304,7 @@ func testDuplicateSettleInvoice(t *testing.T,
payHash := invoice.Terms.PaymentPreimage.Hash() payHash := invoice.Terms.PaymentPreimage.Hash()
ctxb := context.Background() ctxb := t.Context()
if _, err := db.AddInvoice(ctxb, invoice, payHash); err != nil { if _, err := db.AddInvoice(ctxb, invoice, payHash); err != nil {
t.Fatalf("unable to add invoice %v", err) t.Fatalf("unable to add invoice %v", err)
} }
@@ -1372,7 +1371,7 @@ func testQueryInvoices(t *testing.T,
pendingInvoices []invpkg.Invoice pendingInvoices []invpkg.Invoice
) )
ctxb := context.Background() ctxb := t.Context()
for i := 1; i <= numInvoices; i++ { for i := 1; i <= numInvoices; i++ {
amt := lnwire.MilliSatoshi(i) amt := lnwire.MilliSatoshi(i)
invoice, err := randInvoice(amt) invoice, err := randInvoice(amt)
@@ -1813,7 +1812,7 @@ func testCustomRecords(t *testing.T,
}, },
} }
ctxb := context.Background() ctxb := t.Context()
if _, err := db.AddInvoice(ctxb, testInvoice, paymentHash); err != nil { if _, err := db.AddInvoice(ctxb, testInvoice, paymentHash); err != nil {
t.Fatalf("unable to add invoice: %v", err) t.Fatalf("unable to add invoice: %v", err)
} }
@@ -1893,7 +1892,7 @@ func testInvoiceHtlcAMPFieldsImpl(t *testing.T, isAMP bool,
testInvoice.Terms.Features = ampFeatures testInvoice.Terms.Features = ampFeatures
} }
ctxb := context.Background() ctxb := t.Context()
payHash := testInvoice.Terms.PaymentPreimage.Hash() payHash := testInvoice.Terms.PaymentPreimage.Hash()
_, err = db.AddInvoice(ctxb, testInvoice, payHash) _, err = db.AddInvoice(ctxb, testInvoice, payHash)
require.Nil(t, err) require.Nil(t, err)
@@ -2101,7 +2100,7 @@ func testAddInvoiceWithHTLCs(t *testing.T,
testInvoice.Htlcs[key] = &invpkg.InvoiceHTLC{} testInvoice.Htlcs[key] = &invpkg.InvoiceHTLC{}
payHash := testInvoice.Terms.PaymentPreimage.Hash() payHash := testInvoice.Terms.PaymentPreimage.Hash()
_, err = db.AddInvoice(context.Background(), testInvoice, payHash) _, err = db.AddInvoice(t.Context(), testInvoice, payHash)
require.Equal(t, invpkg.ErrInvoiceHasHtlcs, err) require.Equal(t, invpkg.ErrInvoiceHasHtlcs, err)
} }
@@ -2121,7 +2120,7 @@ func testSetIDIndex(t *testing.T, makeDB func(t *testing.T) invpkg.InvoiceDB) {
// preimages. // preimages.
invoice.Terms.Features = ampFeatures invoice.Terms.Features = ampFeatures
ctxb := context.Background() ctxb := t.Context()
preimage := *invoice.Terms.PaymentPreimage preimage := *invoice.Terms.PaymentPreimage
payHash := preimage.Hash() payHash := preimage.Hash()
_, err = db.AddInvoice(ctxb, invoice, payHash) _, err = db.AddInvoice(ctxb, invoice, payHash)
@@ -2460,7 +2459,7 @@ func testUnexpectedInvoicePreimage(t *testing.T,
invoice, err := randInvoice(lnwire.MilliSatoshi(100)) invoice, err := randInvoice(lnwire.MilliSatoshi(100))
require.NoError(t, err) require.NoError(t, err)
ctxb := context.Background() ctxb := t.Context()
// Add a random invoice indexed by payment hash and payment addr. // Add a random invoice indexed by payment hash and payment addr.
paymentHash := invoice.Terms.PaymentPreimage.Hash() paymentHash := invoice.Terms.PaymentPreimage.Hash()
@@ -2530,7 +2529,7 @@ func testUpdateHTLCPreimagesImpl(t *testing.T, test updateHTLCPreimageTestCase,
// preimages. // preimages.
invoice.Terms.Features = ampFeatures invoice.Terms.Features = ampFeatures
ctxb := context.Background() ctxb := t.Context()
_, err = db.AddInvoice(ctxb, invoice, payHash) _, err = db.AddInvoice(ctxb, invoice, payHash)
require.Nil(t, err) require.Nil(t, err)
@@ -2594,7 +2593,7 @@ func testDeleteInvoices(t *testing.T,
numInvoices := 3 numInvoices := 3
invoicesToDelete := make([]invpkg.InvoiceDeleteRef, numInvoices) invoicesToDelete := make([]invpkg.InvoiceDeleteRef, numInvoices)
ctxb := context.Background() ctxb := t.Context()
for i := 0; i < numInvoices; i++ { for i := 0; i < numInvoices; i++ {
invoice, err := randInvoice(lnwire.MilliSatoshi(i + 1)) invoice, err := randInvoice(lnwire.MilliSatoshi(i + 1))
require.NoError(t, err) require.NoError(t, err)
@@ -2689,7 +2688,7 @@ func testDeleteCanceledInvoices(t *testing.T,
} }
// Test deletion of canceled invoices when there are none. // Test deletion of canceled invoices when there are none.
ctxb := context.Background() ctxb := t.Context()
require.NoError(t, db.DeleteCanceledInvoices(ctxb)) require.NoError(t, db.DeleteCanceledInvoices(ctxb))
// Add some invoices to the test db. // Add some invoices to the test db.
@@ -2750,7 +2749,7 @@ func testAddInvoiceInvalidFeatureDeps(t *testing.T,
) )
hash := invoice.Terms.PaymentPreimage.Hash() hash := invoice.Terms.PaymentPreimage.Hash()
_, err = db.AddInvoice(context.Background(), invoice, hash) _, err = db.AddInvoice(t.Context(), invoice, hash)
require.Error(t, err, feature.NewErrMissingFeatureDep( require.Error(t, err, feature.NewErrMissingFeatureDep(
lnwire.PaymentAddrOptional, lnwire.PaymentAddrOptional,
)) ))
+2 -3
View File
@@ -1,7 +1,6 @@
package invoices_test package invoices_test
import ( import (
"context"
"database/sql" "database/sql"
"os" "os"
"path" "path"
@@ -67,7 +66,7 @@ func TestMigrationWithChannelDB(t *testing.T) {
sqlite bool) { sqlite bool) {
sqlInvoiceStore, sqlStore := makeSQLDB(t, sqlite) sqlInvoiceStore, sqlStore := makeSQLDB(t, sqlite)
ctxb := context.Background() ctxb := t.Context()
const batchSize = 11 const batchSize = 11
err := sqlStore.ExecTx( err := sqlStore.ExecTx(
@@ -163,7 +162,7 @@ func TestMigrationWithChannelDB(t *testing.T) {
sqliteBackend, err := kvdb.Open( sqliteBackend, err := kvdb.Open(
kvdb.SqliteBackendName, kvdb.SqliteBackendName,
context.Background(), t.Context(),
sqliteConfig, test.dbPath, sqliteConfig, test.dbPath,
lncfg.SqliteChannelDBName, lncfg.SqliteChannelDBName,
lncfg.NSChannelDB, lncfg.NSChannelDB,
+1 -2
View File
@@ -1,7 +1,6 @@
package invoices package invoices
import ( import (
"context"
crand "crypto/rand" crand "crypto/rand"
"database/sql" "database/sql"
"math/rand" "math/rand"
@@ -305,7 +304,7 @@ func TestMigrateSingleInvoiceRapid(t *testing.T) {
func testMigrateSingleInvoiceRapid(t *rapid.T, store *SQLStore, mpp bool, func testMigrateSingleInvoiceRapid(t *rapid.T, store *SQLStore, mpp bool,
amp bool) { amp bool) {
ctxb := context.Background() ctxb := t.Context()
invoices := make(map[lntypes.Hash]*Invoice) invoices := make(map[lntypes.Hash]*Invoice)
for i := 0; i < 100; i++ { for i := 0; i < 100; i++ {
+3 -4
View File
@@ -1,7 +1,6 @@
package itest package itest
import ( import (
"context"
"errors" "errors"
"testing" "testing"
@@ -65,7 +64,7 @@ func testChannelFundMaxError(ht *lntest.HarnessTest) {
// Calculate reserve amount for one channel. // Calculate reserve amount for one channel.
reserveResp, _ := alice.RPC.WalletKit.RequiredReserve( reserveResp, _ := alice.RPC.WalletKit.RequiredReserve(
context.Background(), &walletrpc.RequiredReserveRequest{ ht.Context(), &walletrpc.RequiredReserveRequest{
AdditionalPublicChannels: 1, AdditionalPublicChannels: 1,
}, },
) )
@@ -155,7 +154,7 @@ func testChannelFundMaxWalletAmount(ht *lntest.HarnessTest) {
// Calculate reserve amount for one channel. // Calculate reserve amount for one channel.
reserveResp, _ := alice.RPC.WalletKit.RequiredReserve( reserveResp, _ := alice.RPC.WalletKit.RequiredReserve(
context.Background(), &walletrpc.RequiredReserveRequest{ ht.Context(), &walletrpc.RequiredReserveRequest{
AdditionalPublicChannels: 1, AdditionalPublicChannels: 1,
}, },
) )
@@ -220,7 +219,7 @@ func testChannelFundMaxAnchorReserve(ht *lntest.HarnessTest) {
// Calculate reserve amount for one channel. // Calculate reserve amount for one channel.
reserveResp, _ := alice.RPC.WalletKit.RequiredReserve( reserveResp, _ := alice.RPC.WalletKit.RequiredReserve(
context.Background(), &walletrpc.RequiredReserveRequest{ ht.Context(), &walletrpc.RequiredReserveRequest{
AdditionalPublicChannels: 1, AdditionalPublicChannels: 1,
}, },
) )
@@ -1,7 +1,6 @@
package itest package itest
import ( import (
"context"
"errors" "errors"
"fmt" "fmt"
"testing" "testing"
@@ -104,7 +103,7 @@ func testChannelUtxoSelectionError(ht *lntest.HarnessTest) {
// Calculate reserve amount for one channel. // Calculate reserve amount for one channel.
reserveResp, _ := alice.RPC.WalletKit.RequiredReserve( reserveResp, _ := alice.RPC.WalletKit.RequiredReserve(
context.Background(), &walletrpc.RequiredReserveRequest{ ht.Context(), &walletrpc.RequiredReserveRequest{
AdditionalPublicChannels: 1, AdditionalPublicChannels: 1,
}, },
) )
@@ -198,7 +197,7 @@ func testUtxoSelectionSelectedValidChanSize(ht *lntest.HarnessTest) {
// Calculate reserve amount for one channel. // Calculate reserve amount for one channel.
reserveResp, _ := alice.RPC.WalletKit.RequiredReserve( reserveResp, _ := alice.RPC.WalletKit.RequiredReserve(
context.Background(), &walletrpc.RequiredReserveRequest{ ht.Context(), &walletrpc.RequiredReserveRequest{
AdditionalPublicChannels: 1, AdditionalPublicChannels: 1,
}, },
) )
@@ -240,7 +239,7 @@ func testUtxoSelectionSelectedValidChanReserve(ht *lntest.HarnessTest) {
// Calculate reserve amount for one channel. // Calculate reserve amount for one channel.
reserveResp, _ := alice.RPC.WalletKit.RequiredReserve( reserveResp, _ := alice.RPC.WalletKit.RequiredReserve(
context.Background(), &walletrpc.RequiredReserveRequest{ ht.Context(), &walletrpc.RequiredReserveRequest{
AdditionalPublicChannels: 1, AdditionalPublicChannels: 1,
}, },
) )
@@ -281,7 +280,7 @@ func testUtxoSelectionReserveFromSelected(ht *lntest.HarnessTest) {
// Calculate reserve amount for one channel. // Calculate reserve amount for one channel.
reserveResp, _ := alice.RPC.WalletKit.RequiredReserve( reserveResp, _ := alice.RPC.WalletKit.RequiredReserve(
context.Background(), &walletrpc.RequiredReserveRequest{ ht.Context(), &walletrpc.RequiredReserveRequest{
AdditionalPublicChannels: 1, AdditionalPublicChannels: 1,
}, },
) )
@@ -325,7 +324,7 @@ func testUtxoSelectionFundmax(ht *lntest.HarnessTest) {
// Calculate reserve amount for one channel. // Calculate reserve amount for one channel.
reserveResp, _ := alice.RPC.WalletKit.RequiredReserve( reserveResp, _ := alice.RPC.WalletKit.RequiredReserve(
context.Background(), &walletrpc.RequiredReserveRequest{ ht.Context(), &walletrpc.RequiredReserveRequest{
AdditionalPublicChannels: 1, AdditionalPublicChannels: 1,
}, },
) )
@@ -364,7 +363,7 @@ func testUtxoSelectionFundmaxReserve(ht *lntest.HarnessTest) {
// Calculate reserve amount for one channel. // Calculate reserve amount for one channel.
reserveResp, _ := alice.RPC.WalletKit.RequiredReserve( reserveResp, _ := alice.RPC.WalletKit.RequiredReserve(
context.Background(), &walletrpc.RequiredReserveRequest{ ht.Context(), &walletrpc.RequiredReserveRequest{
AdditionalPublicChannels: 1, AdditionalPublicChannels: 1,
}, },
) )
@@ -404,7 +403,7 @@ func testUtxoSelectionReuseUTXO(ht *lntest.HarnessTest) {
// Calculate reserve amount for one channel. // Calculate reserve amount for one channel.
reserveResp, _ := alice.RPC.WalletKit.RequiredReserve( reserveResp, _ := alice.RPC.WalletKit.RequiredReserve(
context.Background(), &walletrpc.RequiredReserveRequest{ ht.Context(), &walletrpc.RequiredReserveRequest{
AdditionalPublicChannels: 1, AdditionalPublicChannels: 1,
}, },
) )
+1 -2
View File
@@ -1,7 +1,6 @@
package itest package itest
import ( import (
"context"
"fmt" "fmt"
"testing" "testing"
@@ -1164,7 +1163,7 @@ func ensurePolicy(ht *lntest.HarnessTest, alice, peer *node.HarnessNode,
channel := ht.AssertChannelExists(peer, chanPoint) channel := ht.AssertChannelExists(peer, chanPoint)
policy, err := peer.RPC.LN.GetChanInfo( policy, err := peer.RPC.LN.GetChanInfo(
context.Background(), &lnrpc.ChanInfoRequest{ ht.Context(), &lnrpc.ChanInfoRequest{
ChanId: channel.ChanId, ChanId: channel.ChanId,
}, },
) )
+1 -1
View File
@@ -21,7 +21,7 @@ func testGraphMigration(ht *lntest.HarnessTest) {
ht.Skip("not running with test_native_sql tag") ht.Skip("not running with test_native_sql tag")
} }
ctx := context.Background() ctx := ht.Context()
alice := ht.NewNodeWithCoins("Alice", nil) alice := ht.NewNodeWithCoins("Alice", nil)
// Make sure we run the test with SQLite or Postgres. // Make sure we run the test with SQLite or Postgres.
+1 -2
View File
@@ -1,7 +1,6 @@
package itest package itest
import ( import (
"context"
"time" "time"
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
@@ -47,7 +46,7 @@ func testInvoiceHtlcModifierBasic(ht *lntest.HarnessTest) {
// Make sure we get an error if we try to register a second modifier and // Make sure we get an error if we try to register a second modifier and
// then try to use it (the error won't be returned on connect, only on // then try to use it (the error won't be returned on connect, only on
// the first _read_ interaction on the stream). // the first _read_ interaction on the stream).
mod2, err := carol.RPC.Invoice.HtlcModifier(context.Background()) mod2, err := carol.RPC.Invoice.HtlcModifier(ht.Context())
require.NoError(ht, err) require.NoError(ht, err)
_, err = mod2.Recv() _, err = mod2.Recv()
require.ErrorContains( require.ErrorContains(
+2 -2
View File
@@ -1400,7 +1400,7 @@ func testGRPCNotFound(ht *lntest.HarnessTest) {
// during a reorg. A reorg notification is produced after a reorg affects the // during a reorg. A reorg notification is produced after a reorg affects the
// block which has produced a spending notification for this registration. // block which has produced a spending notification for this registration.
func testReorgNotifications(ht *lntest.HarnessTest) { func testReorgNotifications(ht *lntest.HarnessTest) {
ctxb := context.Background() ctxb := ht.Context()
const timeout = wait.DefaultTimeout const timeout = wait.DefaultTimeout
alice := ht.NewNodeWithCoins("Alice", nil) alice := ht.NewNodeWithCoins("Alice", nil)
@@ -1599,7 +1599,7 @@ func testReorgNotifications(ht *lntest.HarnessTest) {
func testEstimateFee(ht *lntest.HarnessTest) { func testEstimateFee(ht *lntest.HarnessTest) {
alice := ht.NewNode("Alice", nil) alice := ht.NewNode("Alice", nil)
ctx := context.Background() ctx := ht.Context()
testCases := []struct { testCases := []struct {
name string name string
+1 -1
View File
@@ -1081,7 +1081,7 @@ func sendPaymentInterceptAndCancel(ht *lntest.HarnessTest,
// We initiate a payment from Alice and define the payment context // We initiate a payment from Alice and define the payment context
// cancellable. // cancellable.
ctx, cancelPaymentContext := context.WithCancel(context.Background()) ctx, cancelPaymentContext := context.WithCancel(ht.Context())
var paymentStream rpc.PaymentClient var paymentStream rpc.PaymentClient
go func() { go func() {
req := &routerrpc.SendPaymentRequest{ req := &routerrpc.SendPaymentRequest{
+1 -1
View File
@@ -335,7 +335,7 @@ type blindedForwardTest struct {
func newBlindedForwardTest(ht *lntest.HarnessTest) (context.Context, func newBlindedForwardTest(ht *lntest.HarnessTest) (context.Context,
*blindedForwardTest) { *blindedForwardTest) {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(ht.Context())
return ctx, &blindedForwardTest{ return ctx, &blindedForwardTest{
ht: ht, ht: ht,
+4 -4
View File
@@ -220,7 +220,7 @@ func middlewareInterceptionTest(t *testing.T,
// Everything we test here should be executed in a matter of // Everything we test here should be executed in a matter of
// milliseconds, so we can use one single timeout context for all calls. // milliseconds, so we can use one single timeout context for all calls.
ctxb := context.Background() ctxb := t.Context()
ctxc, cancel := context.WithTimeout(ctxb, defaultTimeout) ctxc, cancel := context.WithTimeout(ctxb, defaultTimeout)
defer cancel() defer cancel()
@@ -372,7 +372,7 @@ func middlewareResponseManipulationTest(t *testing.T,
// Everything we test here should be executed in a matter of // Everything we test here should be executed in a matter of
// milliseconds, so we can use one single timeout context for all calls. // milliseconds, so we can use one single timeout context for all calls.
ctxb := context.Background() ctxb := t.Context()
ctxc, cancel := context.WithTimeout(ctxb, defaultTimeout) ctxc, cancel := context.WithTimeout(ctxb, defaultTimeout)
defer cancel() defer cancel()
@@ -489,7 +489,7 @@ func middlewareRequestManipulationTest(t *testing.T, node *node.HarnessNode,
// Everything we test here should be executed in a matter of // Everything we test here should be executed in a matter of
// milliseconds, so we can use one single timeout context for all calls. // milliseconds, so we can use one single timeout context for all calls.
ctxb := context.Background() ctxb := t.Context()
ctxc, cancel := context.WithTimeout(ctxb, defaultTimeout) ctxc, cancel := context.WithTimeout(ctxb, defaultTimeout)
defer cancel() defer cancel()
@@ -582,7 +582,7 @@ func middlewareMandatoryTest(ht *lntest.HarnessTest, node *node.HarnessNode) {
err = node.WaitUntilServerActive() err = node.WaitUntilServerActive()
require.NoError(ht, err) require.NoError(ht, err)
ctxb := context.Background() ctxb := ht.Context()
ctxc, cancel := context.WithTimeout(ctxb, defaultTimeout) ctxc, cancel := context.WithTimeout(ctxb, defaultTimeout)
defer cancel() defer cancel()
+1 -2
View File
@@ -2,7 +2,6 @@ package itest
import ( import (
"bytes" "bytes"
"context"
"crypto/sha256" "crypto/sha256"
"github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2"
@@ -500,7 +499,7 @@ func runSignVerifyMessage(ht *lntest.HarnessTest, alice *node.HarnessNode) {
expectedErr := "tag can only be used when the Schnorr signature " + expectedErr := "tag can only be used when the Schnorr signature " +
"option is set" "option is set"
ctxt := context.Background() ctxt := ht.Context()
_, err := alice.RPC.Signer.SignMessage(ctxt, signMsgReq) _, err := alice.RPC.Signer.SignMessage(ctxt, signMsgReq)
require.ErrorContains(ht, err, expectedErr) require.ErrorContains(ht, err, expectedErr)
+1 -1
View File
@@ -40,7 +40,7 @@ func TestCommitQueue(t *testing.T) {
} }
} }
ctx := context.Background() ctx := t.Context()
ctx, cancel := context.WithCancel(ctx) ctx, cancel := context.WithCancel(ctx)
q := NewCommitQueue(ctx) q := NewCommitQueue(ctx)
defer q.Stop() defer q.Stop()
+3 -3
View File
@@ -19,7 +19,7 @@ func TestDump(t *testing.T) {
f := NewEtcdTestFixture(t) f := NewEtcdTestFixture(t)
db, err := newEtcdBackend(context.Background(), f.BackendConfig()) db, err := newEtcdBackend(t.Context(), f.BackendConfig())
require.NoError(t, err) require.NoError(t, err)
err = db.Update(func(tx walletdb.ReadWriteTx) error { err = db.Update(func(tx walletdb.ReadWriteTx) error {
@@ -53,7 +53,7 @@ func TestAbortContext(t *testing.T) {
f := NewEtcdTestFixture(t) f := NewEtcdTestFixture(t)
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(t.Context())
config := f.BackendConfig() config := f.BackendConfig()
@@ -83,7 +83,7 @@ func TestNewEtcdClient(t *testing.T) {
f := NewEtcdTestFixture(t) f := NewEtcdTestFixture(t)
client, ctx, cancel, err := NewEtcdClient( client, ctx, cancel, err := NewEtcdClient(
context.Background(), f.BackendConfig(), t.Context(), f.BackendConfig(),
) )
require.NoError(t, err) require.NoError(t, err)
t.Cleanup(cancel) t.Cleanup(cancel)
+2 -3
View File
@@ -4,7 +4,6 @@
package etcd package etcd
import ( import (
"context"
"testing" "testing"
"github.com/btcsuite/btcwallet/walletdb" "github.com/btcsuite/btcwallet/walletdb"
@@ -16,7 +15,7 @@ func TestChangeDuringManualTx(t *testing.T) {
f := NewEtcdTestFixture(t) f := NewEtcdTestFixture(t)
db, err := newEtcdBackend(context.Background(), f.BackendConfig()) db, err := newEtcdBackend(t.Context(), f.BackendConfig())
require.NoError(t, err) require.NoError(t, err)
tx, err := db.BeginReadWriteTx() tx, err := db.BeginReadWriteTx()
@@ -44,7 +43,7 @@ func TestChangeDuringUpdate(t *testing.T) {
f := NewEtcdTestFixture(t) f := NewEtcdTestFixture(t)
db, err := newEtcdBackend(context.Background(), f.BackendConfig()) db, err := newEtcdBackend(t.Context(), f.BackendConfig())
require.NoError(t, err) require.NoError(t, err)
count := 0 count := 0
+5 -5
View File
@@ -23,7 +23,7 @@ func TestPutToEmpty(t *testing.T) {
t.Parallel() t.Parallel()
f := NewEtcdTestFixture(t) f := NewEtcdTestFixture(t)
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(t.Context())
txQueue := NewCommitQueue(ctx) txQueue := NewCommitQueue(ctx)
t.Cleanup(func() { t.Cleanup(func() {
@@ -50,7 +50,7 @@ func TestGetPutDel(t *testing.T) {
t.Parallel() t.Parallel()
f := NewEtcdTestFixture(t) f := NewEtcdTestFixture(t)
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(t.Context())
txQueue := NewCommitQueue(ctx) txQueue := NewCommitQueue(ctx)
t.Cleanup(func() { t.Cleanup(func() {
@@ -151,7 +151,7 @@ func testFirstLastNextPrev(t *testing.T, prefetchKeys []string,
prefetchRange []string, expectedCallCount int) { prefetchRange []string, expectedCallCount int) {
f := NewEtcdTestFixture(t) f := NewEtcdTestFixture(t)
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(t.Context())
txQueue := NewCommitQueue(ctx) txQueue := NewCommitQueue(ctx)
t.Cleanup(func() { t.Cleanup(func() {
@@ -325,7 +325,7 @@ func TestCommitError(t *testing.T) {
t.Parallel() t.Parallel()
f := NewEtcdTestFixture(t) f := NewEtcdTestFixture(t)
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(t.Context())
txQueue := NewCommitQueue(ctx) txQueue := NewCommitQueue(ctx)
t.Cleanup(func() { t.Cleanup(func() {
@@ -374,7 +374,7 @@ func TestManualTxError(t *testing.T) {
t.Parallel() t.Parallel()
f := NewEtcdTestFixture(t) f := NewEtcdTestFixture(t)
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(t.Context())
txQueue := NewCommitQueue(ctx) txQueue := NewCommitQueue(ctx)
t.Cleanup(func() { t.Cleanup(func() {
+1 -2
View File
@@ -4,7 +4,6 @@
package etcd package etcd
import ( import (
"context"
"testing" "testing"
"github.com/btcsuite/btcwallet/walletdb/walletdbtest" "github.com/btcsuite/btcwallet/walletdb/walletdbtest"
@@ -15,5 +14,5 @@ import (
func TestWalletDBInterface(t *testing.T) { func TestWalletDBInterface(t *testing.T) {
f := NewEtcdTestFixture(t) f := NewEtcdTestFixture(t)
cfg := f.BackendConfig() cfg := f.BackendConfig()
walletdbtest.TestInterface(t, dbType, context.Background(), &cfg) walletdbtest.TestInterface(t, dbType, t.Context(), &cfg)
} }
+2 -2
View File
@@ -15,7 +15,6 @@ require (
go.etcd.io/etcd/client/pkg/v3 v3.5.12 go.etcd.io/etcd/client/pkg/v3 v3.5.12
go.etcd.io/etcd/client/v3 v3.5.12 go.etcd.io/etcd/client/v3 v3.5.12
go.etcd.io/etcd/server/v3 v3.5.12 go.etcd.io/etcd/server/v3 v3.5.12
golang.org/x/net v0.39.0
modernc.org/sqlite v1.29.10 modernc.org/sqlite v1.29.10
) )
@@ -118,6 +117,7 @@ require (
golang.org/x/crypto v0.37.0 // indirect golang.org/x/crypto v0.37.0 // indirect
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect
golang.org/x/mod v0.17.0 // indirect golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.39.0 // indirect
golang.org/x/sync v0.13.0 // indirect golang.org/x/sync v0.13.0 // indirect
golang.org/x/sys v0.32.0 // indirect golang.org/x/sys v0.32.0 // indirect
golang.org/x/text v0.24.0 // indirect golang.org/x/text v0.24.0 // indirect
@@ -147,4 +147,4 @@ replace github.com/ulikunitz/xz => github.com/ulikunitz/xz v0.5.11
// https://deps.dev/advisory/OSV/GO-2021-0053?from=%2Fgo%2Fgithub.com%252Fgogo%252Fprotobuf%2Fv1.3.1 // https://deps.dev/advisory/OSV/GO-2021-0053?from=%2Fgo%2Fgithub.com%252Fgogo%252Fprotobuf%2Fv1.3.1
replace github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2 replace github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2
go 1.23.12 go 1.24.6
+1 -2
View File
@@ -9,7 +9,6 @@ import (
"github.com/btcsuite/btcwallet/walletdb" "github.com/btcsuite/btcwallet/walletdb"
"github.com/btcsuite/btcwallet/walletdb/walletdbtest" "github.com/btcsuite/btcwallet/walletdb/walletdbtest"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/net/context"
) )
// TestInterface performs all interfaces tests for this database driver. // TestInterface performs all interfaces tests for this database driver.
@@ -24,7 +23,7 @@ func TestInterface(t *testing.T) {
// dbType is the database type name for this driver. // dbType is the database type name for this driver.
const dbType = "postgres" const dbType = "postgres"
ctx := context.Background() ctx := t.Context()
cfg := &Config{ cfg := &Config{
Dsn: f.Dsn, Dsn: f.Dsn,
} }
+1 -2
View File
@@ -9,14 +9,13 @@ import (
"github.com/btcsuite/btcwallet/walletdb/walletdbtest" "github.com/btcsuite/btcwallet/walletdb/walletdbtest"
"github.com/lightningnetwork/lnd/kvdb/sqlbase" "github.com/lightningnetwork/lnd/kvdb/sqlbase"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/net/context"
) )
// TestInterface performs all interfaces tests for this database driver. // TestInterface performs all interfaces tests for this database driver.
func TestInterface(t *testing.T) { func TestInterface(t *testing.T) {
// dbType is the database type name for this driver. // dbType is the database type name for this driver.
dir := t.TempDir() dir := t.TempDir()
ctx := context.Background() ctx := t.Context()
sqlbase.Init(0) sqlbase.Init(0)
+1 -1
View File
@@ -1,6 +1,6 @@
# If you change this please also update GO_VERSION in Makefile (then run # If you change this please also update GO_VERSION in Makefile (then run
# `make lint` to see where else it needs to be updated as well). # `make lint` to see where else it needs to be updated as well).
FROM golang:1.23.12-bookworm FROM golang:1.24.6-bookworm
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
git \ git \
+1 -1
View File
@@ -6,7 +6,7 @@ set -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# golang docker image version used in this script. # golang docker image version used in this script.
GO_IMAGE=docker.io/library/golang:1.23.12-alpine GO_IMAGE=docker.io/library/golang:1.24.6-alpine
PROTOBUF_VERSION=$(docker run --rm -v $DIR/../:/lnd -w /lnd $GO_IMAGE \ PROTOBUF_VERSION=$(docker run --rm -v $DIR/../:/lnd -w /lnd $GO_IMAGE \
go list -f '{{.Version}}' -m google.golang.org/protobuf) go list -f '{{.Version}}' -m google.golang.org/protobuf)
+1 -2
View File
@@ -2,7 +2,6 @@ package routerrpc
import ( import (
"bytes" "bytes"
"context"
"encoding/hex" "encoding/hex"
"testing" "testing"
"time" "time"
@@ -264,7 +263,7 @@ func testQueryRoutes(t *testing.T, useMissionControl bool, useMsat bool,
backend.MaxTotalTimelock = 1000 backend.MaxTotalTimelock = 1000
} }
resp, err := backend.QueryRoutes(context.Background(), request) resp, err := backend.QueryRoutes(t.Context(), request)
// If we're using both OutgoingChanId and OutgoingChanIds, we should get // If we're using both OutgoingChanId and OutgoingChanIds, we should get
// an error. // an error.
+3 -3
View File
@@ -82,7 +82,7 @@ func TestTrackPaymentsReturnsOnCancelContext(t *testing.T) {
} }
towerMock := makeControlTowerMock() towerMock := makeControlTowerMock()
streamCtx, cancelStream := context.WithCancel(context.Background()) streamCtx, cancelStream := context.WithCancel(t.Context())
stream := makeStreamMock(streamCtx) stream := makeStreamMock(streamCtx)
server := &Server{ server := &Server{
@@ -110,7 +110,7 @@ func TestTrackPaymentsInflightUpdates(t *testing.T) {
} }
towerMock := makeControlTowerMock() towerMock := makeControlTowerMock()
streamCtx, cancelStream := context.WithCancel(context.Background()) streamCtx, cancelStream := context.WithCancel(t.Context())
stream := makeStreamMock(streamCtx) stream := makeStreamMock(streamCtx)
defer cancelStream() defer cancelStream()
@@ -172,7 +172,7 @@ func TestTrackPaymentsNoInflightUpdates(t *testing.T) {
} }
towerMock.queue.Start() towerMock.queue.Start()
streamCtx, cancelStream := context.WithCancel(context.Background()) streamCtx, cancelStream := context.WithCancel(t.Context())
stream := makeStreamMock(streamCtx) stream := makeStreamMock(streamCtx)
defer cancelStream() defer cancelStream()
+1 -1
View File
@@ -5,6 +5,7 @@ package lnrpc
import ( import (
"bufio" "bufio"
"context"
"io" "io"
"net/http" "net/http"
"net/textproto" "net/textproto"
@@ -14,7 +15,6 @@ import (
"github.com/btcsuite/btclog/v2" "github.com/btcsuite/btclog/v2"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"golang.org/x/net/context"
) )
const ( const (
+1 -2
View File
@@ -1,7 +1,6 @@
package lntest package lntest
import ( import (
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
@@ -130,7 +129,7 @@ func (f *FeeService) handleRequest(w http.ResponseWriter, _ *http.Request) {
// Stop stops the web server. // Stop stops the web server.
func (f *FeeService) Stop() error { func (f *FeeService) Stop() error {
err := f.srv.Shutdown(context.Background()) err := f.srv.Shutdown(f.Context())
require.NoError(f, err, "cannot stop fee api") require.NoError(f, err, "cannot stop fee api")
f.wg.Wait() f.wg.Wait()
+6 -4
View File
@@ -147,7 +147,7 @@ func NewHarnessTest(t *testing.T, lndBinary string, feeService WebFeeService,
t.Helper() t.Helper()
// Create the run context. // Create the run context.
ctxt, cancel := context.WithCancel(context.Background()) ctxt, cancel := context.WithCancel(t.Context())
manager := newNodeManager(lndBinary, dbBackend, nativeSQL) manager := newNodeManager(lndBinary, dbBackend, nativeSQL)
@@ -435,9 +435,9 @@ func (h *HarnessTest) shutdownNodesNoAssert() {
// shutdownAllNodes will shutdown all running nodes. // shutdownAllNodes will shutdown all running nodes.
func (h *HarnessTest) shutdownAllNodes() { func (h *HarnessTest) shutdownAllNodes() {
var err error var lastErr error
for _, node := range h.manager.activeNodes { for _, node := range h.manager.activeNodes {
err = h.manager.shutdownNode(node) err := h.manager.shutdownNode(node)
if err == nil { if err == nil {
continue continue
} }
@@ -446,9 +446,11 @@ func (h *HarnessTest) shutdownAllNodes() {
// is needed so other nodes can continue their shutdown // is needed so other nodes can continue their shutdown
// processes. // processes.
h.Logf("unable to shutdown %s, got err: %v", node.Name(), err) h.Logf("unable to shutdown %s, got err: %v", node.Name(), err)
lastErr = err
} }
require.NoError(h, err, "failed to shutdown all nodes") require.NoError(h, lastErr, "failed to shutdown all nodes")
} }
// cleanupStandbyNode is a function should be called with defer whenever a // cleanupStandbyNode is a function should be called with defer whenever a
+16 -14
View File
@@ -115,7 +115,7 @@ func NewHarnessNode(t *testing.T, cfg *BaseNodeConfig) (*HarnessNode, error) {
var dbName string var dbName string
if cfg.DBBackend == BackendPostgres { if cfg.DBBackend == BackendPostgres {
var err error var err error
dbName, err = createTempPgDB() dbName, err = createTempPgDB(t.Context())
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -702,6 +702,11 @@ func (hn *HarnessNode) Stop() error {
// gets closed before a response is returned. // gets closed before a response is returned.
req := lnrpc.StopRequest{} req := lnrpc.StopRequest{}
// We have to use context.Background(), because both hn.Context
// and hn.runCtx have been canceled by this point. We canceled
// hn.runCtx just few lines above. hn.Context() is canceled by
// Go before calling cleanup callbacks; HarnessNode.Stop() is
// called from shutdownAllNodes which is called from a cleanup.
ctxt, cancel := context.WithCancel(context.Background()) ctxt, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
@@ -841,8 +846,8 @@ func (hn *HarnessNode) BackupDB() error {
// Backup database. // Backup database.
backupDBName := hn.Cfg.postgresDBName + "_backup" backupDBName := hn.Cfg.postgresDBName + "_backup"
err := executePgQuery( err := executePgQuery(
"CREATE DATABASE " + backupDBName + " WITH TEMPLATE " + hn.Context(), "CREATE DATABASE "+backupDBName+
hn.Cfg.postgresDBName, " WITH TEMPLATE "+hn.Cfg.postgresDBName,
) )
if err != nil { if err != nil {
return err return err
@@ -872,14 +877,14 @@ func (hn *HarnessNode) RestoreDB() error {
// Restore database. // Restore database.
backupDBName := hn.Cfg.postgresDBName + "_backup" backupDBName := hn.Cfg.postgresDBName + "_backup"
err := executePgQuery( err := executePgQuery(
"DROP DATABASE " + hn.Cfg.postgresDBName, hn.Context(), "DROP DATABASE "+hn.Cfg.postgresDBName,
) )
if err != nil { if err != nil {
return err return err
} }
err = executePgQuery( err = executePgQuery(
"ALTER DATABASE " + backupDBName + " RENAME TO " + hn.Context(), "ALTER DATABASE "+backupDBName+
hn.Cfg.postgresDBName, " RENAME TO "+hn.Cfg.postgresDBName,
) )
if err != nil { if err != nil {
return err return err
@@ -924,7 +929,7 @@ func postgresDatabaseDsn(dbName string) string {
} }
// createTempPgDB creates a temp postgres database. // createTempPgDB creates a temp postgres database.
func createTempPgDB() (string, error) { func createTempPgDB(ctx context.Context) (string, error) {
// Create random database name. // Create random database name.
randBytes := make([]byte, 8) randBytes := make([]byte, 8)
_, err := rand.Read(randBytes) _, err := rand.Read(randBytes)
@@ -934,7 +939,7 @@ func createTempPgDB() (string, error) {
dbName := "itest_" + hex.EncodeToString(randBytes) dbName := "itest_" + hex.EncodeToString(randBytes)
// Create database. // Create database.
err = executePgQuery("CREATE DATABASE " + dbName) err = executePgQuery(ctx, "CREATE DATABASE "+dbName)
if err != nil { if err != nil {
return "", err return "", err
} }
@@ -943,17 +948,14 @@ func createTempPgDB() (string, error) {
} }
// executePgQuery executes a SQL statement in a postgres db. // executePgQuery executes a SQL statement in a postgres db.
func executePgQuery(query string) error { func executePgQuery(ctx context.Context, query string) error {
pool, err := pgxpool.Connect( pool, err := pgxpool.Connect(ctx, postgresDatabaseDsn("postgres"))
context.Background(),
postgresDatabaseDsn("postgres"),
)
if err != nil { if err != nil {
return fmt.Errorf("unable to connect to database: %w", err) return fmt.Errorf("unable to connect to database: %w", err)
} }
defer pool.Close() defer pool.Close()
_, err = pool.Exec(context.Background(), query) _, err = pool.Exec(ctx, query)
return err return err
} }
+11 -11
View File
@@ -153,7 +153,7 @@ func assertUnknownEventFail(t *testing.T, startingState ProtocolState) {
defer closeHarness.stopAndAssert() defer closeHarness.stopAndAssert()
closeHarness.sendEventAndExpectFailure( closeHarness.sendEventAndExpectFailure(
context.Background(), &unknownEvent{}, t.Context(), &unknownEvent{},
ErrInvalidStateTransition, ErrInvalidStateTransition,
) )
}) })
@@ -173,7 +173,7 @@ func assertSpendEventCloseFin(t *testing.T, startingState ProtocolState) {
defer closeHarness.stopAndAssert() defer closeHarness.stopAndAssert()
closeHarness.chanCloser.SendEvent( closeHarness.chanCloser.SendEvent(
context.Background(), &SpendEvent{}, t.Context(), &SpendEvent{},
) )
closeHarness.assertStateTransitions(&CloseFin{}) closeHarness.assertStateTransitions(&CloseFin{})
@@ -539,7 +539,7 @@ func (r *rbfCloserTestHarness) expectHalfSignerIteration(
initEvent ProtocolEvent, balanceAfterClose, absoluteFee btcutil.Amount, initEvent ProtocolEvent, balanceAfterClose, absoluteFee btcutil.Amount,
dustExpect dustExpectation, iteration bool) { dustExpect dustExpectation, iteration bool) {
ctx := context.Background() ctx := r.T.Context()
numFeeCalls := 2 numFeeCalls := 2
// If we're using the SendOfferEvent as a trigger, we only need to call // If we're using the SendOfferEvent as a trigger, we only need to call
@@ -645,7 +645,7 @@ func (r *rbfCloserTestHarness) assertSingleRbfIteration(
initEvent ProtocolEvent, balanceAfterClose, absoluteFee btcutil.Amount, initEvent ProtocolEvent, balanceAfterClose, absoluteFee btcutil.Amount,
dustExpect dustExpectation, iteration bool) { dustExpect dustExpectation, iteration bool) {
ctx := context.Background() ctx := r.T.Context()
// We'll now send in the send offer event, which should trigger 1/2 of // We'll now send in the send offer event, which should trigger 1/2 of
// the RBF loop, ending us in the LocalOfferSent state. // the RBF loop, ending us in the LocalOfferSent state.
@@ -686,7 +686,7 @@ func (r *rbfCloserTestHarness) assertSingleRemoteRbfIteration(
absoluteFee btcutil.Amount, sequence uint32, iteration bool, absoluteFee btcutil.Amount, sequence uint32, iteration bool,
sendInit bool) { sendInit bool) {
ctx := context.Background() ctx := r.T.Context()
// When we receive the signature below, our local state machine should // When we receive the signature below, our local state machine should
// move to finalize the close. // move to finalize the close.
@@ -744,7 +744,7 @@ func assertStateT[T ProtocolState](h *rbfCloserTestHarness) T {
func newRbfCloserTestHarness(t *testing.T, func newRbfCloserTestHarness(t *testing.T,
cfg *harnessCfg) *rbfCloserTestHarness { cfg *harnessCfg) *rbfCloserTestHarness {
ctx := context.Background() ctx := t.Context()
startingHeight := 200 startingHeight := 200
@@ -850,7 +850,7 @@ func newCloser(t *testing.T, cfg *harnessCfg) *rbfCloserTestHarness {
// TestRbfChannelActiveTransitions tests the transitions of from the // TestRbfChannelActiveTransitions tests the transitions of from the
// ChannelActive state. // ChannelActive state.
func TestRbfChannelActiveTransitions(t *testing.T) { func TestRbfChannelActiveTransitions(t *testing.T) {
ctx := context.Background() ctx := t.Context()
localAddr := lnwire.DeliveryAddress(bytes.Repeat([]byte{0x01}, 20)) localAddr := lnwire.DeliveryAddress(bytes.Repeat([]byte{0x01}, 20))
remoteAddr := lnwire.DeliveryAddress(bytes.Repeat([]byte{0x02}, 20)) remoteAddr := lnwire.DeliveryAddress(bytes.Repeat([]byte{0x02}, 20))
@@ -1001,7 +1001,7 @@ func TestRbfChannelActiveTransitions(t *testing.T) {
// shutdown ourselves. // shutdown ourselves.
func TestRbfShutdownPendingTransitions(t *testing.T) { func TestRbfShutdownPendingTransitions(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
startingState := &ShutdownPending{} startingState := &ShutdownPending{}
@@ -1229,7 +1229,7 @@ func TestRbfShutdownPendingTransitions(t *testing.T) {
// transition to the negotiation state. // transition to the negotiation state.
func TestRbfChannelFlushingTransitions(t *testing.T) { func TestRbfChannelFlushingTransitions(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
localBalance := lnwire.NewMSatFromSatoshis(10_000) localBalance := lnwire.NewMSatFromSatoshis(10_000)
remoteBalance := lnwire.NewMSatFromSatoshis(50_000) remoteBalance := lnwire.NewMSatFromSatoshis(50_000)
@@ -1406,7 +1406,7 @@ func TestRbfChannelFlushingTransitions(t *testing.T) {
// rate. // rate.
func TestRbfCloseClosingNegotiationLocal(t *testing.T) { func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
localBalance := lnwire.NewMSatFromSatoshis(40_000) localBalance := lnwire.NewMSatFromSatoshis(40_000)
remoteBalance := lnwire.NewMSatFromSatoshis(50_000) remoteBalance := lnwire.NewMSatFromSatoshis(50_000)
@@ -1687,7 +1687,7 @@ func TestRbfCloseClosingNegotiationLocal(t *testing.T) {
func TestRbfCloseClosingNegotiationRemote(t *testing.T) { func TestRbfCloseClosingNegotiationRemote(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
localBalance := lnwire.NewMSatFromSatoshis(40_000) localBalance := lnwire.NewMSatFromSatoshis(40_000)
remoteBalance := lnwire.NewMSatFromSatoshis(50_000) remoteBalance := lnwire.NewMSatFromSatoshis(50_000)
+1 -1
View File
@@ -662,7 +662,7 @@ func TestCoinSelectSubtractFees(t *testing.T) {
if err != nil { if err != nil {
switch { switch {
case test.expectErr == "": case test.expectErr == "":
t.Fatalf(err.Error()) t.Fatal(err)
case test.expectErr != removeAmounts(err.Error()): case test.expectErr != removeAmounts(err.Error()):
t.Fatalf("expected error '%v', got '%v'", t.Fatalf("expected error '%v', got '%v'",
+1 -1
View File
@@ -3836,7 +3836,7 @@ func TestQuitDuringSignNextCommitment(t *testing.T) {
) )
quitDelay := time.Millisecond * 20 quitDelay := time.Millisecond * 20
quit, quitFunc := context.WithCancel(context.Background()) quit, quitFunc := context.WithCancel(t.Context())
// Alice's channel will be stuck waiting for aux sig job responses until // Alice's channel will be stuck waiting for aux sig job responses until
// we send the quit signal. We add an explicit sleep here so that we can // we send the quit signal. We add an explicit sleep here so that we can
+1 -1
View File
@@ -2,9 +2,9 @@ package macaroons
import ( import (
"bytes" "bytes"
"context"
"fmt" "fmt"
"golang.org/x/net/context"
"gopkg.in/macaroon-bakery.v2/bakery" "gopkg.in/macaroon-bakery.v2/bakery"
"gopkg.in/macaroon.v2" "gopkg.in/macaroon.v2"
) )
+1 -2
View File
@@ -1,7 +1,6 @@
package macaroons_test package macaroons_test
import ( import (
"context"
"encoding/hex" "encoding/hex"
"testing" "testing"
@@ -49,7 +48,7 @@ func TestBakeFromRootKey(t *testing.T) {
md := metadata.New(map[string]string{ md := metadata.New(map[string]string{
"macaroon": hex.EncodeToString(macaroonBytes), "macaroon": hex.EncodeToString(macaroonBytes),
}) })
macCtx := metadata.NewIncomingContext(context.Background(), md) macCtx := metadata.NewIncomingContext(t.Context(), md)
// The macaroon should be valid for the service, since the root key was // The macaroon should be valid for the service, since the root key was
// the same. // the same.
+4 -3
View File
@@ -136,7 +136,8 @@ func IPLockChecker() (string, checkers.Func) {
// check. // check.
pr, ok := peer.FromContext(ctx) pr, ok := peer.FromContext(ctx)
if !ok { if !ok {
return fmt.Errorf("unable to get peer info from context") return fmt.Errorf("unable to get peer info from " +
"context")
} }
peerAddr, _, err := net.SplitHostPort(pr.Addr.String()) peerAddr, _, err := net.SplitHostPort(pr.Addr.String())
if err != nil { if err != nil {
@@ -144,8 +145,8 @@ func IPLockChecker() (string, checkers.Func) {
} }
if !net.ParseIP(arg).Equal(net.ParseIP(peerAddr)) { if !net.ParseIP(arg).Equal(net.ParseIP(peerAddr)) {
msg := "macaroon locked to different IP address" return fmt.Errorf("macaroon locked to different IP " +
return fmt.Errorf(msg) "address")
} }
return nil return nil
} }
+1 -2
View File
@@ -1,7 +1,6 @@
package macaroons package macaroons
import ( import (
"context"
"testing" "testing"
"gopkg.in/macaroon-bakery.v2/bakery" "gopkg.in/macaroon-bakery.v2/bakery"
@@ -17,7 +16,7 @@ func FuzzUnmarshalMacaroon(f *testing.F) {
func FuzzAuthChecker(f *testing.F) { func FuzzAuthChecker(f *testing.F) {
rootKeyStore := bakery.NewMemRootKeyStore() rootKeyStore := bakery.NewMemRootKeyStore()
ctx := context.Background() ctx := f.Context()
f.Fuzz(func(t *testing.T, location, entity, action, method string, f.Fuzz(func(t *testing.T, location, entity, action, method string,
rootKey, id []byte) { rootKey, id []byte) {
+5 -6
View File
@@ -1,7 +1,6 @@
package macaroons_test package macaroons_test
import ( import (
"context"
"encoding/hex" "encoding/hex"
"path" "path"
"testing" "testing"
@@ -55,7 +54,7 @@ func setupTestRootKeyStorage(t *testing.T) kvdb.Backend {
// TestNewService tests the creation of the macaroon service. // TestNewService tests the creation of the macaroon service.
func TestNewService(t *testing.T) { func TestNewService(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// First, initialize a dummy DB file with a store that the service // First, initialize a dummy DB file with a store that the service
// can read from. Make sure the file is removed in the end. // can read from. Make sure the file is removed in the end.
@@ -109,7 +108,7 @@ func TestNewService(t *testing.T) {
// incoming context. // incoming context.
func TestValidateMacaroon(t *testing.T) { func TestValidateMacaroon(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// First, initialize the service and unlock it. // First, initialize the service and unlock it.
db := setupTestRootKeyStorage(t) db := setupTestRootKeyStorage(t)
@@ -157,7 +156,7 @@ func TestValidateMacaroon(t *testing.T) {
// TestListMacaroonIDs checks that ListMacaroonIDs returns the expected result. // TestListMacaroonIDs checks that ListMacaroonIDs returns the expected result.
func TestListMacaroonIDs(t *testing.T) { func TestListMacaroonIDs(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// First, initialize a dummy DB file with a store that the service // First, initialize a dummy DB file with a store that the service
// can read from. Make sure the file is removed in the end. // can read from. Make sure the file is removed in the end.
@@ -192,7 +191,7 @@ func TestListMacaroonIDs(t *testing.T) {
func TestDeleteMacaroonID(t *testing.T) { func TestDeleteMacaroonID(t *testing.T) {
t.Parallel() t.Parallel()
ctxb := context.Background() ctxb := t.Context()
// First, initialize a dummy DB file with a store that the service // First, initialize a dummy DB file with a store that the service
// can read from. Make sure the file is removed in the end. // can read from. Make sure the file is removed in the end.
@@ -308,7 +307,7 @@ func TestCloneMacaroons(t *testing.T) {
func TestMacaroonVersionDecode(t *testing.T) { func TestMacaroonVersionDecode(t *testing.T) {
t.Parallel() t.Parallel()
ctxb := context.Background() ctxb := t.Context()
// First, initialize a dummy DB file with a store that the service // First, initialize a dummy DB file with a store that the service
// can read from. Make sure the file is removed in the end. // can read from. Make sure the file is removed in the end.
+1 -1
View File
@@ -59,7 +59,7 @@ func openTestStore(t *testing.T, tempDir string) *macaroons.RootKeyStorage {
// reading keys and closing it. // reading keys and closing it.
func TestStore(t *testing.T) { func TestStore(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
tempDir, store := newTestStore(t) tempDir, store := newTestStore(t)
+1 -1
View File
@@ -1,6 +1,6 @@
# If you change this please also update GO_VERSION in Makefile (then run # If you change this please also update GO_VERSION in Makefile (then run
# `make lint` to see where else it needs to be updated as well). # `make lint` to see where else it needs to be updated as well).
FROM golang:1.23.12-bookworm FROM golang:1.24.6-bookworm
MAINTAINER Olaoluwa Osuntokun <laolu@lightning.engineering> MAINTAINER Olaoluwa Osuntokun <laolu@lightning.engineering>
+1 -1
View File
@@ -34,7 +34,7 @@ func (m *mockEndpoint) SendMessage(ctx context.Context, msg PeerMsg) bool {
// TestMessageRouterOperation tests the basic operation of the message router: // TestMessageRouterOperation tests the basic operation of the message router:
// add new endpoints, route to them, remove, them, etc. // add new endpoints, route to them, remove, them, etc.
func TestMessageRouterOperation(t *testing.T) { func TestMessageRouterOperation(t *testing.T) {
ctx := context.Background() ctx := t.Context()
msgRouter := NewMultiMsgRouter() msgRouter := NewMultiMsgRouter()
msgRouter.Start(ctx) msgRouter.Start(ctx)
defer msgRouter.Stop() defer msgRouter.Stop()
+1 -2
View File
@@ -2,7 +2,6 @@ package paymentsdb
import ( import (
"bytes" "bytes"
"context"
"math" "math"
"reflect" "reflect"
"testing" "testing"
@@ -932,7 +931,7 @@ func TestQueryPayments(t *testing.T) {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
paymentDB := NewKVTestDB(t) paymentDB := NewKVTestDB(t)
+1 -2
View File
@@ -1,7 +1,6 @@
package paymentsdb package paymentsdb
import ( import (
"context"
"crypto/rand" "crypto/rand"
"crypto/sha256" "crypto/sha256"
"errors" "errors"
@@ -304,7 +303,7 @@ func assertDBPayments(t *testing.T, paymentDB DB, payments []*payment) {
t.Helper() t.Helper()
response, err := paymentDB.QueryPayments( response, err := paymentDB.QueryPayments(
context.Background(), Query{ t.Context(), Query{
IndexOffset: 0, IndexOffset: 0,
MaxPayments: uint64(len(payments)), MaxPayments: uint64(len(payments)),
IncludeIncomplete: true, IncludeIncomplete: true,
+6 -7
View File
@@ -1,7 +1,6 @@
package protofsm package protofsm
import ( import (
"context"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"sync/atomic" "sync/atomic"
@@ -410,7 +409,7 @@ func (d *dummyAdapters) RegisterSpendNtfn(outpoint *wire.OutPoint,
// TestStateMachineOnInitDaemonEvent tests that the state machine will properly // TestStateMachineOnInitDaemonEvent tests that the state machine will properly
// execute any init-level daemon events passed into it. // execute any init-level daemon events passed into it.
func TestStateMachineOnInitDaemonEvent(t *testing.T) { func TestStateMachineOnInitDaemonEvent(t *testing.T) {
ctx := context.Background() ctx := t.Context()
// First, we'll create our state machine given the env, and our // First, we'll create our state machine given the env, and our
// starting state. // starting state.
@@ -464,7 +463,7 @@ func TestStateMachineOnInitDaemonEvent(t *testing.T) {
// transition. // transition.
func TestStateMachineInternalEvents(t *testing.T) { func TestStateMachineInternalEvents(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// First, we'll create our state machine given the env, and our // First, we'll create our state machine given the env, and our
// starting state. // starting state.
@@ -513,7 +512,7 @@ func TestStateMachineInternalEvents(t *testing.T) {
// daemon emitted as part of the state transition process. // daemon emitted as part of the state transition process.
func TestStateMachineDaemonEvents(t *testing.T) { func TestStateMachineDaemonEvents(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// First, we'll create our state machine given the env, and our // First, we'll create our state machine given the env, and our
// starting state. // starting state.
@@ -598,7 +597,7 @@ func TestStateMachineDaemonEvents(t *testing.T) {
// scenario where full block details are requested in the confirmation // scenario where full block details are requested in the confirmation
// notification. // notification.
func testStateMachineConfMapperImpl(t *testing.T, fullBlock bool) { func testStateMachineConfMapperImpl(t *testing.T, fullBlock bool) {
ctx := context.Background() ctx := t.Context()
// Create the state machine. // Create the state machine.
env := &dummyEnv{} env := &dummyEnv{}
@@ -722,7 +721,7 @@ func TestStateMachineConfMapper(t *testing.T) {
// transition. // transition.
func TestStateMachineSpendMapper(t *testing.T) { func TestStateMachineSpendMapper(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
// Create the state machine. // Create the state machine.
env := &dummyEnv{} env := &dummyEnv{}
@@ -808,7 +807,7 @@ func (d *dummyMsgMapper) MapMsg(wireMsg msgmux.PeerMsg) fn.Option[dummyEvents] {
// TestStateMachineMsgMapper tests that given a message mapper, we can properly // TestStateMachineMsgMapper tests that given a message mapper, we can properly
// send in wire messages get mapped to FSM events. // send in wire messages get mapped to FSM events.
func TestStateMachineMsgMapper(t *testing.T) { func TestStateMachineMsgMapper(t *testing.T) {
ctx := context.Background() ctx := t.Context()
// First, we'll create our state machine given the env, and our // First, we'll create our state machine given the env, and our
// starting state. // starting state.
+1 -1
View File
@@ -317,7 +317,7 @@ func TestManager(t *testing.T) {
expectedNumUpdates = test.expectedNumUpdates expectedNumUpdates = test.expectedNumUpdates
failedUpdates, err := manager.UpdatePolicy( failedUpdates, err := manager.UpdatePolicy(
context.Background(), t.Context(),
test.newPolicy, test.newPolicy,
test.createMissingEdge, test.createMissingEdge,
test.specifiedChanPoints...) test.specifiedChanPoints...)
+13 -13
View File
@@ -184,7 +184,7 @@ func makeTestGraph(t *testing.T, useCache bool) (*graphdb.ChannelGraph,
func parseTestGraph(t *testing.T, useCache bool, path string) ( func parseTestGraph(t *testing.T, useCache bool, path string) (
*testGraphInstance, error) { *testGraphInstance, error) {
ctx := context.Background() ctx := t.Context()
graphJSON, err := os.ReadFile(path) graphJSON, err := os.ReadFile(path)
if err != nil { if err != nil {
@@ -526,7 +526,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
testChannels []*testChannel, source string, testChannels []*testChannel, source string,
sourceFeatureBits ...lnwire.FeatureBit) (*testGraphInstance, error) { sourceFeatureBits ...lnwire.FeatureBit) (*testGraphInstance, error) {
ctx := context.Background() ctx := t.Context()
// We'll use this fake address for the IP address of all the nodes in // We'll use this fake address for the IP address of all the nodes in
// our tests. This value isn't needed for path finding so it doesn't // our tests. This value isn't needed for path finding so it doesn't
@@ -1090,7 +1090,7 @@ func runBasicGraphPathFinding(t *testing.T, useCache bool) {
func testBasicGraphPathFindingCase(t *testing.T, graphInstance *testGraphInstance, func testBasicGraphPathFindingCase(t *testing.T, graphInstance *testGraphInstance,
test *basicGraphPathFindingTestCase) { test *basicGraphPathFindingTestCase) {
ctx := context.Background() ctx := t.Context()
aliases := graphInstance.aliasMap aliases := graphInstance.aliasMap
expectedHops := test.expectedHops expectedHops := test.expectedHops
expectedHopCount := len(expectedHops) expectedHopCount := len(expectedHops)
@@ -1235,7 +1235,7 @@ func runPathFindingWithAdditionalEdges(t *testing.T, useCache bool) {
graph, err := parseTestGraph(t, useCache, basicGraphFilePath) graph, err := parseTestGraph(t, useCache, basicGraphFilePath)
require.NoError(t, err, "unable to create graph") require.NoError(t, err, "unable to create graph")
ctx := context.Background() ctx := t.Context()
sourceNode, err := graph.graph.SourceNode(ctx) sourceNode, err := graph.graph.SourceNode(ctx)
require.NoError(t, err, "unable to fetch source node") require.NoError(t, err, "unable to fetch source node")
@@ -1320,7 +1320,7 @@ func runPathFindingWithBlindedPathDuplicateHop(t *testing.T, useCache bool) {
graph, err := parseTestGraph(t, useCache, basicGraphFilePath) graph, err := parseTestGraph(t, useCache, basicGraphFilePath)
require.NoError(t, err, "unable to create graph") require.NoError(t, err, "unable to create graph")
ctx := context.Background() ctx := t.Context()
sourceNode, err := graph.graph.SourceNode(ctx) sourceNode, err := graph.graph.SourceNode(ctx)
require.NoError(t, err, "unable to fetch source node") require.NoError(t, err, "unable to fetch source node")
@@ -1807,7 +1807,7 @@ func runPathNotAvailable(t *testing.T, useCache bool) {
graph, err := parseTestGraph(t, useCache, basicGraphFilePath) graph, err := parseTestGraph(t, useCache, basicGraphFilePath)
require.NoError(t, err, "unable to create graph") require.NoError(t, err, "unable to create graph")
ctx := context.Background() ctx := t.Context()
sourceNode, err := graph.graph.SourceNode(ctx) sourceNode, err := graph.graph.SourceNode(ctx)
require.NoError(t, err, "unable to fetch source node") require.NoError(t, err, "unable to fetch source node")
@@ -1865,7 +1865,7 @@ func runDestTLVGraphFallback(t *testing.T, useCache bool) {
ctx := newPathFindingTestContext(t, useCache, testChannels, "roasbeef") ctx := newPathFindingTestContext(t, useCache, testChannels, "roasbeef")
sourceNode, err := ctx.graph.SourceNode(context.Background()) sourceNode, err := ctx.graph.SourceNode(t.Context())
require.NoError(t, err, "unable to fetch source node") require.NoError(t, err, "unable to fetch source node")
find := func(r *RestrictParams, find := func(r *RestrictParams,
@@ -2083,7 +2083,7 @@ func runPathInsufficientCapacity(t *testing.T, useCache bool) {
graph, err := parseTestGraph(t, useCache, basicGraphFilePath) graph, err := parseTestGraph(t, useCache, basicGraphFilePath)
require.NoError(t, err, "unable to create graph") require.NoError(t, err, "unable to create graph")
ctx := context.Background() ctx := t.Context()
sourceNode, err := graph.graph.SourceNode(ctx) sourceNode, err := graph.graph.SourceNode(ctx)
require.NoError(t, err, "unable to fetch source node") require.NoError(t, err, "unable to fetch source node")
@@ -2114,7 +2114,7 @@ func runRouteFailMinHTLC(t *testing.T, useCache bool) {
graph, err := parseTestGraph(t, useCache, basicGraphFilePath) graph, err := parseTestGraph(t, useCache, basicGraphFilePath)
require.NoError(t, err, "unable to create graph") require.NoError(t, err, "unable to create graph")
ctx := context.Background() ctx := t.Context()
sourceNode, err := graph.graph.SourceNode(ctx) sourceNode, err := graph.graph.SourceNode(ctx)
require.NoError(t, err, "unable to fetch source node") require.NoError(t, err, "unable to fetch source node")
@@ -2179,7 +2179,7 @@ func runRouteFailMaxHTLC(t *testing.T, useCache bool) {
midEdge.MessageFlags = 1 midEdge.MessageFlags = 1
midEdge.MaxHTLC = payAmt - 1 midEdge.MaxHTLC = payAmt - 1
midEdge.LastUpdate = midEdge.LastUpdate.Add(time.Second) midEdge.LastUpdate = midEdge.LastUpdate.Add(time.Second)
err = graph.UpdateEdgePolicy(context.Background(), midEdge) err = graph.UpdateEdgePolicy(t.Context(), midEdge)
require.NoError(t, err) require.NoError(t, err)
// We'll now attempt to route through that edge with a payment above // We'll now attempt to route through that edge with a payment above
@@ -2199,7 +2199,7 @@ func runRouteFailDisabledEdge(t *testing.T, useCache bool) {
graph, err := parseTestGraph(t, useCache, basicGraphFilePath) graph, err := parseTestGraph(t, useCache, basicGraphFilePath)
require.NoError(t, err, "unable to create graph") require.NoError(t, err, "unable to create graph")
ctx := context.Background() ctx := t.Context()
sourceNode, err := graph.graph.SourceNode(ctx) sourceNode, err := graph.graph.SourceNode(ctx)
require.NoError(t, err, "unable to fetch source node") require.NoError(t, err, "unable to fetch source node")
@@ -2268,7 +2268,7 @@ func runPathSourceEdgesBandwidth(t *testing.T, useCache bool) {
graph, err := parseTestGraph(t, useCache, basicGraphFilePath) graph, err := parseTestGraph(t, useCache, basicGraphFilePath)
require.NoError(t, err, "unable to create graph") require.NoError(t, err, "unable to create graph")
ctx := context.Background() ctx := t.Context()
sourceNode, err := graph.graph.SourceNode(ctx) sourceNode, err := graph.graph.SourceNode(ctx)
require.NoError(t, err, "unable to fetch source node") require.NoError(t, err, "unable to fetch source node")
@@ -3202,7 +3202,7 @@ func newPathFindingTestContext(t *testing.T, useCache bool,
require.NoError(t, err, "unable to create graph") require.NoError(t, err, "unable to create graph")
sourceNode, err := testGraphInstance.graph.SourceNode( sourceNode, err := testGraphInstance.graph.SourceNode(
context.Background(), t.Context(),
) )
require.NoError(t, err, "unable to fetch source node") require.NoError(t, err, "unable to fetch source node")
+12 -12
View File
@@ -198,7 +198,7 @@ func sendPaymentAndAssertSucceeded(t *testing.T,
// We now make a call to `resumePayment` and expect it to return the // We now make a call to `resumePayment` and expect it to return the
// preimage. // preimage.
go func() { go func() {
preimage, _, err := p.resumePayment(context.Background()) preimage, _, err := p.resumePayment(t.Context())
resultChan <- &resumePaymentResult{ resultChan <- &resumePaymentResult{
preimage: preimage, preimage: preimage,
err: err, err: err,
@@ -294,7 +294,7 @@ func TestCheckTimeoutTimedOut(t *testing.T) {
t.Parallel() t.Parallel()
deadline := time.Now().Add(time.Nanosecond) deadline := time.Now().Add(time.Nanosecond)
ctx, cancel := context.WithDeadline(context.Background(), deadline) ctx, cancel := context.WithDeadline(t.Context(), deadline)
defer cancel() defer cancel()
p := createTestPaymentLifecycle() p := createTestPaymentLifecycle()
@@ -330,7 +330,7 @@ func TestCheckTimeoutTimedOut(t *testing.T) {
// Make the timeout happens instantly. // Make the timeout happens instantly.
deadline = time.Now().Add(time.Nanosecond) deadline = time.Now().Add(time.Nanosecond)
ctx, cancel = context.WithDeadline(context.Background(), deadline) ctx, cancel = context.WithDeadline(t.Context(), deadline)
defer cancel() defer cancel()
// Sleep one millisecond to make sure it timed out. // Sleep one millisecond to make sure it timed out.
@@ -349,7 +349,7 @@ func TestCheckTimeoutTimedOut(t *testing.T) {
func TestCheckTimeoutOnRouterQuit(t *testing.T) { func TestCheckTimeoutOnRouterQuit(t *testing.T) {
t.Parallel() t.Parallel()
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(t.Context())
defer cancel() defer cancel()
p := createTestPaymentLifecycle() p := createTestPaymentLifecycle()
@@ -795,7 +795,7 @@ func TestResumePaymentFailOnFetchPayment(t *testing.T) {
m.control.On("FetchPayment", p.identifier).Return(nil, errDummy) m.control.On("FetchPayment", p.identifier).Return(nil, errDummy)
// Send the payment and assert it failed. // Send the payment and assert it failed.
sendPaymentAndAssertError(t, context.Background(), p, errDummy) sendPaymentAndAssertError(t, t.Context(), p, errDummy)
// Expected collectResultAsync to not be called. // Expected collectResultAsync to not be called.
require.Zero(t, m.collectResultsCount) require.Zero(t, m.collectResultsCount)
@@ -831,7 +831,7 @@ func TestResumePaymentFailOnTimeout(t *testing.T) {
// 3. make the timeout happens instantly and sleep one millisecond to // 3. make the timeout happens instantly and sleep one millisecond to
// make sure it timed out. // make sure it timed out.
deadline := time.Now().Add(time.Nanosecond) deadline := time.Now().Add(time.Nanosecond)
ctx, cancel := context.WithDeadline(context.Background(), deadline) ctx, cancel := context.WithDeadline(t.Context(), deadline)
defer cancel() defer cancel()
time.Sleep(1 * time.Millisecond) time.Sleep(1 * time.Millisecond)
@@ -882,7 +882,7 @@ func TestResumePaymentFailOnTimeoutErr(t *testing.T) {
// Send the payment and assert it failed when router is shutting down. // Send the payment and assert it failed when router is shutting down.
sendPaymentAndAssertError( sendPaymentAndAssertError(
t, context.Background(), p, ErrRouterShuttingDown, t, t.Context(), p, ErrRouterShuttingDown,
) )
// Expected collectResultAsync to not be called. // Expected collectResultAsync to not be called.
@@ -900,7 +900,7 @@ func TestResumePaymentFailContextCancel(t *testing.T) {
p, m := setupTestPaymentLifecycle(t) p, m := setupTestPaymentLifecycle(t)
// Create the cancelable payment context. // Create the cancelable payment context.
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(t.Context())
paymentAmt := lnwire.MilliSatoshi(10000) paymentAmt := lnwire.MilliSatoshi(10000)
@@ -977,7 +977,7 @@ func TestResumePaymentFailOnStepErr(t *testing.T) {
m.payment.On("AllowMoreAttempts").Return(false, errDummy).Once() m.payment.On("AllowMoreAttempts").Return(false, errDummy).Once()
// Send the payment and assert it failed. // Send the payment and assert it failed.
sendPaymentAndAssertError(t, context.Background(), p, errDummy) sendPaymentAndAssertError(t, t.Context(), p, errDummy)
// Expected collectResultAsync to not be called. // Expected collectResultAsync to not be called.
require.Zero(t, m.collectResultsCount) require.Zero(t, m.collectResultsCount)
@@ -1021,7 +1021,7 @@ func TestResumePaymentFailOnRequestRouteErr(t *testing.T) {
).Return(nil, errDummy).Once() ).Return(nil, errDummy).Once()
// Send the payment and assert it failed. // Send the payment and assert it failed.
sendPaymentAndAssertError(t, context.Background(), p, errDummy) sendPaymentAndAssertError(t, t.Context(), p, errDummy)
// Expected collectResultAsync to not be called. // Expected collectResultAsync to not be called.
require.Zero(t, m.collectResultsCount) require.Zero(t, m.collectResultsCount)
@@ -1081,7 +1081,7 @@ func TestResumePaymentFailOnRegisterAttemptErr(t *testing.T) {
).Return(nil, errDummy).Once() ).Return(nil, errDummy).Once()
// Send the payment and assert it failed. // Send the payment and assert it failed.
sendPaymentAndAssertError(t, context.Background(), p, errDummy) sendPaymentAndAssertError(t, t.Context(), p, errDummy)
// Expected collectResultAsync to not be called. // Expected collectResultAsync to not be called.
require.Zero(t, m.collectResultsCount) require.Zero(t, m.collectResultsCount)
@@ -1173,7 +1173,7 @@ func TestResumePaymentFailOnSendAttemptErr(t *testing.T) {
).Return(nil, errDummy).Once() ).Return(nil, errDummy).Once()
// Send the payment and assert it failed. // Send the payment and assert it failed.
sendPaymentAndAssertError(t, context.Background(), p, errDummy) sendPaymentAndAssertError(t, t.Context(), p, errDummy)
// Expected collectResultAsync to not be called. // Expected collectResultAsync to not be called.
require.Zero(t, m.collectResultsCount) require.Zero(t, m.collectResultsCount)
+3 -3
View File
@@ -132,7 +132,7 @@ func createTestCtxFromGraphInstanceAssumeValid(t *testing.T,
) )
require.NoError(t, err) require.NoError(t, err)
sourceNode, err := graphInstance.graph.SourceNode(context.Background()) sourceNode, err := graphInstance.graph.SourceNode(t.Context())
require.NoError(t, err) require.NoError(t, err)
sessionSource := &SessionSource{ sessionSource := &SessionSource{
GraphSessionFactory: graphInstance.graph, GraphSessionFactory: graphInstance.graph,
@@ -1202,7 +1202,7 @@ func TestFindPathFeeWeighting(t *testing.T) {
var preImage [32]byte var preImage [32]byte
copy(preImage[:], bytes.Repeat([]byte{9}, 32)) copy(preImage[:], bytes.Repeat([]byte{9}, 32))
sourceNode, err := ctx.graph.SourceNode(context.Background()) sourceNode, err := ctx.graph.SourceNode(t.Context())
require.NoError(t, err, "unable to fetch source node") require.NoError(t, err, "unable to fetch source node")
amt := lnwire.MilliSatoshi(100) amt := lnwire.MilliSatoshi(100)
@@ -2706,7 +2706,7 @@ func TestNewRouteRequest(t *testing.T) {
// announcements for the channel vertexes to be able to use the channel. // announcements for the channel vertexes to be able to use the channel.
func TestAddEdgeUnknownVertexes(t *testing.T) { func TestAddEdgeUnknownVertexes(t *testing.T) {
t.Parallel() t.Parallel()
ctxb := context.Background() ctxb := t.Context()
const startingBlockHeight = 101 const startingBlockHeight = 101
ctx := createTestCtxFromFile(t, startingBlockHeight, basicGraphFilePath) ctx := createTestCtxFromFile(t, startingBlockHeight, basicGraphFilePath)
+1 -1
View File
@@ -7986,7 +7986,7 @@ func (r *rpcServer) UpdateChannelPolicy(ctx context.Context,
errMsg := "cannot set both FeeRate and FeeRatePpm at the " + errMsg := "cannot set both FeeRate and FeeRatePpm at the " +
"same time" "same time"
return nil, status.Errorf(codes.InvalidArgument, errMsg) return nil, status.Errorf(codes.InvalidArgument, "%v", errMsg)
// If the request is using fee_rate. // If the request is using fee_rate.
case req.FeeRate != 0: case req.FeeRate != 0:
+1 -1
View File
@@ -75,4 +75,4 @@ require (
modernc.org/token v1.1.0 // indirect modernc.org/token v1.1.0 // indirect
) )
go 1.23.12 go 1.24.6
+8 -9
View File
@@ -1,7 +1,6 @@
package sqldb package sqldb
import ( import (
"context"
"database/sql" "database/sql"
"fmt" "fmt"
"path/filepath" "path/filepath"
@@ -75,7 +74,7 @@ func TestMigrations(t *testing.T) {
// 2592000 seconds for AMP invoices. // 2592000 seconds for AMP invoices.
func testInvoiceExpiryMigration(t *testing.T, makeDB makeMigrationTestDB) { func testInvoiceExpiryMigration(t *testing.T, makeDB makeMigrationTestDB) {
t.Parallel() t.Parallel()
ctxb := context.Background() ctxb := t.Context()
// Create a new database that already has the first version of the // Create a new database that already has the first version of the
// native invoice schema. // native invoice schema.
@@ -276,7 +275,7 @@ func TestCustomMigration(t *testing.T) {
}, },
} }
ctxb := context.Background() ctxb := t.Context()
for _, test := range tests { for _, test := range tests {
// checkSchemaVersion checks the database schema version against // checkSchemaVersion checks the database schema version against
// the expected version. // the expected version.
@@ -391,7 +390,7 @@ func TestCustomMigration(t *testing.T) {
"migrations", dbName) "migrations", dbName)
_, err := fixture.db.ExecContext( _, err := fixture.db.ExecContext(
context.Background(), "CREATE DATABASE "+dbName, t.Context(), "CREATE DATABASE "+dbName,
) )
require.NoError(t, err) require.NoError(t, err)
@@ -490,7 +489,7 @@ func TestSchemaMigrationIdempotency(t *testing.T) {
) )
}) })
ctxb := context.Background() ctxb := t.Context()
require.NoError( require.NoError(
t, db.ApplyAllMigrations(ctxb, GetMigrations()), t, db.ApplyAllMigrations(ctxb, GetMigrations()),
) )
@@ -536,7 +535,7 @@ func TestSchemaMigrationIdempotency(t *testing.T) {
"migrations", dbName) "migrations", dbName)
_, err := fixture.db.ExecContext( _, err := fixture.db.ExecContext(
context.Background(), "CREATE DATABASE "+dbName, t.Context(), "CREATE DATABASE "+dbName,
) )
require.NoError(t, err) require.NoError(t, err)
@@ -550,7 +549,7 @@ func TestSchemaMigrationIdempotency(t *testing.T) {
db, err = NewPostgresStore(cfg) db, err = NewPostgresStore(cfg)
require.NoError(t, err) require.NoError(t, err)
ctxb := context.Background() ctxb := t.Context()
require.NoError( require.NoError(
t, db.ApplyAllMigrations(ctxb, GetMigrations()), t, db.ApplyAllMigrations(ctxb, GetMigrations()),
) )
@@ -601,7 +600,7 @@ func TestMigrationSucceedsAfterDirtyStateMigrationFailure19RC1(t *testing.T) {
failingSchemaVersion = 3 failingSchemaVersion = 3
) )
ctxb := context.Background() ctxb := t.Context()
migrations := GetMigrations() migrations := GetMigrations()
migrations = migrations[:maxSchemaVersionBefore19RC1] migrations = migrations[:maxSchemaVersionBefore19RC1]
lastMigration := migrations[len(migrations)-1] lastMigration := migrations[len(migrations)-1]
@@ -692,7 +691,7 @@ func TestMigrationSucceedsAfterDirtyStateMigrationFailure19RC1(t *testing.T) {
"migrations", dbName) "migrations", dbName)
_, err := fixture.db.ExecContext( _, err := fixture.db.ExecContext(
context.Background(), "CREATE DATABASE "+dbName, t.Context(), "CREATE DATABASE "+dbName,
) )
require.NoError(t, err) require.NoError(t, err)
+4 -4
View File
@@ -18,7 +18,7 @@ import (
func TestExecuteBatchQuery(t *testing.T) { func TestExecuteBatchQuery(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
t.Run("empty input returns nil", func(t *testing.T) { t.Run("empty input returns nil", func(t *testing.T) {
var ( var (
@@ -245,7 +245,7 @@ func TestExecuteBatchQuery(t *testing.T) {
// executing the query in pages. // executing the query in pages.
func TestSQLSliceQueries(t *testing.T) { func TestSQLSliceQueries(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
db := NewTestDB(t) db := NewTestDB(t)
@@ -327,7 +327,7 @@ func TestSQLSliceQueries(t *testing.T) {
// page until all items are processed or an error occurs. // page until all items are processed or an error occurs.
func TestExecutePaginatedQuery(t *testing.T) { func TestExecutePaginatedQuery(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := t.Context()
type testItem struct { type testItem struct {
id int64 id int64
@@ -944,7 +944,7 @@ func TestExecuteCollectAndBatchWithSharedDataQuery(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
ctx := context.Background() ctx := t.Context()
cfg := &QueryConfig{ cfg := &QueryConfig{
MaxPageSize: tt.maxPageSize, MaxPageSize: tt.maxPageSize,
} }
+1 -1
View File
@@ -22,4 +22,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )
go 1.23.12 go 1.24.6
+3 -3
View File
@@ -1,4 +1,4 @@
FROM golang:1.23.12 FROM golang:1.24.6
RUN apt-get update && apt-get install -y git RUN apt-get update && apt-get install -y git
ENV GOCACHE=/tmp/build/.cache ENV GOCACHE=/tmp/build/.cache
@@ -10,8 +10,8 @@ RUN cd /tmp \
&& mkdir -p /tmp/build/.cache \ && mkdir -p /tmp/build/.cache \
&& mkdir -p /tmp/build/.modcache \ && mkdir -p /tmp/build/.modcache \
&& cd /tmp/tools \ && cd /tmp/tools \
&& go install -trimpath github.com/golangci/golangci-lint/cmd/golangci-lint \ && CGO_ENABLED=0 go install -trimpath github.com/golangci/golangci-lint/cmd/golangci-lint \
&& golangci-lint custom \ && CGO_ENABLED=0 golangci-lint custom \
&& mv ./custom-gcl /usr/local/bin/custom-gcl \ && mv ./custom-gcl /usr/local/bin/custom-gcl \
&& chmod -R 777 /tmp/build/ \ && chmod -R 777 /tmp/build/ \
&& git config --global --add safe.directory /build && git config --global --add safe.directory /build
+1 -1
View File
@@ -1,6 +1,6 @@
module github.com/lightningnetwork/lnd/tools module github.com/lightningnetwork/lnd/tools
go 1.23.12 go 1.24.6
require ( require (
github.com/btcsuite/btcd v0.24.2 github.com/btcsuite/btcd v0.24.2
+1 -1
View File
@@ -1,6 +1,6 @@
module github.com/lightningnetwork/lnd/tools/linters module github.com/lightningnetwork/lnd/tools/linters
go 1.22.6 go 1.24.6
require ( require (
github.com/golangci/plugin-module-register v0.1.1 github.com/golangci/plugin-module-register v0.1.1
+1 -1
View File
@@ -250,7 +250,7 @@ func (c *Controller) Reconnect() error {
// sendCommand sends a command to the Tor server and returns its response, as a // sendCommand sends a command to the Tor server and returns its response, as a
// single space-delimited string, and code. // single space-delimited string, and code.
func (c *Controller) sendCommand(command string) (int, string, error) { func (c *Controller) sendCommand(command string) (int, string, error) {
id, err := c.conn.Cmd(command) id, err := c.conn.Cmd("%v", command)
if err != nil { if err != nil {
return 0, "", err return 0, "", err
} }
+1 -1
View File
@@ -23,4 +23,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )
go 1.23.12 go 1.24.6
Loaded 100 of 102 files, more files were not shown because too many files have changed in this diff. Show more