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

Function test_sourcefree_on_mods

tests/test_askrene.py:1219–1261  ·  view source on GitHub ↗

auto.sourcefree should also apply to layer-created channels

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

1217
1218
1219def test_sourcefree_on_mods(node_factory, bitcoind):
1220 """auto.sourcefree should also apply to layer-created channels"""
1221 gsfile, nodemap = generate_gossip_store([GenChannel(0, 1, forward=GenChannel.Half(propfee=10000)),
1222 GenChannel(0, 2, forward=GenChannel.Half(propfee=10000))])
1223
1224 l1 = node_factory.get_node(gossip_store_file=gsfile.name)
1225
1226 # Add a local channel from 0->l1 (we just needed a nodeid).
1227 l1.rpc.askrene_create_layer('test_layers')
1228 l1.rpc.askrene_create_channel('test_layers',
1229 nodemap[0],
1230 l1.info['id'],
1231 '0x3x3',
1232 '1000000sat')
1233 l1.rpc.askrene_update_channel(layer='test_layers',
1234 short_channel_id_dir=f'0x3x3/{direction(nodemap[0], l1.info["id"])}',
1235 enabled=True,
1236 htlc_minimum_msat=100,
1237 htlc_maximum_msat='900000sat',
1238 fee_base_msat=1000,
1239 fee_proportional_millionths=2000,
1240 cltv_expiry_delta=18)
1241 dir03 = direction(nodemap[0], l1.info['id'])
1242 routes = l1.rpc.getroutes(source=nodemap[0],
1243 destination=l1.info['id'],
1244 amount_msat=1000000,
1245 layers=['test_layers', 'auto.sourcefree'],
1246 maxfee_msat=100000,
1247 final_cltv=99)['routes']
1248 # Expect no fee.
1249 check_route_as_expected(routes, [[{'short_channel_id_dir': f'0x3x3/{dir03}',
1250 'amount_in_msat': 1000000, 'cltv_in': 99}]])
1251
1252 # NOT if we specify layers in the other order!
1253 routes = l1.rpc.getroutes(source=nodemap[0],
1254 destination=l1.info['id'],
1255 amount_msat=1000000,
1256 layers=['auto.sourcefree', 'test_layers'],
1257 maxfee_msat=100000,
1258 final_cltv=99)['routes']
1259 # Expect no fee.
1260 check_route_as_expected(routes, [[{'short_channel_id_dir': f'0x3x3/{dir03}',
1261 'amount_in_msat': 1003000, 'cltv_in': 117}]])
1262
1263
1264def test_live_spendable(node_factory, bitcoind):

Callers

nothing calls this directly

Calls 6

generate_gossip_storeFunction · 0.90
GenChannelClass · 0.90
check_route_as_expectedFunction · 0.85
getroutesMethod · 0.80
directionFunction · 0.70
get_nodeMethod · 0.45

Tested by

no test coverage detected