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:1856–1923  ·  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

1854
1855
1856def test_pay_avoid_low_fee_chan(node_factory, bitcoind, executor, chainparams):
1857 """Make sure we're able to route around a low fee depleted channel """
1858
1859 # NOTE: This test did not consistently fail. If this test is flaky, that
1860 # probably means it needs to be fixed!
1861
1862 # Setup:
1863 # l1 - l2 ------ l4
1864 # \ /
1865 # - l3 -
1866 # l2 is connected to the destination
1867 # l3 is also connected to l2 and the destination, with a low fee
1868 # path. The channel however, is depleted.
1869 l1, l2, l3, l4 = node_factory.get_nodes(4)
1870 node_factory.join_nodes([l1, l2, l4])
1871
1872 # l2 has a depleted channel to l3. Mimic this by opening the
1873 # channel the other way around.
1874 node_factory.join_nodes([l3, l2])
1875 node_factory.join_nodes([l3, l4])
1876
1877 l2l3_scid = first_scid(l2, l3)
1878 l2l4_scid = first_scid(l2, l4)
1879 l3l4_scid = first_scid(l3, l4)
1880
1881 # Set relevant fees:
1882 # - High fee from l2 to l4
1883 # - Low fee from l2 to l3 and l3 to l4
1884 l2.rpc.setchannel(l2l4_scid, feebase=0, feeppm=2000, htlcmin=1)
1885 l2.rpc.setchannel(l2l3_scid, feebase=0, feeppm=1, htlcmin=1)
1886 l3.rpc.setchannel(l3l4_scid, feebase=0, feeppm=1, htlcmin=1)
1887
1888 # Make sure l1 sees all the channels.
1889 mine_funding_to_announce(bitcoind, [l1, l2, l3, l4])
1890
1891 def has_gossip():
1892 channels = l1.rpc.listchannels()['channels']
1893 if len(channels) != 4 * 2:
1894 return False
1895
1896 if sum(1 for c in channels if c['fee_per_millionth'] == 1) != 2:
1897 return False
1898
1899 if sum(1 for c in channels if c['fee_per_millionth'] == 2000) != 1:
1900 return False
1901
1902 return True
1903
1904 wait_for(has_gossip)
1905
1906 def listpays_nofail(b11):
1907 while True:
1908 pays = l1.rpc.listpays(b11)['pays']
1909 if len(pays) != 0:
1910 if only_one(pays)['status'] == 'complete':
1911 return
1912 assert only_one(pays)['status'] != 'failed'
1913

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