@@ -600,24 +600,54 @@ func setupFourHopNetwork(ht *lntest.HarnessTest,
600600 }
601601}
602602
603- // testForwardAndReceiveBlindedRoute tests lnd's ability to create a blinded
604- // payment path, forward payments in a blinded route and receive the payment.
605- func testForwardAndReceiveBlindedRoute (ht * lntest.HarnessTest ) {
603+ // testBlindedRouteInvoices tests lnd's ability to create a blinded payment path
604+ // which it then inserts into an invoice, sending to an invoice with a blinded
605+ // path and forward payments in a blinded route and finally, receiving the
606+ // payment.
607+ func testBlindedRouteInvoices (ht * lntest.HarnessTest ) {
606608 ctx , testCase := newBlindedForwardTest (ht )
607609 defer testCase .cleanup ()
608610
609611 // Set up the 4 hop network and let Dave create an invoice with a
610612 // blinded path that uses Bob as an introduction node.
611613 testCase .setupNetwork (ctx , false )
612- blindedPaymentPath := testCase .buildBlindedPath ()
613614
614- // Construct a full route from Alice to Dave using the blinded payment
615- // path.
616- route := testCase .createRouteToBlinded (10_000_000 , blindedPaymentPath )
615+ // Let Dave add a blinded invoice.
616+ invoice := testCase .dave .RPC .AddInvoice (& lnrpc.Invoice {
617+ Memo : "test" ,
618+ ValueMsat : 10_000_000 ,
619+ Blind : true ,
620+ })
617621
618- // Let Alice send to the constructed route and assert that the payment
619- // succeeds.
620- testCase .sendToRoute (route , true )
622+ // Now let Alice pay the invoice.
623+ ht .CompletePaymentRequests (ht .Alice , []string {invoice .PaymentRequest })
624+
625+ // Restart Dave with blinded path restrictions that will result in him
626+ // creating a blinded path that uses himself as the introduction node.
627+ ht .RestartNodeWithExtraArgs (testCase .dave , []string {
628+ "--invoices.blinding.min-num-real-hops=0" ,
629+ "--invoices.blinding.num-hops=0" ,
630+ })
631+ ht .EnsureConnected (testCase .dave , testCase .carol )
632+
633+ // Let Dave add a blinded invoice.
634+ // Once again let Dave create a blinded invoice.
635+ invoice = testCase .dave .RPC .AddInvoice (& lnrpc.Invoice {
636+ Memo : "test" ,
637+ ValueMsat : 10_000_000 ,
638+ Blind : true ,
639+ })
640+
641+ // Assert that it contains a single blinded path with only an
642+ // introduction node hop where the introduction node is Dave.
643+ payReq := testCase .dave .RPC .DecodePayReq (invoice .PaymentRequest )
644+ require .Len (ht , payReq .BlindedPaths , 1 )
645+ path := payReq .BlindedPaths [0 ].BlindedPath
646+ require .Len (ht , path .BlindedHops , 1 )
647+ require .EqualValues (ht , path .IntroductionNode , testCase .dave .PubKey [:])
648+
649+ // Now let Alice pay the invoice.
650+ ht .CompletePaymentRequests (ht .Alice , []string {invoice .PaymentRequest })
621651}
622652
623653// testReceiverBlindedError tests handling of errors from the receiving node in
0 commit comments