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

Function test_pay_routeboost

tests/test_pay.py:1954–2051  ·  view source on GitHub ↗

Make sure we can use routeboost information. ```dot graph { l1 -- l2 -- l3 l3 -- l4 [style="dotted"] l4 -- l5 [style="dotted"] } ```

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

1952
1953@pytest.mark.slow_test
1954def test_pay_routeboost(node_factory, bitcoind):
1955 """Make sure we can use routeboost information.
1956
1957 ```dot
1958 graph {
1959 l1 -- l2 -- l3
1960 l3 -- l4 [style="dotted"]
1961 l4 -- l5 [style="dotted"]
1962 }
1963 ```
1964 """
1965 # l1->l2->l3--private-->l4
1966 l1, l2 = node_factory.line_graph(2, announce_channels=True, wait_for_announce=True)
1967 l3, l4, l5 = node_factory.line_graph(3, announce_channels=False, wait_for_announce=False)
1968
1969 with pytest.raises(RpcError, match=rf"Failed: Unknown destination node {l5.info['id']}"):
1970 l1.rpc.xpay(l5.rpc.invoice(10**8, 'test_retry', 'test_retry')['bolt11'])
1971
1972 l2.rpc.connect(l3.info['id'], 'localhost', l3.port)
1973 scidl2l3, _ = l2.fundchannel(l3, 10**6)
1974
1975 # Make sure l1 knows about the 2->3 channel.
1976 mine_funding_to_announce(bitcoind, [l1, l2, l3, l4, l5])
1977 l1.daemon.wait_for_logs([r'update for channel {}/0 now ACTIVE'
1978 .format(scidl2l3),
1979 r'update for channel {}/1 now ACTIVE'
1980 .format(scidl2l3)])
1981 # Make sure l4 knows about 2->3 channel too so it's not a dead-end.
1982 l4.daemon.wait_for_logs([r'update for channel {}/0 now ACTIVE'
1983 .format(scidl2l3),
1984 r'update for channel {}/1 now ACTIVE'
1985 .format(scidl2l3)])
1986
1987 # Get an l4 invoice; it should put the private channel in routeboost.
1988 inv = l4.rpc.invoice(10**5, 'test_pay_routeboost', 'test_pay_routeboost',
1989 exposeprivatechannels=True)
1990 assert 'warning_capacity' not in inv
1991 assert 'warning_offline' not in inv
1992 assert only_one(only_one(l1.rpc.decode(inv['bolt11'])['routes']))
1993
1994 # Now we should be able to pay it.
1995 ret = l1.rpc.xpay(inv['bolt11'], dev_use_shadow=False)
1996 assert ret['failed_parts'] == 0
1997 assert ret['successful_parts'] == 1
1998
1999 # With dev-route option we can test longer routehints.
2000 scid34 = l3.rpc.listpeerchannels(l4.info['id'])['channels'][0]['alias']['local']
2001 scid45 = l4.rpc.listpeerchannels(l5.info['id'])['channels'][0]['alias']['local']
2002 routel3l4l5 = [{'id': l3.info['id'],
2003 'short_channel_id': scid34,
2004 'fee_base_msat': 1000,
2005 'fee_proportional_millionths': 10,
2006 'cltv_expiry_delta': 6},
2007 {'id': l4.info['id'],
2008 'short_channel_id': scid45,
2009 'fee_base_msat': 1000,
2010 'fee_proportional_millionths': 10,
2011 'cltv_expiry_delta': 6}]

Callers

nothing calls this directly

Calls 12

mine_funding_to_announceFunction · 0.90
only_oneFunction · 0.90
line_graphMethod · 0.80
wait_for_logsMethod · 0.80
listpeerchannelsMethod · 0.80
dev_invoiceMethod · 0.80
xpayMethod · 0.45
invoiceMethod · 0.45
connectMethod · 0.45
fundchannelMethod · 0.45
decodeMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected