Skip to content

Commit 9f34a4d

Browse files
committed
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.
1 parent ddceb2b commit 9f34a4d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

itest/lnd_route_blinding_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"crypto/sha256"
77
"encoding/hex"
8+
"errors"
89
"time"
910

1011
"github.com/btcsuite/btcd/btcec/v2"
@@ -465,6 +466,14 @@ func (b *blindedForwardTest) sendBlindedPayment(ctx context.Context,
465466
ctx, cancel := context.WithTimeout(ctx, time.Hour)
466467
go func() {
467468
_, err := b.ht.Alice.RPC.Router.SendToRouteV2(ctx, sendReq)
469+
470+
// We may get a context canceled error when the test is
471+
// finished.
472+
if errors.Is(err, context.Canceled) {
473+
b.ht.Logf("sendBlindedPayment: parent context canceled")
474+
return
475+
}
476+
468477
require.NoError(b.ht, err)
469478
}()
470479

0 commit comments

Comments
 (0)