Skip to content

Commit 5207897

Browse files
committed
itest: Add test for sendpayment with route hints
Adds an integration test to verify SendPayment successfully uses invoice route hints for payments involving private channels.
1 parent 3260ac6 commit 5207897

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

itest/list_on_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ var allTestCases = []*lntest.TestCase{
177177
Name: "send direct payment simple taproot",
178178
TestFunc: testSendDirectPaymentSimpleTaproot,
179179
},
180+
{
181+
Name: "sendpayment with route hints",
182+
TestFunc: testSendPaymentWithRouteHints,
183+
},
180184
{
181185
Name: "immediate payment after channel opened",
182186
TestFunc: testPaymentFollowingChannelOpen,

itest/lnd_payment_test.go

+45
Original file line numberDiff line numberDiff line change
@@ -1396,3 +1396,48 @@ func testSendPaymentKeysendMPPFail(ht *lntest.HarnessTest) {
13961396
_, err = ht.ReceivePaymentUpdate(client)
13971397
require.Error(ht, err)
13981398
}
1399+
1400+
// testSendPaymentWithRouteHints tests sending a payment using route hints
1401+
// derived from a private channel.
1402+
func testSendPaymentWithRouteHints(ht *lntest.HarnessTest) {
1403+
// Setup a three-node network: Alice -> Bob -> Carol.
1404+
alice := ht.NewNode("Alice", nil)
1405+
defer ht.Shutdown(alice)
1406+
bob := ht.NewNode("Bob", nil)
1407+
defer ht.Shutdown(bob)
1408+
carol := ht.NewNode("Carol", nil)
1409+
defer ht.Shutdown(carol)
1410+
1411+
ht.ConnectNodes(alice, bob)
1412+
ht.ConnectNodes(bob, carol)
1413+
1414+
// Fund Alice and Bob.
1415+
ht.FundCoins(btcutil.SatoshiPerBitcoin, alice)
1416+
ht.FundCoins(btcutil.SatoshiPerBitcoin, bob)
1417+
1418+
// Open channels: Alice -> Bob (public), Bob -> Carol (private).
1419+
const chanAmt = btcutil.Amount(1_000_000)
1420+
aliceBobChanPoint := ht.OpenChannel(
1421+
alice, bob, lntest.OpenChannelParams{Amt: chanAmt},
1422+
)
1423+
defer ht.CloseChannel(alice, aliceBobChanPoint)
1424+
bobCarolChanPoint := ht.OpenChannel(
1425+
bob, carol, lntest.OpenChannelParams{Amt: chanAmt, Private: true},
1426+
)
1427+
defer ht.CloseChannel(bob, bobCarolChanPoint)
1428+
1429+
sendReq := &routerrpc.SendPaymentRequest{
1430+
PaymentRequest: carol.RPC.AddInvoice(&lnrpc.Invoice{
1431+
Value: 10_000,
1432+
Private: true, // include route hints
1433+
}).PaymentRequest,
1434+
FeeLimitSat: int64(chanAmt),
1435+
TimeoutSeconds: 60,
1436+
}
1437+
1438+
// Send payment and assert success.
1439+
ht.AssertPaymentStatusFromStream(
1440+
alice.RPC.SendPayment(sendReq),
1441+
lnrpc.Payment_SUCCEEDED,
1442+
)
1443+
}

0 commit comments

Comments
 (0)