From d5af76cb2973b92ead1f602baba2f71e8e939cc3 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Mon, 14 Nov 2022 17:27:49 +0800 Subject: [PATCH] itest+lntest: add a dedicated timeout for sending payments This commit adds a new timeout `PaymentTimeout` that's used when sending payments. A potential bug is also marked in the test. --- itest/lnd_channel_policy_test.go | 13 +++++++++++++ lntest/harness.go | 4 ++-- lntest/harness_assertion.go | 4 +++- lntest/utils.go | 4 ---- lntest/wait/timeouts.go | 3 +++ lntest/wait/timeouts_darwin.go | 3 +++ lntest/wait/timeouts_remote_db.go | 3 +++ 7 files changed, 27 insertions(+), 7 deletions(-) diff --git a/itest/lnd_channel_policy_test.go b/itest/lnd_channel_policy_test.go index ebabde856..85527a082 100644 --- a/itest/lnd_channel_policy_test.go +++ b/itest/lnd_channel_policy_test.go @@ -714,6 +714,19 @@ func testUpdateChannelPolicyForPrivateChannel(ht *lntest.HarnessTest) { // Alice pays the invoices. She will use the updated baseFeeMSat in the // payment + // + // TODO(yy): we may get a flake saying the timeout checking the + // payment's state, which is due to slow round of HTLC settlement. An + // example log is shown below, where Alice sent RevokeAndAck to Bob, + // but it took Bob 7 seconds to reply back the final UpdateFulfillHTLC. + // + // 2022-11-14 06:23:59.774 PEER: Peer(Bob): Sending UpdateAddHTLC + // 2022-11-14 06:24:00.635 PEER: Peer(Bob): Sending CommitSig + // 2022-11-14 06:24:01.784 PEER: Peer(Bob): Sending RevokeAndAck + // 2022-11-14 06:24:08.464 PEER: Peer(Bob): Received UpdateFulfillHTLC + // + // 7 seconds is too long for a local test and this needs more + // investigation. payReqs := []string{resp.PaymentRequest} ht.CompletePaymentRequests(alice, payReqs) diff --git a/lntest/harness.go b/lntest/harness.go index 9b3e9b3fe..ca9aa0174 100644 --- a/lntest/harness.go +++ b/lntest/harness.go @@ -1294,7 +1294,7 @@ func (h *HarnessTest) completePaymentRequestsAssertStatus(hn *node.HarnessNode, send := func(payReq string) { req := &routerrpc.SendPaymentRequest{ PaymentRequest: payReq, - TimeoutSeconds: defaultPaymentTimeout, + TimeoutSeconds: int32(wait.PaymentTimeout.Seconds()), FeeLimitMsat: noFeeLimitMsat, } stream := hn.RPC.SendPayment(req) @@ -1310,7 +1310,7 @@ func (h *HarnessTest) completePaymentRequestsAssertStatus(hn *node.HarnessNode, } // Wait for all payments to report the expected status. - timer := time.After(DefaultTimeout) + timer := time.After(wait.PaymentTimeout) select { case stream := <-results: h.AssertPaymentStatusFromStream(stream, status) diff --git a/lntest/harness_assertion.go b/lntest/harness_assertion.go index 7f6a6d866..02c26ec41 100644 --- a/lntest/harness_assertion.go +++ b/lntest/harness_assertion.go @@ -948,7 +948,9 @@ func (h *HarnessTest) AssertNodesNumPendingOpenChannels(a, b *node.HarnessNode, func (h *HarnessTest) AssertPaymentStatusFromStream(stream rpc.PaymentClient, status lnrpc.Payment_PaymentStatus) *lnrpc.Payment { - return h.assertPaymentStatusWithTimeout(stream, status, DefaultTimeout) + return h.assertPaymentStatusWithTimeout( + stream, status, wait.PaymentTimeout, + ) } // AssertPaymentSucceedWithTimeout asserts that a payment is succeeded within diff --git a/lntest/utils.go b/lntest/utils.go index dd5fc8c17..724653344 100644 --- a/lntest/utils.go +++ b/lntest/utils.go @@ -27,10 +27,6 @@ const ( // noFeeLimitMsat is used to specify we will put no requirements on fee // charged when choosing a route path. noFeeLimitMsat = math.MaxInt64 - - // defaultPaymentTimeout specifies the default timeout in seconds when - // sending a payment. - defaultPaymentTimeout = 60 ) // CopyFile copies the file src to dest. diff --git a/lntest/wait/timeouts.go b/lntest/wait/timeouts.go index e17c8a433..f8239799b 100644 --- a/lntest/wait/timeouts.go +++ b/lntest/wait/timeouts.go @@ -33,4 +33,7 @@ const ( // SqliteBusyTimeout is the maximum time that a call to the sqlite db // will wait for the connection to become available. SqliteBusyTimeout = time.Second * 10 + + // PaymentTimeout is the timeout used when sending payments. + PaymentTimeout = time.Second * 60 ) diff --git a/lntest/wait/timeouts_darwin.go b/lntest/wait/timeouts_darwin.go index 18c4ec653..bc9ff2144 100644 --- a/lntest/wait/timeouts_darwin.go +++ b/lntest/wait/timeouts_darwin.go @@ -34,4 +34,7 @@ const ( // SqliteBusyTimeout is the maximum time that a call to the sqlite db // will wait for the connection to become available. SqliteBusyTimeout = time.Second * 10 + + // PaymentTimeout is the timeout used when sending payments. + PaymentTimeout = time.Second * 60 ) diff --git a/lntest/wait/timeouts_remote_db.go b/lntest/wait/timeouts_remote_db.go index 2e798b709..902508136 100644 --- a/lntest/wait/timeouts_remote_db.go +++ b/lntest/wait/timeouts_remote_db.go @@ -33,4 +33,7 @@ const ( // SqliteBusyTimeout is the maximum time that a call to the sqlite db // will wait for the connection to become available. SqliteBusyTimeout = time.Second * 10 + + // PaymentTimeout is the timeout used when sending payments. + PaymentTimeout = time.Second * 60 )