itest: add test case for policy in route hint

This commit tests that the routing policy of the correct peer (the
policy pointing toward the recipient of an invoice) is included in an
asset invoice.
This commit is contained in:
Oliver Gugger 2025-06-16 15:21:53 +02:00
parent fe9a36ceee
commit b0e1d552d1
No known key found for this signature in database
GPG key ID: 8E4256593F177720
2 changed files with 50 additions and 2 deletions

View file

@ -1397,7 +1397,7 @@ func sendKeySendPayment(t *testing.T, src, dst *HarnessNode,
DestCustomRecords: customRecords,
PaymentHash: hash[:],
TimeoutSeconds: int32(PaymentTimeout.Seconds()),
FeeLimitMsat: 1_000_000,
FeeLimitMsat: int64(cfg.feeLimit),
MaxParts: cfg.maxShards,
OutgoingChanIds: cfg.outgoingChanIDs,
AllowSelfPayment: cfg.allowSelfPayment,
@ -1477,7 +1477,7 @@ func payPayReqWithSatoshi(t *testing.T, payer *HarnessNode, payReq string,
sendReq := &routerrpc.SendPaymentRequest{
PaymentRequest: payReq,
TimeoutSeconds: int32(PaymentTimeout.Seconds()),
FeeLimitMsat: 1_000_000,
FeeLimitMsat: int64(cfg.feeLimit),
MaxParts: cfg.maxShards,
OutgoingChanIds: cfg.outgoingChanIDs,
AllowSelfPayment: cfg.allowSelfPayment,

View file

@ -2901,6 +2901,54 @@ func testCustomChannelsLiquidityEdgeCasesCore(ctx context.Context,
)
logBalance(t.t, nodes, assetID, "after safe asset htlc failure")
// Another test case: Make sure an asset invoice contains the correct
// channel policy. We expect it to be the policy for the direction from
// edge node to receiver node. To test this, we first set two different
// policies on the channel between Erin and Fabia.
resp, err := erin.UpdateChannelPolicy(ctx, &lnrpc.PolicyUpdateRequest{
Scope: &lnrpc.PolicyUpdateRequest_ChanPoint{
ChanPoint: chanPointEF,
},
BaseFeeMsat: 31337,
FeeRatePpm: 443322,
TimeLockDelta: 19,
})
require.NoError(t.t, err)
require.Empty(t.t, resp.FailedUpdates)
resp, err = fabia.UpdateChannelPolicy(ctx, &lnrpc.PolicyUpdateRequest{
Scope: &lnrpc.PolicyUpdateRequest_ChanPoint{
ChanPoint: chanPointEF,
},
BaseFeeMsat: 42069,
FeeRatePpm: 223344,
TimeLockDelta: 18,
})
require.NoError(t.t, err)
require.Empty(t.t, resp.FailedUpdates)
// We now create an invoice on Fabia and expect Erin's policy to be used
// in the invoice.
invoiceResp = createAssetInvoice(t.t, erin, fabia, 1_000, assetID)
req, err := erin.DecodePayReq(ctx, &lnrpc.PayReqString{
PayReq: invoiceResp.PaymentRequest,
})
require.NoError(t.t, err)
require.Len(t.t, req.RouteHints, 1)
require.Len(t.t, req.RouteHints[0].HopHints, 1)
invoiceHint := req.RouteHints[0].HopHints[0]
require.Equal(t.t, erin.PubKeyStr, invoiceHint.NodeId)
require.EqualValues(t.t, 31337, invoiceHint.FeeBaseMsat)
require.EqualValues(t.t, 443322, invoiceHint.FeeProportionalMillionths)
require.EqualValues(t.t, 19, invoiceHint.CltvExpiryDelta)
// Now we pay the invoice and expect the same policy with very expensive
// fees to be used.
payInvoiceWithSatoshi(
t.t, dave, invoiceResp, withFeeLimit(100_000_000),
)
}
// testCustomChannelsLiquidityEdgeCases is a test that runs through some