itest: break down payment failed tests

This commit is contained in:
yyforyongyu 2024-11-09 00:59:15 +08:00
parent 3319d0d983
commit 7b1427a565
No known key found for this signature in database
GPG key ID: 9BCD95C4FF296868
2 changed files with 32 additions and 26 deletions

View file

@ -648,6 +648,10 @@ var allTestCases = []*lntest.TestCase{
Name: "payment failed htlc local swept", Name: "payment failed htlc local swept",
TestFunc: testPaymentFailedHTLCLocalSwept, TestFunc: testPaymentFailedHTLCLocalSwept,
}, },
{
Name: "payment failed htlc local swept resumed",
TestFunc: testPaymentFailedHTLCLocalSweptResumed,
},
{ {
Name: "payment succeeded htlc remote swept", Name: "payment succeeded htlc remote swept",
TestFunc: testPaymentSucceededHTLCRemoteSwept, TestFunc: testPaymentSucceededHTLCRemoteSwept,
@ -656,6 +660,10 @@ var allTestCases = []*lntest.TestCase{
Name: "send to route failed htlc timeout", Name: "send to route failed htlc timeout",
TestFunc: testSendToRouteFailHTLCTimeout, TestFunc: testSendToRouteFailHTLCTimeout,
}, },
{
Name: "send to route failed htlc timeout resumed",
TestFunc: testSendToRouteFailHTLCTimeoutResumed,
},
{ {
Name: "debuglevel show", Name: "debuglevel show",
TestFunc: testDebuglevelShow, TestFunc: testDebuglevelShow,

View file

@ -179,21 +179,19 @@ func testPaymentSucceededHTLCRemoteSwept(ht *lntest.HarnessTest) {
// out and claimed onchain via the timeout path, the payment will be marked as // out and claimed onchain via the timeout path, the payment will be marked as
// failed. This test creates a topology from Alice -> Bob, and let Alice send // failed. This test creates a topology from Alice -> Bob, and let Alice send
// payments to Bob. Bob then goes offline, such that Alice's outgoing HTLC will // payments to Bob. Bob then goes offline, such that Alice's outgoing HTLC will
// time out. Alice will also be restarted to make sure resumed payments are // time out.
// also marked as failed.
func testPaymentFailedHTLCLocalSwept(ht *lntest.HarnessTest) { func testPaymentFailedHTLCLocalSwept(ht *lntest.HarnessTest) {
success := ht.Run("fail payment", func(t *testing.T) { runTestPaymentHTLCTimeout(ht, false)
st := ht.Subtest(t) }
runTestPaymentHTLCTimeout(st, false)
})
if !success {
return
}
ht.Run("fail resumed payment", func(t *testing.T) { // testPaymentFailedHTLCLocalSweptResumed checks that when an outgoing HTLC is
st := ht.Subtest(t) // timed out and claimed onchain via the timeout path, the payment will be
runTestPaymentHTLCTimeout(st, true) // marked as failed. This test creates a topology from Alice -> Bob, and let
}) // Alice send payments to Bob. Bob then goes offline, such that Alice's
// outgoing HTLC will time out. Alice will be restarted to make sure resumed
// payments are also marked as failed.
func testPaymentFailedHTLCLocalSweptResumed(ht *lntest.HarnessTest) {
runTestPaymentHTLCTimeout(ht, true)
} }
// runTestPaymentHTLCTimeout is the helper function that actually runs the // runTestPaymentHTLCTimeout is the helper function that actually runs the
@ -1181,21 +1179,21 @@ func sendPaymentInterceptAndCancel(ht *lntest.HarnessTest,
// out and claimed onchain via the timeout path, the payment will be marked as // out and claimed onchain via the timeout path, the payment will be marked as
// failed. This test creates a topology from Alice -> Bob, and let Alice send // failed. This test creates a topology from Alice -> Bob, and let Alice send
// payments to Bob. Bob then goes offline, such that Alice's outgoing HTLC will // payments to Bob. Bob then goes offline, such that Alice's outgoing HTLC will
// time out. Alice will also be restarted to make sure resumed payments are // time out.
// also marked as failed.
func testSendToRouteFailHTLCTimeout(ht *lntest.HarnessTest) { func testSendToRouteFailHTLCTimeout(ht *lntest.HarnessTest) {
success := ht.Run("fail payment", func(t *testing.T) { runSendToRouteFailHTLCTimeout(ht, false)
st := ht.Subtest(t) }
runSendToRouteFailHTLCTimeout(st, false)
})
if !success {
return
}
ht.Run("fail resumed payment", func(t *testing.T) { // testSendToRouteFailHTLCTimeout is similar to
st := ht.Subtest(t) // testPaymentFailedHTLCLocalSwept. The only difference is the `SendPayment` is
runTestPaymentHTLCTimeout(st, true) // replaced with `SendToRouteV2`. It checks that when an outgoing HTLC is timed
}) // out and claimed onchain via the timeout path, the payment will be marked as
// failed. This test creates a topology from Alice -> Bob, and let Alice send
// payments to Bob. Bob then goes offline, such that Alice's outgoing HTLC will
// time out. Alice will be restarted to make sure resumed payments are also
// marked as failed.
func testSendToRouteFailHTLCTimeoutResumed(ht *lntest.HarnessTest) {
runTestPaymentHTLCTimeout(ht, true)
} }
// runSendToRouteFailHTLCTimeout is the helper function that actually runs the // runSendToRouteFailHTLCTimeout is the helper function that actually runs the