multi: context.Background() -> t.Context()
Use the new feature of Go 1.24, fix linter warnings. This change was produced by: - running golangci-lint run --fix - sed 's/context.Background/t.Context/' -i `git grep -l context.Background | grep test.go` - manually fixing broken tests - itest, lntest: use ht.Context() where ht or hn is available - in HarnessNode.Stop() we keep using context.Background(), because it is called from a cleanup handler in which t.Context() is canceled already.
This commit is contained in:
71 files changed
+361
-393
No files matched your search
+27
-27
@@ -1024,7 +1024,7 @@ func createTestCtx(t *testing.T, startHeight uint32, isChanPeer bool) (
|
||||
// the router subsystem.
|
||||
func TestProcessAnnouncement(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
timestamp := testTimestamp
|
||||
tCtx, err := createTestCtx(t, 0, false)
|
||||
@@ -1140,7 +1140,7 @@ func TestProcessAnnouncement(t *testing.T) {
|
||||
// propagated to the router subsystem.
|
||||
func TestPrematureAnnouncement(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
timestamp := testTimestamp
|
||||
|
||||
@@ -1176,7 +1176,7 @@ func TestPrematureAnnouncement(t *testing.T) {
|
||||
// properly processes partial and fully announcement signatures message.
|
||||
func TestSignatureAnnouncementLocalFirst(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
tCtx, err := createTestCtx(t, proofMatureDelta, false)
|
||||
require.NoError(t, err, "can't create context")
|
||||
@@ -1355,7 +1355,7 @@ func TestSignatureAnnouncementLocalFirst(t *testing.T) {
|
||||
// processes announcement with unknown channel ids.
|
||||
func TestOrphanSignatureAnnouncement(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
tCtx, err := createTestCtx(t, proofMatureDelta, false)
|
||||
require.NoError(t, err, "can't create context")
|
||||
@@ -1547,7 +1547,7 @@ func TestOrphanSignatureAnnouncement(t *testing.T) {
|
||||
// assembled.
|
||||
func TestSignatureAnnouncementRetryAtStartup(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
tCtx, err := createTestCtx(t, proofMatureDelta, false)
|
||||
require.NoError(t, err, "can't create context")
|
||||
@@ -1783,7 +1783,7 @@ out:
|
||||
// the full proof (ChannelAnnouncement) to the remote peer.
|
||||
func TestSignatureAnnouncementFullProofWhenRemoteProof(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
tCtx, err := createTestCtx(t, proofMatureDelta, false)
|
||||
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.
|
||||
func TestForwardPrivateNodeAnnouncement(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
const (
|
||||
startingHeight = 100
|
||||
@@ -2334,7 +2334,7 @@ func TestForwardPrivateNodeAnnouncement(t *testing.T) {
|
||||
// zombie edges.
|
||||
func TestRejectZombieEdge(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// We'll start by creating our test context with a batch of
|
||||
// announcements.
|
||||
@@ -2436,7 +2436,7 @@ func TestRejectZombieEdge(t *testing.T) {
|
||||
// becomes live by receiving a fresh update.
|
||||
func TestProcessZombieEdgeNowLive(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// We'll start by creating our test context with a batch of
|
||||
// announcements.
|
||||
@@ -2594,7 +2594,7 @@ func TestProcessZombieEdgeNowLive(t *testing.T) {
|
||||
// be reprocessed later, after our ChannelAnnouncement.
|
||||
func TestReceiveRemoteChannelUpdateFirst(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
tCtx, err := createTestCtx(t, proofMatureDelta, false)
|
||||
require.NoError(t, err, "can't create context")
|
||||
@@ -2798,7 +2798,7 @@ func TestReceiveRemoteChannelUpdateFirst(t *testing.T) {
|
||||
// currently know of.
|
||||
func TestExtraDataChannelAnnouncementValidation(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
tCtx, err := createTestCtx(t, 0, false)
|
||||
require.NoError(t, err, "can't create context")
|
||||
@@ -2835,7 +2835,7 @@ func TestExtraDataChannelAnnouncementValidation(t *testing.T) {
|
||||
// know of.
|
||||
func TestExtraDataChannelUpdateValidation(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
timestamp := testTimestamp
|
||||
tCtx, err := createTestCtx(t, 0, false)
|
||||
@@ -2896,7 +2896,7 @@ func TestExtraDataChannelUpdateValidation(t *testing.T) {
|
||||
// currently know of.
|
||||
func TestExtraDataNodeAnnouncementValidation(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
tCtx, err := createTestCtx(t, 0, false)
|
||||
require.NoError(t, err, "can't create context")
|
||||
@@ -2969,7 +2969,7 @@ func assertProcessAnnouncement(t *testing.T, result chan error) {
|
||||
// the retransmit ticker ticks.
|
||||
func TestRetransmit(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
tCtx, err := createTestCtx(t, proofMatureDelta, false)
|
||||
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.
|
||||
func TestNodeAnnouncementNoChannels(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
tCtx, err := createTestCtx(t, 0, false)
|
||||
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.
|
||||
func TestOptionalFieldsChannelUpdateValidation(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
tCtx, err := createTestCtx(t, 0, false)
|
||||
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.
|
||||
func TestSendChannelUpdateReliably(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// We'll start by creating our test context and a batch of
|
||||
// announcements.
|
||||
@@ -3587,7 +3587,7 @@ func sendRemoteMsg(t *testing.T, ctx *testCtx, msg lnwire.Message,
|
||||
|
||||
select {
|
||||
case err := <-ctx.gossiper.ProcessRemoteAnnouncement(
|
||||
context.Background(), msg, remotePeer,
|
||||
t.Context(), msg, remotePeer,
|
||||
):
|
||||
if err != nil {
|
||||
t.Fatalf("unable to process channel msg: %v", err)
|
||||
@@ -3718,7 +3718,7 @@ out:
|
||||
// policy of all of them.
|
||||
const newTimeLockDelta = 100
|
||||
var edgesToUpdate []EdgeWithInfo
|
||||
err = ctx.router.ForAllOutgoingChannels(context.Background(), func(
|
||||
err = ctx.router.ForAllOutgoingChannels(t.Context(), func(
|
||||
info *models.ChannelEdgeInfo,
|
||||
edge *models.ChannelEdgePolicy) error {
|
||||
|
||||
@@ -3986,7 +3986,7 @@ func (m *SyncManager) markGraphSyncing() {
|
||||
// initial historical sync has completed.
|
||||
func TestBroadcastAnnsAfterGraphSynced(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
tCtx, err := createTestCtx(t, 10, false)
|
||||
require.NoError(t, err, "can't create context")
|
||||
@@ -4064,7 +4064,7 @@ func TestBroadcastAnnsAfterGraphSynced(t *testing.T) {
|
||||
// is tested by TestRateLimitChannelUpdates.
|
||||
func TestRateLimitDeDup(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// Create our test harness.
|
||||
const blockHeight = 100
|
||||
@@ -4261,7 +4261,7 @@ func TestRateLimitDeDup(t *testing.T) {
|
||||
// channel updates.
|
||||
func TestRateLimitChannelUpdates(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
// Create our test harness.
|
||||
const blockHeight = 100
|
||||
@@ -4416,7 +4416,7 @@ func TestRateLimitChannelUpdates(t *testing.T) {
|
||||
// about our own channels when coming from a remote peer.
|
||||
func TestIgnoreOwnAnnouncement(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
tCtx, err := createTestCtx(t, proofMatureDelta, false)
|
||||
require.NoError(t, err, "can't create context")
|
||||
@@ -4563,7 +4563,7 @@ func TestIgnoreOwnAnnouncement(t *testing.T) {
|
||||
// error.
|
||||
func TestRejectCacheChannelAnn(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
tCtx, err := createTestCtx(t, proofMatureDelta, false)
|
||||
require.NoError(t, err, "can't create context")
|
||||
@@ -4644,7 +4644,7 @@ func TestFutureMsgCacheEviction(t *testing.T) {
|
||||
// channel announcements are banned properly.
|
||||
func TestChanAnnBanningNonChanPeer(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
tCtx, err := createTestCtx(t, 1000, false)
|
||||
require.NoError(t, err, "can't create context")
|
||||
@@ -4739,7 +4739,7 @@ func TestChanAnnBanningNonChanPeer(t *testing.T) {
|
||||
// get disconnected.
|
||||
func TestChanAnnBanningChanPeer(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
ctx := t.Context()
|
||||
|
||||
tCtx, err := createTestCtx(t, 1000, true)
|
||||
require.NoError(t, err, "can't create context")
|
||||
@@ -4832,7 +4832,7 @@ func assertChanChainRejection(t *testing.T, ctx *testCtx,
|
||||
}
|
||||
|
||||
_, added := ctx.gossiper.handleChanAnnouncement(
|
||||
context.Background(), nMsg, edge,
|
||||
t.Context(), nMsg, edge,
|
||||
)
|
||||
require.False(t, added)
|
||||
|
||||
|
||||
Reference in new issue
Block a user