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

Function test_pay_avoid_low_fee_chan

tests/test_pay.py:1883–1950  ·  view source on GitHub ↗

Make sure we're able to route around a low fee depleted channel

(node_factory, bitcoind, executor, chainparams)

Source from the content-addressed store, hash-verified

1881
1882
1883def test_pay_avoid_low_fee_chan(node_factory, bitcoind, executor, chainparams):
1884 """Make sure we're able to route around a low fee depleted channel """
1885
1886 # NOTE: This test did not consistently fail. If this test is flaky, that
1887 # probably means it needs to be fixed!
1888
1889 # Setup:
1890 # l1 - l2 ------ l4
1891 # \ /
1892 # - l3 -
1893 # l2 is connected to the destination
1894 # l3 is also connected to l2 and the destination, with a low fee
1895 # path. The channel however, is depleted.
1896 l1, l2, l3, l4 = node_factory.get_nodes(4)
1897 node_factory.join_nodes([l1, l2, l4])
1898
1899 # l2 has a depleted channel to l3. Mimic this by opening the
1900 # channel the other way around.
1901 node_factory.join_nodes([l3, l2])
1902 node_factory.join_nodes([l3, l4])
1903
1904 l2l3_scid = first_scid(l2, l3)
1905 l2l4_scid = first_scid(l2, l4)
1906 l3l4_scid = first_scid(l3, l4)
1907
1908 # Set relevant fees:
1909 # - High fee from l2 to l4
1910 # - Low fee from l2 to l3 and l3 to l4
1911 l2.rpc.setchannel(l2l4_scid, feebase=0, feeppm=2000, htlcmin=1)
1912 l2.rpc.setchannel(l2l3_scid, feebase=0, feeppm=1, htlcmin=1)
1913 l3.rpc.setchannel(l3l4_scid, feebase=0, feeppm=1, htlcmin=1)
1914
1915 # Make sure l1 sees all the channels.
1916 mine_funding_to_announce(bitcoind, [l1, l2, l3, l4])
1917
1918 def has_gossip():
1919 channels = l1.rpc.listchannels()['channels']
1920 if len(channels) != 4 * 2:
1921 return False
1922
1923 if sum(1 for c in channels if c['fee_per_millionth'] == 1) != 2:
1924 return False
1925
1926 if sum(1 for c in channels if c['fee_per_millionth'] == 2000) != 1:
1927 return False
1928
1929 return True
1930
1931 wait_for(has_gossip)
1932
1933 def listpays_nofail(b11):
1934 while True:
1935 pays = l1.rpc.listpays(b11)['pays']
1936 if len(pays) != 0:
1937 if only_one(pays)['status'] == 'complete':
1938 return
1939 assert only_one(pays)['status'] != 'failed'
1940

Callers

nothing calls this directly

Calls 8

first_scidFunction · 0.90
mine_funding_to_announceFunction · 0.90
wait_forFunction · 0.90
get_nodesMethod · 0.80
join_nodesMethod · 0.80
setchannelMethod · 0.80
invoiceMethod · 0.45
dev_payMethod · 0.45

Tested by

no test coverage detected