Skip to content

Commit

Permalink
itest: assert payment status after sending
Browse files Browse the repository at this point in the history
  • Loading branch information
yyforyongyu committed Dec 13, 2024
1 parent c103abb commit 8f186a2
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 35 deletions.
2 changes: 1 addition & 1 deletion itest/lnd_channel_balance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func testChannelUnsettledBalance(ht *lntest.HarnessTest) {
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
alice.RPC.SendPayment(req)
ht.SendPaymentAssertInflight(alice, req)
}()
}

Expand Down
2 changes: 1 addition & 1 deletion itest/lnd_channel_force_close_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func runChannelForceClosureTest(ht *lntest.HarnessTest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
alice.RPC.SendPayment(req)
ht.SendPaymentAssertInflight(alice, req)
}

// Once the HTLC has cleared, all the nodes n our mini network should
Expand Down
6 changes: 2 additions & 4 deletions itest/lnd_forward_interceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,7 @@ func testForwardInterceptorWireRecords(ht *lntest.HarnessTest) {
FeeLimitMsat: noFeeLimitMsat,
FirstHopCustomRecords: customRecords,
}

_ = alice.RPC.SendPayment(sendReq)
ht.SendPaymentAssertInflight(alice, sendReq)

// We start the htlc interceptor with a simple implementation that saves
// all intercepted packets. These packets are held to simulate a
Expand Down Expand Up @@ -635,8 +634,7 @@ func testForwardInterceptorRestart(ht *lntest.HarnessTest) {
FeeLimitMsat: noFeeLimitMsat,
FirstHopCustomRecords: customRecords,
}

_ = alice.RPC.SendPayment(sendReq)
ht.SendPaymentAssertInflight(alice, sendReq)

// We start the htlc interceptor with a simple implementation that saves
// all intercepted packets. These packets are held to simulate a
Expand Down
2 changes: 1 addition & 1 deletion itest/lnd_hold_invoice_force_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func testHoldInvoiceForceClose(ht *lntest.HarnessTest) {
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
alice.RPC.SendPayment(req)
ht.SendPaymentAssertInflight(alice, req)

ht.AssertInvoiceState(stream, lnrpc.Invoice_ACCEPTED)

Expand Down
4 changes: 2 additions & 2 deletions itest/lnd_htlc_timeout_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func testHtlcTimeoutResolverExtractPreimageRemote(ht *lntest.HarnessTest) {
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
alice.RPC.SendPayment(req)
ht.SendPaymentAssertInflight(alice, req)

// Once the payment sent, Alice should have one outgoing HTLC active.
ht.AssertOutgoingHTLCActive(alice, aliceChanPoint, payHash[:])
Expand Down Expand Up @@ -270,7 +270,7 @@ func testHtlcTimeoutResolverExtractPreimageLocal(ht *lntest.HarnessTest) {
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
alice.RPC.SendPayment(req)
ht.SendPaymentAssertInflight(alice, req)

// Once the payment sent, Alice should have one outgoing HTLC active.
ht.AssertOutgoingHTLCActive(alice, aliceChanPoint, payHash[:])
Expand Down
6 changes: 4 additions & 2 deletions itest/lnd_misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,10 @@ func testRejectHTLC(ht *lntest.HarnessTest) {
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
payStream := alice.RPC.SendPayment(paymentReq)
ht.AssertPaymentStatusFromStream(payStream, lnrpc.Payment_FAILED)
ht.SendPaymentAssertFail(
alice, paymentReq,
lnrpc.PaymentFailureReason_FAILURE_REASON_NO_ROUTE,
)

ht.AssertLastHTLCError(alice, lnrpc.Failure_CHANNEL_DISABLED)

Expand Down
28 changes: 15 additions & 13 deletions itest/lnd_multi-hop_force_close_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,25 +306,27 @@ func runLocalClaimOutgoingHTLC(ht *lntest.HarnessTest,
routeHints = makeRouteHints(bob, carol, params.ZeroConf)
}

alice.RPC.SendPayment(&routerrpc.SendPaymentRequest{
req := &routerrpc.SendPaymentRequest{
Dest: carolPubKey,
Amt: int64(dustHtlcAmt),
PaymentHash: dustPayHash,
FinalCltvDelta: finalCltvDelta,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
RouteHints: routeHints,
})
}
ht.SendPaymentAssertInflight(alice, req)

alice.RPC.SendPayment(&routerrpc.SendPaymentRequest{
req = &routerrpc.SendPaymentRequest{
Dest: carolPubKey,
Amt: int64(htlcAmt),
PaymentHash: payHash,
FinalCltvDelta: finalCltvDelta,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
RouteHints: routeHints,
})
}
ht.SendPaymentAssertInflight(alice, req)

// Verify that all nodes in the path now have two HTLC's with the
// proper parameters.
Expand Down Expand Up @@ -653,7 +655,7 @@ func runMultiHopReceiverPreimageClaim(ht *lntest.HarnessTest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
alice.RPC.SendPayment(req)
ht.SendPaymentAssertInflight(alice, req)

// At this point, all 3 nodes should now have an active channel with
// the created HTLC pending on all of them.
Expand Down Expand Up @@ -1014,7 +1016,7 @@ func runLocalForceCloseBeforeHtlcTimeout(ht *lntest.HarnessTest,
FeeLimitMsat: noFeeLimitMsat,
RouteHints: routeHints,
}
alice.RPC.SendPayment(req)
ht.SendPaymentAssertInflight(alice, req)

// Once the HTLC has cleared, all channels in our mini network should
// have the it locked in.
Expand Down Expand Up @@ -1343,7 +1345,7 @@ func runRemoteForceCloseBeforeHtlcTimeout(ht *lntest.HarnessTest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
alice.RPC.SendPayment(req)
ht.SendPaymentAssertInflight(alice, req)

// Once the HTLC has cleared, all the nodes in our mini network should
// show that the HTLC has been locked in.
Expand Down Expand Up @@ -1602,7 +1604,7 @@ func runLocalClaimIncomingHTLC(ht *lntest.HarnessTest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
alice.RPC.SendPayment(req)
ht.SendPaymentAssertInflight(alice, req)

// At this point, all 3 nodes should now have an active channel with
// the created HTLC pending on all of them.
Expand Down Expand Up @@ -1913,7 +1915,7 @@ func runLocalClaimIncomingHTLCLeased(ht *lntest.HarnessTest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
alice.RPC.SendPayment(req)
ht.SendPaymentAssertInflight(alice, req)

// At this point, all 3 nodes should now have an active channel with
// the created HTLC pending on all of them.
Expand Down Expand Up @@ -2268,7 +2270,7 @@ func runLocalPreimageClaim(ht *lntest.HarnessTest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
alice.RPC.SendPayment(req)
ht.SendPaymentAssertInflight(alice, req)

// At this point, all 3 nodes should now have an active channel with
// the created HTLC pending on all of them.
Expand Down Expand Up @@ -2551,7 +2553,7 @@ func runLocalPreimageClaimLeased(ht *lntest.HarnessTest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
alice.RPC.SendPayment(req)
ht.SendPaymentAssertInflight(alice, req)

// At this point, all 3 nodes should now have an active channel with
// the created HTLC pending on all of them.
Expand Down Expand Up @@ -2998,7 +3000,7 @@ func runHtlcAggregation(ht *lntest.HarnessTest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
alice.RPC.SendPayment(req)
ht.SendPaymentAssertInflight(alice, req)
}

// And Carol will pay Alice's.
Expand All @@ -3008,7 +3010,7 @@ func runHtlcAggregation(ht *lntest.HarnessTest,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
carol.RPC.SendPayment(req)
ht.SendPaymentAssertInflight(carol, req)
}

// At this point, all 3 nodes should now the HTLCs active on their
Expand Down
17 changes: 6 additions & 11 deletions itest/lnd_watchtower_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -655,17 +655,12 @@ func generateBackups(ht *lntest.HarnessTest, srcNode,
)

send := func(node *node.HarnessNode, payReq string) {
stream := node.RPC.SendPayment(
&routerrpc.SendPaymentRequest{
PaymentRequest: payReq,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
},
)

ht.AssertPaymentStatusFromStream(
stream, lnrpc.Payment_SUCCEEDED,
)
req := &routerrpc.SendPaymentRequest{
PaymentRequest: payReq,
TimeoutSeconds: 60,
FeeLimitMsat: noFeeLimitMsat,
}
ht.SendPaymentAssertSettled(node, req)
}

// Pay each invoice.
Expand Down

0 comments on commit 8f186a2

Please sign in to comment.