MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_xpay_user_layers

Function test_xpay_user_layers

tests/test_xpay.py:1189–1242  ·  view source on GitHub ↗
(node_factory)

Source from the content-addressed store, hash-verified

1187
1188
1189def test_xpay_user_layers(node_factory):
1190 l1, l2, l3, l4 = node_factory.get_nodes(
1191 4, opts={"may_reconnect": True, "xpay-handle-pay": True}
1192 )
1193 node_factory.join_nodes([l1, l2, l3], wait_for_announce=True)
1194 node_factory.join_nodes([l2, l4], wait_for_announce=True)
1195
1196 layer = "disable-chan23"
1197 l1.rpc.askrene_create_layer(layer=layer, persistent=True)
1198 scid = l2.rpc.listpeerchannels(l3.info["id"])["channels"][0]["short_channel_id"]
1199 direction = l2.rpc.listpeerchannels(l3.info["id"])["channels"][0]["direction"]
1200 l1.rpc.askrene_update_channel(
1201 layer=layer, enabled=False, short_channel_id_dir=f"{scid}/{direction}"
1202 )
1203
1204 layer = "disable-chan24"
1205 l1.rpc.askrene_create_layer(layer=layer, persistent=True)
1206 scid = l2.rpc.listpeerchannels(l4.info["id"])["channels"][0]["short_channel_id"]
1207 direction = l2.rpc.listpeerchannels(l4.info["id"])["channels"][0]["direction"]
1208 l1.rpc.askrene_update_channel(
1209 layer=layer, enabled=False, short_channel_id_dir=f"{scid}/{direction}"
1210 )
1211
1212 # Let us load these layers as user layers in xpay. Both payments should fail
1213 l1.stop()
1214 l1.daemon.opts["xpay-user-layer"] = ["disable-chan23", "disable-chan24"]
1215 l1.start()
1216 l1.rpc.connect(l2.info["id"], "localhost", l2.port)
1217 l1.daemon.wait_for_log(f"channeld.*: billboard: Channel ready for use")
1218 inv3 = l3.rpc.invoice(1000, "test-xpay-user-layer", "test-xpay-user-layer")[
1219 "bolt11"
1220 ]
1221 with pytest.raises(
1222 RpcError,
1223 match="We could not find a usable set of paths. All 1 channels to the destination are disabled.",
1224 ):
1225 l1.rpc.pay(inv3)
1226 inv4 = l4.rpc.invoice(1000, "test-xpay-user-layer", "test-xpay-user-layer")[
1227 "bolt11"
1228 ]
1229 with pytest.raises(
1230 RpcError,
1231 match="We could not find a usable set of paths. All 1 channels to the destination are disabled.",
1232 ):
1233 l1.rpc.pay(inv4)
1234
1235 # Without those layers, the same payments should go through
1236 l1.stop()
1237 del l1.daemon.opts["xpay-user-layer"]
1238 l1.start()
1239 l1.rpc.connect(l2.info["id"], "localhost", l2.port)
1240 l1.daemon.wait_for_log(f"channeld.*: billboard: Channel ready for use")
1241 l1.rpc.pay(inv3)
1242 l1.rpc.pay(inv4)
1243
1244
1245def test_xpay_get_error_with_update(node_factory):

Callers

nothing calls this directly

Calls 9

get_nodesMethod · 0.80
join_nodesMethod · 0.80
listpeerchannelsMethod · 0.80
wait_for_logMethod · 0.80
stopMethod · 0.45
startMethod · 0.45
connectMethod · 0.45
invoiceMethod · 0.45
payMethod · 0.45

Tested by

no test coverage detected