Skip to content

Commit

Permalink
lntest: add coverage for single hop blinded route query routes
Browse files Browse the repository at this point in the history
  • Loading branch information
carlaKC committed May 31, 2023
1 parent 703a231 commit d4e3175
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion itest/lnd_route_blinding.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import (
// it sets up a nework of Alice - Bob - Carol and creates a mock blinded route
// that uses Carol as the introduction node (plus dummy hops to cover multiple
// hops). The test simply asserts that the structure of the route is as
// expected.
// expected. It also includes the edge case of a single-hop blinded route,
// which indicates that the introduction node is the recipient.
func testQueryBlindedRoutes(ht *lntest.HarnessTest) {
var (
ctxb = context.Background()
Expand Down Expand Up @@ -287,6 +288,42 @@ func testQueryBlindedRoutes(ht *lntest.HarnessTest) {
require.NotNil(ht, htlcAttempt.Failure)
require.Equal(ht, uint32(2), htlcAttempt.Failure.FailureSourceIndex)

// Next, we test an edge case where just an introduction node is
// included as a "single hop blinded route".
introNodeBlinded := &lnrpc.BlindedPayment{
BlindedPath: &lnrpc.BlindedPath{
IntroductionNode: carol.PubKey[:],
BlindingPoint: blindingBytes,
BlindedHops: []*lnrpc.BlindedHop{
{
// The first hop in the blinded route is
// expected to be the introduction node.
BlindedNode: carolBlindedBytes,
EncryptedData: encryptedDataCarol,
},
},
},
// Fees and expiry are zero for single-hop blinded paths.
BaseFeeMsat: 0,
TotalCltvDelta: 0,
}
req = &lnrpc.QueryRoutesRequest{
AmtMsat: paymentAmt,
BlindedPath: []*lnrpc.BlindedPayment{
introNodeBlinded,
},
FinalCltvDelta: int32(finalDelta),
}

ctxt, cancel = context.WithTimeout(ctxb, defaultTimeout)
resp, err = alice.RPC.LN.QueryRoutes(ctxt, req)
cancel()
require.NoError(ht, err)

// Assert that we have one route, and two hops: Alice/Bob and Bob/Carol.
require.Len(ht, resp.Routes, 1)
require.Len(ht, resp.Routes[0].Hops, 2)

ht.CloseChannel(alice, chanPointAliceBob)
ht.CloseChannel(bob, chanPointBobCarol)
}

0 comments on commit d4e3175

Please sign in to comment.