Skip to content

Commit cb03804

Browse files
committed
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.
1 parent 7f5ae70 commit cb03804

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

itest/assets_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,7 @@ func sendKeySendPayment(t *testing.T, src, dst *HarnessNode,
13971397
DestCustomRecords: customRecords,
13981398
PaymentHash: hash[:],
13991399
TimeoutSeconds: int32(PaymentTimeout.Seconds()),
1400-
FeeLimitMsat: 1_000_000,
1400+
FeeLimitMsat: int64(cfg.feeLimit),
14011401
MaxParts: cfg.maxShards,
14021402
OutgoingChanIds: cfg.outgoingChanIDs,
14031403
AllowSelfPayment: cfg.allowSelfPayment,
@@ -1477,7 +1477,7 @@ func payPayReqWithSatoshi(t *testing.T, payer *HarnessNode, payReq string,
14771477
sendReq := &routerrpc.SendPaymentRequest{
14781478
PaymentRequest: payReq,
14791479
TimeoutSeconds: int32(PaymentTimeout.Seconds()),
1480-
FeeLimitMsat: 1_000_000,
1480+
FeeLimitMsat: int64(cfg.feeLimit),
14811481
MaxParts: cfg.maxShards,
14821482
OutgoingChanIds: cfg.outgoingChanIDs,
14831483
AllowSelfPayment: cfg.allowSelfPayment,

itest/litd_custom_channels_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2901,6 +2901,54 @@ func testCustomChannelsLiquidityEdgeCasesCore(ctx context.Context,
29012901
)
29022902

29032903
logBalance(t.t, nodes, assetID, "after safe asset htlc failure")
2904+
2905+
// Another test case: Make sure an asset invoice contains the correct
2906+
// channel policy. We expect it to be the policy for the direction from
2907+
// edge node to receiver node. To test this, we first set two different
2908+
// policies on the channel between Erin and Fabia.
2909+
resp, err := erin.UpdateChannelPolicy(ctx, &lnrpc.PolicyUpdateRequest{
2910+
Scope: &lnrpc.PolicyUpdateRequest_ChanPoint{
2911+
ChanPoint: chanPointEF,
2912+
},
2913+
BaseFeeMsat: 31337,
2914+
FeeRatePpm: 443322,
2915+
TimeLockDelta: 19,
2916+
})
2917+
require.NoError(t.t, err)
2918+
require.Empty(t.t, resp.FailedUpdates)
2919+
2920+
resp, err = fabia.UpdateChannelPolicy(ctx, &lnrpc.PolicyUpdateRequest{
2921+
Scope: &lnrpc.PolicyUpdateRequest_ChanPoint{
2922+
ChanPoint: chanPointEF,
2923+
},
2924+
BaseFeeMsat: 42069,
2925+
FeeRatePpm: 223344,
2926+
TimeLockDelta: 18,
2927+
})
2928+
require.NoError(t.t, err)
2929+
require.Empty(t.t, resp.FailedUpdates)
2930+
2931+
// We now create an invoice on Fabia and expect Erin's policy to be used
2932+
// in the invoice.
2933+
invoiceResp = createAssetInvoice(t.t, erin, fabia, 1_000, assetID)
2934+
req, err := erin.DecodePayReq(ctx, &lnrpc.PayReqString{
2935+
PayReq: invoiceResp.PaymentRequest,
2936+
})
2937+
require.NoError(t.t, err)
2938+
2939+
require.Len(t.t, req.RouteHints, 1)
2940+
require.Len(t.t, req.RouteHints[0].HopHints, 1)
2941+
invoiceHint := req.RouteHints[0].HopHints[0]
2942+
require.Equal(t.t, erin.PubKeyStr, invoiceHint.NodeId)
2943+
require.EqualValues(t.t, 31337, invoiceHint.FeeBaseMsat)
2944+
require.EqualValues(t.t, 443322, invoiceHint.FeeProportionalMillionths)
2945+
require.EqualValues(t.t, 19, invoiceHint.CltvExpiryDelta)
2946+
2947+
// Now we pay the invoice and expect the same policy with very expensive
2948+
// fees to be used.
2949+
payInvoiceWithSatoshi(
2950+
t.t, dave, invoiceResp, withFeeLimit(100_000_000),
2951+
)
29042952
}
29052953

29062954
// testCustomChannelsLiquidityEdgeCases is a test that runs through some

0 commit comments

Comments
 (0)