lnrpc: add wire records fields to payment+interceptor RPCs

This commit is contained in:
George Tsagkarelis authored and Oliver Gugger committed 2024-09-05 11:18:16 +02:00
1 parent 878f964a33
commit 42e358e3d3
9 files changed
+902 -681

No files matched your search

+33 -17
View File
@@ -519,7 +519,7 @@ func TestChannelUpdateValidation(t *testing.T) {
// Send off the payment request to the router. The specified route
// should be attempted and the channel update should be received by
// graph and ignored because it is missing a valid signature.
_, err = ctx.router.SendToRoute(payment, rt)
_, err = ctx.router.SendToRoute(payment, rt, nil)
require.Error(t, err, "expected route to fail with channel update")
_, e1, e2, err = ctx.graph.FetchChannelEdgesByID(
@@ -539,7 +539,7 @@ func TestChannelUpdateValidation(t *testing.T) {
ctx.graphBuilder.setNextReject(false)
// Retry the payment using the same route as before.
_, err = ctx.router.SendToRoute(payment, rt)
_, err = ctx.router.SendToRoute(payment, rt, nil)
require.Error(t, err, "expected route to fail with channel update")
// This time a valid signature was supplied and the policy change should
@@ -1428,7 +1428,7 @@ func TestSendToRouteStructuredError(t *testing.T) {
// update should be received by router and ignored
// because it is missing a valid
// signature.
_, err = ctx.router.SendToRoute(payment, rt)
_, err = ctx.router.SendToRoute(payment, rt, nil)
fErr, ok := err.(*htlcswitch.ForwardingError)
require.True(
@@ -1507,7 +1507,7 @@ func TestSendToRouteMaxHops(t *testing.T) {
// Send off the payment request to the router. We expect an error back
// indicating that the route is too long.
var payHash lntypes.Hash
_, err = ctx.router.SendToRoute(payHash, rt)
_, err = ctx.router.SendToRoute(payHash, rt, nil)
if err != route.ErrMaxRouteHopsExceeded {
t.Fatalf("expected ErrMaxRouteHopsExceeded, but got %v", err)
}
@@ -1649,12 +1649,16 @@ func TestBuildRoute(t *testing.T) {
// Test that we can't build a route when no hops are given.
hops = []route.Vertex{}
_, err = ctx.router.BuildRoute(noAmt, hops, nil, 40, nil)
_, err = ctx.router.BuildRoute(
noAmt, hops, nil, 40, nil, fn.None[[]byte](),
)
require.Error(t, err)
// Create hop list for an unknown destination.
hops := []route.Vertex{ctx.aliases["b"], ctx.aliases["y"]}
_, err = ctx.router.BuildRoute(noAmt, hops, nil, 40, &payAddr)
_, err = ctx.router.BuildRoute(
noAmt, hops, nil, 40, &payAddr, fn.None[[]byte](),
)
noChanErr := ErrNoChannel{}
require.ErrorAs(t, err, &noChanErr)
require.Equal(t, 1, noChanErr.position)
@@ -1664,7 +1668,9 @@ func TestBuildRoute(t *testing.T) {
amt := lnwire.NewMSatFromSatoshis(100)
// Build the route for the given amount.
rt, err := ctx.router.BuildRoute(fn.Some(amt), hops, nil, 40, &payAddr)
rt, err := ctx.router.BuildRoute(
fn.Some(amt), hops, nil, 40, &payAddr, fn.None[[]byte](),
)
require.NoError(t, err)
// Check that we get the expected route back. The total amount should be
@@ -1674,7 +1680,9 @@ func TestBuildRoute(t *testing.T) {
require.Equal(t, lnwire.MilliSatoshi(106000), rt.TotalAmount)
// Build the route for the minimum amount.
rt, err = ctx.router.BuildRoute(noAmt, hops, nil, 40, &payAddr)
rt, err = ctx.router.BuildRoute(
noAmt, hops, nil, 40, &payAddr, fn.None[[]byte](),
)
require.NoError(t, err)
// Check that we get the expected route back. The minimum that we can
@@ -1690,7 +1698,9 @@ func TestBuildRoute(t *testing.T) {
// Test a route that contains incompatible channel htlc constraints.
// There is no amount that can pass through both channel 5 and 4.
hops = []route.Vertex{ctx.aliases["e"], ctx.aliases["c"]}
_, err = ctx.router.BuildRoute(noAmt, hops, nil, 40, nil)
_, err = ctx.router.BuildRoute(
noAmt, hops, nil, 40, nil, fn.None[[]byte](),
)
require.Error(t, err)
noChanErr = ErrNoChannel{}
require.ErrorAs(t, err, &noChanErr)
@@ -1708,7 +1718,9 @@ func TestBuildRoute(t *testing.T) {
// amount that could be delivered to the receiver of 21819 msat, using
// policy of channel 3.
hops = []route.Vertex{ctx.aliases["b"], ctx.aliases["z"]}
rt, err = ctx.router.BuildRoute(noAmt, hops, nil, 40, &payAddr)
rt, err = ctx.router.BuildRoute(
noAmt, hops, nil, 40, &payAddr, fn.None[[]byte](),
)
require.NoError(t, err)
checkHops(rt, []uint64{1, 8}, payAddr)
require.Equal(t, lnwire.MilliSatoshi(21200), rt.TotalAmount)
@@ -1720,7 +1732,9 @@ func TestBuildRoute(t *testing.T) {
// We get 106000 - 1000 (base in) - 0.001 * 106000 (rate in) = 104894.
hops = []route.Vertex{ctx.aliases["d"], ctx.aliases["f"]}
amt = lnwire.NewMSatFromSatoshis(100)
rt, err = ctx.router.BuildRoute(fn.Some(amt), hops, nil, 40, &payAddr)
rt, err = ctx.router.BuildRoute(
fn.Some(amt), hops, nil, 40, &payAddr, fn.None[[]byte](),
)
require.NoError(t, err)
checkHops(rt, []uint64{9, 10}, payAddr)
require.EqualValues(t, 104894, rt.TotalAmount)
@@ -1734,7 +1748,9 @@ func TestBuildRoute(t *testing.T) {
// of 20179 msat, which results in underpayment of 1 msat in fee. There
// is a third pass through newRoute in which this gets corrected to end
hops = []route.Vertex{ctx.aliases["d"], ctx.aliases["f"]}
rt, err = ctx.router.BuildRoute(noAmt, hops, nil, 40, &payAddr)
rt, err = ctx.router.BuildRoute(
noAmt, hops, nil, 40, &payAddr, fn.None[[]byte](),
)
require.NoError(t, err)
checkHops(rt, []uint64{9, 10}, payAddr)
require.EqualValues(t, 20180, rt.TotalAmount, "%v", rt.TotalAmount)
@@ -2208,7 +2224,7 @@ func TestSendToRouteSkipTempErrSuccess(t *testing.T) {
payment.On("TerminalInfo").Return(nil, nil)
// Expect a successful send to route.
attempt, err := router.SendToRouteSkipTempErr(payHash, rt)
attempt, err := router.SendToRouteSkipTempErr(payHash, rt, nil)
require.NoError(t, err)
require.Equal(t, testAttempt, attempt)
@@ -2261,7 +2277,7 @@ func TestSendToRouteSkipTempErrNonMPP(t *testing.T) {
}}
// Expect an error to be returned.
attempt, err := router.SendToRouteSkipTempErr(payHash, rt)
attempt, err := router.SendToRouteSkipTempErr(payHash, rt, nil)
require.ErrorIs(t, ErrSkipTempErr, err)
require.Nil(t, attempt)
@@ -2345,7 +2361,7 @@ func TestSendToRouteSkipTempErrTempFailure(t *testing.T) {
payment.On("TerminalInfo").Return(nil, nil)
// Expect a failed send to route.
attempt, err := router.SendToRouteSkipTempErr(payHash, rt)
attempt, err := router.SendToRouteSkipTempErr(payHash, rt, nil)
require.Equal(t, tempErr, err)
require.Equal(t, testAttempt, attempt)
@@ -2432,7 +2448,7 @@ func TestSendToRouteSkipTempErrPermanentFailure(t *testing.T) {
payment.On("TerminalInfo").Return(nil, &failureReason)
// Expect a failed send to route.
attempt, err := router.SendToRouteSkipTempErr(payHash, rt)
attempt, err := router.SendToRouteSkipTempErr(payHash, rt, nil)
require.Equal(t, permErr, err)
require.Equal(t, testAttempt, attempt)
@@ -2517,7 +2533,7 @@ func TestSendToRouteTempFailure(t *testing.T) {
).Return(nil, nil)
// Expect a failed send to route.
attempt, err := router.SendToRoute(payHash, rt)
attempt, err := router.SendToRoute(payHash, rt, nil)
require.Equal(t, tempErr, err)
require.Equal(t, testAttempt, attempt)