mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-23 00:04:57 +02:00
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.
This commit is contained in:
@@ -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)
|
||||
}()
|
||||
|
||||
|
Reference in New Issue
Block a user