From 9f34a4dc54faee5e96cbbe1e5e23b562ec218459 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Wed, 12 Jun 2024 03:40:49 +0800 Subject: [PATCH] itest: skip error assertion when parent context finishes We may get a flake like the following, ``` lnd_route_blinding_test.go:468: Error Trace: /Users/runner/work/lnd/lnd/itest/lnd_route_blinding_test.go:468 /Users/runner/hostedtoolcache/go/1.22.3/arm64/src/runtime/asm_arm64.s:1222 Error: Received unexpected error: rpc error: code = Canceled desc = context canceled Test: TestLightningNetworkDaemon/tranche15/144-of-156/bitcoind/disable_introduction_node ``` This happens when the test successfully finishes, the parent context is canceled, causing the child context to return an error. We fix it by ignoring it in the goroutine. --- itest/lnd_route_blinding_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/itest/lnd_route_blinding_test.go b/itest/lnd_route_blinding_test.go index 4b0eef859..5c32a85a3 100644 --- a/itest/lnd_route_blinding_test.go +++ b/itest/lnd_route_blinding_test.go @@ -5,6 +5,7 @@ import ( "context" "crypto/sha256" "encoding/hex" + "errors" "time" "github.com/btcsuite/btcd/btcec/v2" @@ -465,6 +466,14 @@ func (b *blindedForwardTest) sendBlindedPayment(ctx context.Context, ctx, cancel := context.WithTimeout(ctx, time.Hour) go func() { _, err := b.ht.Alice.RPC.Router.SendToRouteV2(ctx, sendReq) + + // We may get a context canceled error when the test is + // finished. + if errors.Is(err, context.Canceled) { + b.ht.Logf("sendBlindedPayment: parent context canceled") + return + } + require.NoError(b.ht, err) }()