Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

itest: fix flake in payment_failure_reason_canceled #9228

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions itest/lnd_payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1113,12 +1113,16 @@ func testPaymentFailureReasonCanceled(ht *lntest.HarnessTest) {
// Make sure Alice is aware of channel Bob=>Carol.
ht.AssertTopologyChannelOpen(alice, cpBC)

// Connect the interceptor.
interceptor, cancelInterceptor := bob.RPC.HtlcInterceptor()
defer cancelInterceptor()

// First we check that the payment is successful when bob resumes the
// htlc even though the payment context was canceled before invoice
// settlement.
sendPaymentInterceptAndCancel(
ht, ts, cpAB, routerrpc.ResolveHoldForwardAction_RESUME,
lnrpc.Payment_SUCCEEDED,
lnrpc.Payment_SUCCEEDED, interceptor,
)

// Next we check that the context cancellation results in the expected
Expand All @@ -1128,7 +1132,7 @@ func testPaymentFailureReasonCanceled(ht *lntest.HarnessTest) {
// htlc fail case before the htlc resume case.
sendPaymentInterceptAndCancel(
ht, ts, cpAB, routerrpc.ResolveHoldForwardAction_FAIL,
lnrpc.Payment_FAILED,
lnrpc.Payment_FAILED, interceptor,
)

// Finally, close channels.
Expand All @@ -1139,14 +1143,12 @@ func testPaymentFailureReasonCanceled(ht *lntest.HarnessTest) {
func sendPaymentInterceptAndCancel(ht *lntest.HarnessTest,
ts *interceptorTestScenario, cpAB *lnrpc.ChannelPoint,
interceptorAction routerrpc.ResolveHoldForwardAction,
expectedPaymentStatus lnrpc.Payment_PaymentStatus) {
expectedPaymentStatus lnrpc.Payment_PaymentStatus,
interceptor rpc.InterceptorClient) {

// Prepare the test cases.
alice, bob, carol := ts.alice, ts.bob, ts.carol

// Connect the interceptor.
interceptor, cancelInterceptor := bob.RPC.HtlcInterceptor()

// Prepare the test cases.
addResponse := carol.RPC.AddInvoice(&lnrpc.Invoice{
ValueMsat: 1000,
Expand Down Expand Up @@ -1208,9 +1210,6 @@ func sendPaymentInterceptAndCancel(ht *lntest.HarnessTest,
// should've been made, and we observe FAILURE_REASON_CANCELED.
expectedReason := lnrpc.PaymentFailureReason_FAILURE_REASON_CANCELED
ht.AssertPaymentFailureReason(alice, preimage, expectedReason)

// Cancel the context, which will disconnect the above interceptor.
cancelInterceptor()
}

// testSendToRouteFailHTLCTimeout is similar to
Expand Down
1 change: 0 additions & 1 deletion lntest/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ func (h *HarnessTest) SetupStandbyNodes() {
// above a good number of confirmations.
const totalTxes = 200
h.MineBlocksAndAssertNumTxes(numBlocksSendOutput, totalTxes)
h.MineBlocks(numBlocksSendOutput)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I don't really understand the comment of the sweeper here, because I don't think the sweeper is involved here in general, we are using the SendRawTransaction of the miner imo, but maybe I misunderstand something here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah my bad - it's from another PR, removed the commit msg!


// Now we want to wait for the nodes to catch up.
h.WaitForBlockchainSync(h.Alice)
Expand Down
Loading