From 8fca5d9e97e26e43753451fc0380bf7b5efdb93c Mon Sep 17 00:00:00 2001 From: ShahanaFarooqui Date: Mon, 21 Oct 2024 11:54:35 -0700 Subject: [PATCH] doc: Askrene examples Changelog-Added: Generating askrene examples by test script --- contrib/msggen/msggen/schema.json | 367 +++++++++++++++++- doc/schemas/lightning-askrene-age.json | 16 + .../lightning-askrene-create-channel.json | 16 + .../lightning-askrene-create-layer.json | 22 ++ .../lightning-askrene-disable-node.json | 13 + .../lightning-askrene-inform-channel.json | 24 ++ doc/schemas/lightning-askrene-listlayers.json | 78 +++- .../lightning-askrene-listreservations.json | 37 ++ .../lightning-askrene-remove-layer.json | 12 + doc/schemas/lightning-askrene-reserve.json | 40 ++ doc/schemas/lightning-askrene-unreserve.json | 40 ++ .../lightning-askrene-update-channel.json | 29 ++ doc/schemas/lightning-getroutes.json | 40 ++ tests/autogenerate-rpc-examples.py | 50 ++- 14 files changed, 781 insertions(+), 3 deletions(-) diff --git a/contrib/msggen/msggen/schema.json b/contrib/msggen/msggen/schema.json index 13bc2f9dec1e..f9e6609b053c 100644 --- a/contrib/msggen/msggen/schema.json +++ b/contrib/msggen/msggen/schema.json @@ -254,6 +254,22 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-age#1", + "method": "askrene-age", + "params": { + "layer": "test_layers", + "cutoff": 1738000000 + } + }, + "response": { + "layer": "test_layers", + "num_removed": 1 + } + } ] }, "lightning-askrene-create-channel.json": { @@ -326,6 +342,22 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-create-channel#1", + "method": "askrene-create-channel", + "params": { + "layer": "test_layers", + "source": "nodeid030303030303030303030303030303030303030303030303030303030303", + "destination": "nodeid010101010101010101010101010101010101010101010101010101010101", + "short_channel_id": "0x0x1", + "capacity_msat": "1000000sat" + } + }, + "response": {} + } ] }, "lightning-askrene-create-layer.json": { @@ -527,6 +559,28 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-create-layer#1", + "method": "askrene-create-layer", + "params": { + "layer": "test_layers" + } + }, + "response": { + "layers": [ + { + "layer": "test_layers", + "disabled_nodes": [], + "created_channels": [], + "channel_updates": [], + "constraints": [] + } + ] + } + } ] }, "lightning-askrene-disable-node.json": { @@ -576,6 +630,19 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-disable-node#1", + "method": "askrene-disable-node", + "params": { + "layer": "test_layers", + "node": "nodeid010101010101010101010101010101010101010101010101010101010101" + } + }, + "response": {} + } ] }, "lightning-askrene-inform-channel.json": { @@ -676,6 +743,30 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-inform-channel#1", + "method": "askrene-inform-channel", + "params": { + "layer": "test_layers", + "short_channel_id_dir": "0x0x1/1", + "amount_msat": 100000, + "inform": "unconstrained" + } + }, + "response": { + "constraints": [ + { + "layer": "test_layers", + "short_channel_id_dir": "0x0x1/1", + "timestamp": 1738000000, + "minimum_msat": 100000 + } + ] + } + } ] }, "lightning-askrene-listlayers.json": { @@ -873,10 +964,86 @@ "request": { "id": "example:askrene-listlayers#1", "method": "askrene-listlayers", + "params": [ + "test_layers" + ] + }, + "response": { + "layers": [ + { + "layer": "test_layers", + "disabled_nodes": [ + "nodeid010101010101010101010101010101010101010101010101010101010101" + ], + "created_channels": [ + { + "source": "nodeid010101010101010101010101010101010101010101010101010101010101", + "destination": "nodeid030303030303030303030303030303030303030303030303030303030303", + "short_channel_id": "0x0x1", + "capacity_msat": 1000000000 + } + ], + "channel_updates": [ + { + "short_channel_id_dir": "0x0x1/0", + "htlc_minimum_msat": 100, + "htlc_maximum_msat": 900000000, + "fee_base_msat": 1, + "fee_proportional_millionths": 2, + "cltv_expiry_delta": 18 + } + ], + "constraints": [ + { + "short_channel_id_dir": "0x0x1/1", + "timestamp": 1738000000, + "minimum_msat": 100000 + } + ] + } + ] + } + }, + { + "request": { + "id": "example:askrene-listlayers#2", + "method": "askrene-listlayers", "params": {} }, "response": { - "layers": [] + "layers": [ + { + "layer": "test_layers", + "disabled_nodes": [ + "nodeid010101010101010101010101010101010101010101010101010101010101" + ], + "created_channels": [ + { + "source": "nodeid010101010101010101010101010101010101010101010101010101010101", + "destination": "nodeid030303030303030303030303030303030303030303030303030303030303", + "short_channel_id": "0x0x1", + "capacity_msat": 1000000000 + } + ], + "channel_updates": [ + { + "short_channel_id_dir": "0x0x1/0", + "htlc_minimum_msat": 100, + "htlc_maximum_msat": 900000000, + "fee_base_msat": 1, + "fee_proportional_millionths": 2, + "cltv_expiry_delta": 18 + } + ], + "constraints": [ + { + "short_channel_id_dir": "0x0x1/1", + "timestamp": 1738000000, + "minimum_msat": 100000 + } + ] + } + ] } } ] @@ -951,6 +1118,43 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-listreservations#1", + "method": "askrene-listreservations", + "params": {} + }, + "response": { + "reservations": [ + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000, + "age_in_seconds": 2, + "command_id": "\"-c:askrene-reserve#62/cln:askrene-reserve#122\"" + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250001, + "age_in_seconds": 2, + "command_id": "\"-c:askrene-reserve#62/cln:askrene-reserve#122\"" + }, + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000000000, + "age_in_seconds": 2, + "command_id": "\"-c:askrene-reserve#66/cln:askrene-reserve#126\"" + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250000000000, + "age_in_seconds": 2, + "command_id": "\"-c:askrene-reserve#66/cln:askrene-reserve#126\"" + } + ] + } + } ] }, "lightning-askrene-remove-layer.json": { @@ -990,6 +1194,18 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-remove-layer#1", + "method": "askrene-remove-layer", + "params": { + "layer": "test_layers" + } + }, + "response": {} + } ] }, "lightning-askrene-reserve.json": { @@ -1051,6 +1267,46 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-reserve#1", + "method": "askrene-reserve", + "params": { + "path": [ + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000 + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250001 + } + ] + } + }, + "response": {} + }, + { + "request": { + "id": "example:askrene-reserve#2", + "method": "askrene-reserve", + "params": { + "path": [ + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000000000 + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250000000000 + } + ] + } + }, + "response": {} + } ] }, "lightning-askrene-unreserve.json": { @@ -1112,6 +1368,46 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-unreserve#1", + "method": "askrene-unreserve", + "params": { + "path": [ + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000 + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250001 + } + ] + } + }, + "response": {} + }, + { + "request": { + "id": "example:askrene-unreserve#2", + "method": "askrene-unreserve", + "params": { + "path": [ + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000000000 + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250000000000 + } + ] + } + }, + "response": {} + } ] }, "lightning-askrene-update-channel.json": { @@ -1188,6 +1484,35 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-update-channel#1", + "method": "askrene-update-channel", + "params": [ + "test_layers", + "0x0x1/0" + ] + }, + "response": {} + }, + { + "request": { + "id": "example:askrene-update-channel#2", + "method": "askrene-update-channel", + "params": { + "layer": "test_layers", + "short_channel_id_dir": "0x0x1/0", + "htlc_minimum_msat": 100, + "htlc_maximum_msat": 900000000, + "fee_base_msat": 1, + "fee_proportional_millionths": 2, + "cltv_expiry_delta": 18 + } + }, + "response": {} + } ] }, "lightning-autoclean-once.json": { @@ -14061,6 +14386,46 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:getroutes#1", + "method": "getroutes", + "params": { + "source": "nodeid010101010101010101010101010101010101010101010101010101010101", + "destination": "nodeid030303030303030303030303030303030303030303030303030303030303", + "amount_msat": 1250000, + "layers": [], + "maxfee_msat": 125000, + "final_cltv": 0 + } + }, + "response": { + "probability_ppm": 997501, + "routes": [ + { + "probability_ppm": 997501, + "amount_msat": 1250000, + "final_cltv": 0, + "path": [ + { + "short_channel_id_dir": "109x1x1/1", + "next_node_id": "nodeid020202020202020202020202020202020202020202020202020202020202", + "amount_msat": 1250026, + "delay": 12 + }, + { + "short_channel_id_dir": "123x1x1/0", + "next_node_id": "nodeid030303030303030303030303030303030303030303030303030303030303", + "amount_msat": 1250013, + "delay": 6 + } + ] + } + ] + } + } ] }, "lightning-help.json": { diff --git a/doc/schemas/lightning-askrene-age.json b/doc/schemas/lightning-askrene-age.json index 97527234d733..5771fad59fb4 100644 --- a/doc/schemas/lightning-askrene-age.json +++ b/doc/schemas/lightning-askrene-age.json @@ -59,5 +59,21 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-age#1", + "method": "askrene-age", + "params": { + "layer": "test_layers", + "cutoff": 1738000000 + } + }, + "response": { + "layer": "test_layers", + "num_removed": 1 + } + } ] } diff --git a/doc/schemas/lightning-askrene-create-channel.json b/doc/schemas/lightning-askrene-create-channel.json index f1acd0c8299b..b3f43e03f423 100644 --- a/doc/schemas/lightning-askrene-create-channel.json +++ b/doc/schemas/lightning-askrene-create-channel.json @@ -68,5 +68,21 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-create-channel#1", + "method": "askrene-create-channel", + "params": { + "layer": "test_layers", + "source": "nodeid030303030303030303030303030303030303030303030303030303030303", + "destination": "nodeid010101010101010101010101010101010101010101010101010101010101", + "short_channel_id": "0x0x1", + "capacity_msat": "1000000sat" + } + }, + "response": {} + } ] } diff --git a/doc/schemas/lightning-askrene-create-layer.json b/doc/schemas/lightning-askrene-create-layer.json index 566a2a1e947a..a77f61d5a043 100644 --- a/doc/schemas/lightning-askrene-create-layer.json +++ b/doc/schemas/lightning-askrene-create-layer.json @@ -197,5 +197,27 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-create-layer#1", + "method": "askrene-create-layer", + "params": { + "layer": "test_layers" + } + }, + "response": { + "layers": [ + { + "layer": "test_layers", + "disabled_nodes": [], + "created_channels": [], + "channel_updates": [], + "constraints": [] + } + ] + } + } ] } diff --git a/doc/schemas/lightning-askrene-disable-node.json b/doc/schemas/lightning-askrene-disable-node.json index 389dacaed91e..66d9cfe2c569 100644 --- a/doc/schemas/lightning-askrene-disable-node.json +++ b/doc/schemas/lightning-askrene-disable-node.json @@ -45,5 +45,18 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-disable-node#1", + "method": "askrene-disable-node", + "params": { + "layer": "test_layers", + "node": "nodeid010101010101010101010101010101010101010101010101010101010101" + } + }, + "response": {} + } ] } diff --git a/doc/schemas/lightning-askrene-inform-channel.json b/doc/schemas/lightning-askrene-inform-channel.json index b12de57fef3a..ecdbbc2dd5bb 100644 --- a/doc/schemas/lightning-askrene-inform-channel.json +++ b/doc/schemas/lightning-askrene-inform-channel.json @@ -96,5 +96,29 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-inform-channel#1", + "method": "askrene-inform-channel", + "params": { + "layer": "test_layers", + "short_channel_id_dir": "0x0x1/1", + "amount_msat": 100000, + "inform": "unconstrained" + } + }, + "response": { + "constraints": [ + { + "layer": "test_layers", + "short_channel_id_dir": "0x0x1/1", + "timestamp": 1738000000, + "minimum_msat": 100000 + } + ] + } + } ] } diff --git a/doc/schemas/lightning-askrene-listlayers.json b/doc/schemas/lightning-askrene-listlayers.json index a26b0fb4b851..d67a6fc2b73d 100644 --- a/doc/schemas/lightning-askrene-listlayers.json +++ b/doc/schemas/lightning-askrene-listlayers.json @@ -193,10 +193,86 @@ "request": { "id": "example:askrene-listlayers#1", "method": "askrene-listlayers", + "params": [ + "test_layers" + ] + }, + "response": { + "layers": [ + { + "layer": "test_layers", + "disabled_nodes": [ + "nodeid010101010101010101010101010101010101010101010101010101010101" + ], + "created_channels": [ + { + "source": "nodeid010101010101010101010101010101010101010101010101010101010101", + "destination": "nodeid030303030303030303030303030303030303030303030303030303030303", + "short_channel_id": "0x0x1", + "capacity_msat": 1000000000 + } + ], + "channel_updates": [ + { + "short_channel_id_dir": "0x0x1/0", + "htlc_minimum_msat": 100, + "htlc_maximum_msat": 900000000, + "fee_base_msat": 1, + "fee_proportional_millionths": 2, + "cltv_expiry_delta": 18 + } + ], + "constraints": [ + { + "short_channel_id_dir": "0x0x1/1", + "timestamp": 1738000000, + "minimum_msat": 100000 + } + ] + } + ] + } + }, + { + "request": { + "id": "example:askrene-listlayers#2", + "method": "askrene-listlayers", "params": {} }, "response": { - "layers": [] + "layers": [ + { + "layer": "test_layers", + "disabled_nodes": [ + "nodeid010101010101010101010101010101010101010101010101010101010101" + ], + "created_channels": [ + { + "source": "nodeid010101010101010101010101010101010101010101010101010101010101", + "destination": "nodeid030303030303030303030303030303030303030303030303030303030303", + "short_channel_id": "0x0x1", + "capacity_msat": 1000000000 + } + ], + "channel_updates": [ + { + "short_channel_id_dir": "0x0x1/0", + "htlc_minimum_msat": 100, + "htlc_maximum_msat": 900000000, + "fee_base_msat": 1, + "fee_proportional_millionths": 2, + "cltv_expiry_delta": 18 + } + ], + "constraints": [ + { + "short_channel_id_dir": "0x0x1/1", + "timestamp": 1738000000, + "minimum_msat": 100000 + } + ] + } + ] } } ] diff --git a/doc/schemas/lightning-askrene-listreservations.json b/doc/schemas/lightning-askrene-listreservations.json index 1886d9e1c19e..efa3a18ce9da 100644 --- a/doc/schemas/lightning-askrene-listreservations.json +++ b/doc/schemas/lightning-askrene-listreservations.json @@ -68,5 +68,42 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-listreservations#1", + "method": "askrene-listreservations", + "params": {} + }, + "response": { + "reservations": [ + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000, + "age_in_seconds": 2, + "command_id": "\"-c:askrene-reserve#62/cln:askrene-reserve#122\"" + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250001, + "age_in_seconds": 2, + "command_id": "\"-c:askrene-reserve#62/cln:askrene-reserve#122\"" + }, + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000000000, + "age_in_seconds": 2, + "command_id": "\"-c:askrene-reserve#66/cln:askrene-reserve#126\"" + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250000000000, + "age_in_seconds": 2, + "command_id": "\"-c:askrene-reserve#66/cln:askrene-reserve#126\"" + } + ] + } + } ] } diff --git a/doc/schemas/lightning-askrene-remove-layer.json b/doc/schemas/lightning-askrene-remove-layer.json index 541cf9529002..357dfae695d8 100644 --- a/doc/schemas/lightning-askrene-remove-layer.json +++ b/doc/schemas/lightning-askrene-remove-layer.json @@ -35,5 +35,17 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-remove-layer#1", + "method": "askrene-remove-layer", + "params": { + "layer": "test_layers" + } + }, + "response": {} + } ] } diff --git a/doc/schemas/lightning-askrene-reserve.json b/doc/schemas/lightning-askrene-reserve.json index 880eff109dfd..ff8bddf2132e 100644 --- a/doc/schemas/lightning-askrene-reserve.json +++ b/doc/schemas/lightning-askrene-reserve.json @@ -57,5 +57,45 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-reserve#1", + "method": "askrene-reserve", + "params": { + "path": [ + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000 + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250001 + } + ] + } + }, + "response": {} + }, + { + "request": { + "id": "example:askrene-reserve#2", + "method": "askrene-reserve", + "params": { + "path": [ + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000000000 + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250000000000 + } + ] + } + }, + "response": {} + } ] } diff --git a/doc/schemas/lightning-askrene-unreserve.json b/doc/schemas/lightning-askrene-unreserve.json index c214e56ddc75..8ff184f34412 100644 --- a/doc/schemas/lightning-askrene-unreserve.json +++ b/doc/schemas/lightning-askrene-unreserve.json @@ -57,5 +57,45 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-unreserve#1", + "method": "askrene-unreserve", + "params": { + "path": [ + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000 + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250001 + } + ] + } + }, + "response": {} + }, + { + "request": { + "id": "example:askrene-unreserve#2", + "method": "askrene-unreserve", + "params": { + "path": [ + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000000000 + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250000000000 + } + ] + } + }, + "response": {} + } ] } diff --git a/doc/schemas/lightning-askrene-update-channel.json b/doc/schemas/lightning-askrene-update-channel.json index c0f82dcdee0f..22d9bb891bcb 100644 --- a/doc/schemas/lightning-askrene-update-channel.json +++ b/doc/schemas/lightning-askrene-update-channel.json @@ -72,5 +72,34 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-update-channel#1", + "method": "askrene-update-channel", + "params": [ + "test_layers", + "0x0x1/0" + ] + }, + "response": {} + }, + { + "request": { + "id": "example:askrene-update-channel#2", + "method": "askrene-update-channel", + "params": { + "layer": "test_layers", + "short_channel_id_dir": "0x0x1/0", + "htlc_minimum_msat": 100, + "htlc_maximum_msat": 900000000, + "fee_base_msat": 1, + "fee_proportional_millionths": 2, + "cltv_expiry_delta": 18 + } + }, + "response": {} + } ] } diff --git a/doc/schemas/lightning-getroutes.json b/doc/schemas/lightning-getroutes.json index 12cabd461969..f35a865b29a9 100644 --- a/doc/schemas/lightning-getroutes.json +++ b/doc/schemas/lightning-getroutes.json @@ -173,5 +173,45 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:getroutes#1", + "method": "getroutes", + "params": { + "source": "nodeid010101010101010101010101010101010101010101010101010101010101", + "destination": "nodeid030303030303030303030303030303030303030303030303030303030303", + "amount_msat": 1250000, + "layers": [], + "maxfee_msat": 125000, + "final_cltv": 0 + } + }, + "response": { + "probability_ppm": 997501, + "routes": [ + { + "probability_ppm": 997501, + "amount_msat": 1250000, + "final_cltv": 0, + "path": [ + { + "short_channel_id_dir": "109x1x1/1", + "next_node_id": "nodeid020202020202020202020202020202020202020202020202020202020202", + "amount_msat": 1250026, + "delay": 12 + }, + { + "short_channel_id_dir": "123x1x1/0", + "next_node_id": "nodeid030303030303030303030303030303030303030303030303030303030303", + "amount_msat": 1250013, + "delay": 6 + } + ] + } + ] + } + } ] } diff --git a/tests/autogenerate-rpc-examples.py b/tests/autogenerate-rpc-examples.py index 2b6c4c0798c6..f09ad8726f31 100644 --- a/tests/autogenerate-rpc-examples.py +++ b/tests/autogenerate-rpc-examples.py @@ -1313,6 +1313,53 @@ def generate_splice_examples(node_factory, bitcoind): logger.error(f'Error in generating splicing examples: {e}') +def generate_askrene_examples(l1, l2, l3, c12, c23_2): + """Generates askrene related examples""" + try: + logger.info('Askrene Start...') + + def direction(src, dst): + if src < dst: + return 0 + return 1 + + direction12 = direction(l1.info['id'], l2.info['id']) + direction23 = direction(l2.info['id'], l3.info['id']) + scid12dir = f'{c12}/{direction12}' + scid23dir = f'{c23_2}/{direction23}' + update_example(node=l2, method='askrene-create-layer', params={'layer': 'test_layers'}) + update_example(node=l2, method='askrene-disable-node', params={'layer': 'test_layers', 'node': l1.info['id']}) + update_example(node=l2, method='askrene-update-channel', params=['test_layers', '0x0x1/0']) + update_example(node=l2, method='askrene-create-channel', params={'layer': 'test_layers', 'source': l3.info['id'], 'destination': l1.info['id'], 'short_channel_id': '0x0x1', 'capacity_msat': '1000000sat'}) + update_example(node=l2, method='askrene-update-channel', params={'layer': 'test_layers', 'short_channel_id_dir': '0x0x1/0', 'htlc_minimum_msat': 100, 'htlc_maximum_msat': 900000000, 'fee_base_msat': 1, 'fee_proportional_millionths': 2, 'cltv_expiry_delta': 18}) + askrene_inform_channel_res1 = update_example(node=l2, method='askrene-inform-channel', params={'layer': 'test_layers', 'short_channel_id_dir': '0x0x1/1', 'amount_msat': 100000, 'inform': 'unconstrained'}) + askrene_listlayers_res1 = update_example(node=l2, method='askrene-listlayers', params=['test_layers']) + update_example(node=l2, method='askrene-listlayers', params={}) + ts1 = only_one(only_one(askrene_listlayers_res1['layers'])['constraints'])['timestamp'] + update_example(node=l2, method='askrene-age', params={'layer': 'test_layers', 'cutoff': ts1 + 1}) + update_example(node=l2, method='askrene-remove-layer', params={'layer': 'test_layers'}) + update_example(node=l1, method='getroutes', params={'source': l1.info['id'], 'destination': l3.info['id'], 'amount_msat': 1250000, 'layers': [], 'maxfee_msat': 125000, 'final_cltv': 0}) + update_example(node=l1, method='askrene-reserve', params={'path': [{'short_channel_id_dir': scid12dir, 'amount_msat': 1250_000}, {'short_channel_id_dir': scid23dir, 'amount_msat': 1250_001}]}) + update_example(node=l1, method='askrene-reserve', params={'path': [{'short_channel_id_dir': scid12dir, 'amount_msat': 1250_000_000_000}, {'short_channel_id_dir': scid23dir, 'amount_msat': 1250_000_000_000}]}) + time.sleep(2) + askrene_listreservations_res1 = l1.rpc.askrene_listreservations() + askrene_listreservations_res1 = update_list_responses(askrene_listreservations_res1, list_key='reservations', slice_upto=5, update_func=lambda x, i: REPLACE_RESPONSE_VALUES.extend([{'data_keys': ['command_id'], 'original_value': x['command_id'], 'new_value': f'\"-c:askrene-reserve#6{(i + 1) * 2}/cln:askrene-reserve#12{(i + 1) * 2}\"'}]), sort=True, sort_key='amount_msat') + update_example(node=l1, method='askrene-listreservations', params={}, res=askrene_listreservations_res1, execute=False) + update_example(node=l1, method='askrene-unreserve', params={'path': [{'short_channel_id_dir': scid12dir, 'amount_msat': 1250_000}, {'short_channel_id_dir': scid23dir, 'amount_msat': 1250_001}]}) + update_example(node=l1, method='askrene-unreserve', params={'path': [{'short_channel_id_dir': scid12dir, 'amount_msat': 1250_000_000_000}, {'short_channel_id_dir': scid23dir, 'amount_msat': 1250_000_000_000}]}) + REPLACE_RESPONSE_VALUES.extend([ + {'data_keys': ['short_channel_id_dir'], 'original_value': scid12dir, 'new_value': f"{NEW_VALUES_LIST['c12']}/{direction12}"}, + {'data_keys': ['short_channel_id_dir'], 'original_value': scid23dir, 'new_value': f"{NEW_VALUES_LIST['c23_2']}/{direction23}"}, + {'data_keys': ['cutoff'], 'original_value': ts1 + 1, 'new_value': NEW_VALUES_LIST['time_at_800']}, + {'data_keys': ['timestamp'], 'original_value': askrene_inform_channel_res1['constraints'][0]['timestamp'], 'new_value': NEW_VALUES_LIST['time_at_800']}, + ]) + logger.info('Askrene Done!') + except TaskFinished: + raise + except Exception as e: + logger.error(f'Error in generating askrene examples: {e}') + + def generate_channels_examples(node_factory, bitcoind, l1, l3, l4, l5): """Generates fundchannel and openchannel related examples""" try: @@ -1783,7 +1830,6 @@ def generate_list_examples(l1, l2, l3, c12, c23_2, inv_l31, inv_l32, offer_l23, """Generates lists rpc examples""" try: logger.info('Lists Start...') - global REPLACE_RESPONSE_VALUES # Transactions Lists FUNDS_LEN = 3 listfunds_res1 = l1.rpc.listfunds() @@ -2013,6 +2059,7 @@ def list_missing_examples(): ALL_RPC_EXAMPLES = list_all_examples() ALL_METHOD_NAMES = [example['method'] for example in ALL_RPC_EXAMPLES] logger.info(f'This test can reproduce examples for {len(ALL_RPC_EXAMPLES)} methods: {ALL_METHOD_NAMES}') + logger.warning(f'This test ignores {len(IGNORE_RPCS_LIST)} rpc methods: {IGNORE_RPCS_LIST}') REGENERATING_RPCS = [rpc.strip() for rpc in os.getenv("REGENERATE").split(', ')] if os.getenv("REGENERATE") else ALL_METHOD_NAMES RPCS_STATUS = [False] * len(REGENERATING_RPCS) list_missing_examples() @@ -2025,6 +2072,7 @@ def list_missing_examples(): generate_wait_examples(l1, l2, bitcoind, executor) generate_utils_examples(l1, l2, l3, l4, l5, l6, c23_2, c34_2, inv_l11, inv_l22, rune_l21, bitcoind) generate_splice_examples(node_factory, bitcoind) + generate_askrene_examples(l1, l2, l3, c12, c23_2) generate_channels_examples(node_factory, bitcoind, l1, l3, l4, l5) generate_autoclean_delete_examples(l1, l2, l3, l4, l5, c12, c23) generate_backup_recovery_examples(node_factory, l4, l5, l6)