Skip to content

Commit 428a33f

Browse files
committed
itest: add coverage for failure at the introduction node
1 parent 4535cf6 commit 428a33f

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

itest/list_on_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,10 @@ var allTestCases = []*lntest.TestCase{
574574
Name: "relayer blinded error",
575575
TestFunc: testRelayingBlindedError,
576576
},
577+
{
578+
Name: "introduction blinded error",
579+
TestFunc: testIntroductionNodeError,
580+
},
577581
{
578582
Name: "removetx",
579583
TestFunc: testRemoveTx,

itest/lnd_route_blinding_test.go

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ func testReceiverBlindedError(ht *lntest.HarnessTest) {
841841
defer testCase.cleanup()
842842
route := testCase.setup(ctx)
843843

844-
sendAndResumeBlindedPayment(ctx, ht, testCase, route)
844+
sendAndResumeBlindedPayment(ctx, ht, testCase, route, true)
845845
}
846846

847847
// testRelayingBlindedError tests handling of errors from relaying nodes in a
@@ -861,7 +861,7 @@ func testRelayingBlindedError(ht *lntest.HarnessTest) {
861861
// a lack of liquidity. This check only happens _after_ the interceptor
862862
// has given the instruction to resume so we can use test
863863
// infrastructure that will go ahead and intercept the payment.
864-
sendAndResumeBlindedPayment(ctx, ht, testCase, route)
864+
sendAndResumeBlindedPayment(ctx, ht, testCase, route, true)
865865
}
866866

867867
// sendAndResumeBlindedPayment sends a blinded payment through the test
@@ -870,14 +870,18 @@ func testRelayingBlindedError(ht *lntest.HarnessTest) {
870870
// reach Carol and asserts that all errors appear to originate from the
871871
// introduction node.
872872
func sendAndResumeBlindedPayment(ctx context.Context, ht *lntest.HarnessTest,
873-
testCase *blindedForwardTest, route *routing.BlindedPayment) {
873+
testCase *blindedForwardTest, route *routing.BlindedPayment,
874+
interceptAtCarol bool) {
874875

875876
blindedRoute := testCase.createRouteToBlinded(10_000_000, route)
876877

877878
// Before we dispatch the payment, spin up a goroutine that will
878879
// intercept the HTLC on Carol's forward. This allows us to ensure
879880
// that the HTLC actually reaches the location we expect it to.
880-
resolveHTLC := testCase.interceptFinalHop()
881+
var resolveHTLC func(routerrpc.ResolveHoldForwardAction)
882+
if interceptAtCarol {
883+
resolveHTLC = testCase.interceptFinalHop()
884+
}
881885

882886
// First, test sending the payment all the way through to Dave. We
883887
// expect this payment to fail, because he does not know how to
@@ -886,7 +890,9 @@ func sendAndResumeBlindedPayment(ctx context.Context, ht *lntest.HarnessTest,
886890

887891
// When Carol intercepts the HTLC, instruct her to resume the payment
888892
// so that it'll reach Dave and fail.
889-
resolveHTLC(routerrpc.ResolveHoldForwardAction_RESUME)
893+
if interceptAtCarol {
894+
resolveHTLC(routerrpc.ResolveHoldForwardAction_RESUME)
895+
}
890896

891897
// Wait for the HTLC to reflect as failed for Alice.
892898
preimage, err := lntypes.MakePreimage(testCase.preimage[:])
@@ -901,3 +907,21 @@ func sendAndResumeBlindedPayment(ctx context.Context, ht *lntest.HarnessTest,
901907
pmt.Htlcs[0].Failure.Code,
902908
)
903909
}
910+
911+
// testIntroductionNodeError tests handling of errors in a blinded route when
912+
// the introduction node is the source of the error. This test sends a payment
913+
// over Alice -- Bob -- Carol -- Dave, where Bob is the introduction node and
914+
// has insufficient outgoing liquidity to forward on to carol.
915+
func testIntroductionNodeError(ht *lntest.HarnessTest) {
916+
ctx, testCase := newBlindedForwardTest(ht)
917+
defer testCase.cleanup()
918+
route := testCase.setup(ctx)
919+
920+
// Before we send our payment, drain all of Carol's incoming liquidity
921+
// so that she can't receive the forward from Bob, causing a failure
922+
// at the introduction node.
923+
testCase.drainCarolLiquidity(true)
924+
925+
// Send the payment, but do not expect it to reach Carol at all.
926+
sendAndResumeBlindedPayment(ctx, ht, testCase, route, false)
927+
}

0 commit comments

Comments
 (0)