Skip to content

Commit e90d1f4

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 be8adf7 commit e90d1f4

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

itest/litd_custom_channels_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,6 +2890,47 @@ func testCustomChannelsLiquidityEdgeCasesCore(ctx context.Context,
28902890
)
28912891

28922892
logBalance(t.t, nodes, assetID, "after safe asset htlc failure")
2893+
2894+
// Another test case: Make sure an asset invoice contains the correct
2895+
// channel policy. We expect it to be the policy for the direction from
2896+
// edge node to receiver node. To test this, we first set two different
2897+
// policies on the channel between Erin and Fabia.
2898+
resp, err := erin.UpdateChannelPolicy(ctx, &lnrpc.PolicyUpdateRequest{
2899+
Scope: &lnrpc.PolicyUpdateRequest_ChanPoint{
2900+
ChanPoint: chanPointEF,
2901+
},
2902+
BaseFeeMsat: 31337,
2903+
FeeRatePpm: 443322,
2904+
TimeLockDelta: 19,
2905+
})
2906+
require.NoError(t.t, err)
2907+
require.Empty(t.t, resp.FailedUpdates)
2908+
2909+
resp, err = fabia.UpdateChannelPolicy(ctx, &lnrpc.PolicyUpdateRequest{
2910+
Scope: &lnrpc.PolicyUpdateRequest_ChanPoint{
2911+
ChanPoint: chanPointEF,
2912+
},
2913+
BaseFeeMsat: 42069,
2914+
FeeRatePpm: 223344,
2915+
TimeLockDelta: 18,
2916+
})
2917+
require.NoError(t.t, err)
2918+
require.Empty(t.t, resp.FailedUpdates)
2919+
2920+
// We now create an invoice on Fabia and expect Erin's policy to be used
2921+
// in the invoice.
2922+
invoiceResp = createAssetInvoice(t.t, erin, fabia, 100_000, assetID)
2923+
req, err := erin.DecodePayReq(ctx, &lnrpc.PayReqString{
2924+
PayReq: invoiceResp.PaymentRequest,
2925+
})
2926+
require.NoError(t.t, err)
2927+
2928+
require.Len(t.t, req.RouteHints, 1)
2929+
require.Len(t.t, req.RouteHints[0].HopHints, 1)
2930+
invoiceHint := req.RouteHints[0].HopHints[0]
2931+
require.EqualValues(t.t, 31337, invoiceHint.FeeBaseMsat)
2932+
require.EqualValues(t.t, 443322, invoiceHint.FeeProportionalMillionths)
2933+
require.EqualValues(t.t, 19, invoiceHint.CltvExpiryDelta)
28932934
}
28942935

28952936
// testCustomChannelsLiquidityEdgeCases is a test that runs through some

0 commit comments

Comments
 (0)