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

Function test_htlcs_cltv_only_difference

tests/test_pay.py:1725–1779  ·  view source on GitHub ↗
(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

1723
1724@pytest.mark.slow_test
1725def test_htlcs_cltv_only_difference(node_factory, bitcoind):
1726 # l1 -> l2 -> l3 -> l4
1727 # l4 ignores htlcs, so they stay.
1728 # l3 will see a reconnect from l4 when l4 restarts.
1729 l1, l2, l3, l4 = node_factory.line_graph(4, wait_for_announce=True, opts=[{}] * 2 + [{'dev-no-reconnect': None, 'may_reconnect': True}] * 2)
1730
1731 inv = l4.rpc.invoice(amount_msat=10**8, label='x', description='desc')
1732 h = inv['payment_hash']
1733 l4.rpc.dev_ignore_htlcs(id=l3.info['id'], ignore=True)
1734
1735 # L2 tries to pay
1736 r = l2.single_route(l4.info['id'], 10**8)
1737 l2.rpc.sendpay(r, h, payment_secret=inv['payment_secret'])
1738
1739 # Now increment CLTV
1740 bitcoind.generate_block(1)
1741 sync_blockheight(bitcoind, [l1, l2, l3, l4])
1742
1743 # L1 tries to pay
1744 r = l1.single_route(l4.info['id'], 10**8)
1745 l1.rpc.sendpay(r, h, payment_secret=inv['payment_secret'])
1746
1747 # Now increment CLTV
1748 bitcoind.generate_block(1)
1749 sync_blockheight(bitcoind, [l1, l2, l3, l4])
1750
1751 # L3 tries to pay
1752 r = l3.single_route(l4.info['id'], 10**8)
1753 l3.rpc.sendpay(r, h, payment_secret=inv['payment_secret'])
1754
1755 # Give them time to go through.
1756 time.sleep(5)
1757
1758 # Will all be connected OK.
1759 assert only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['connected']
1760 assert only_one(l2.rpc.listpeers(l3.info['id'])['peers'])['connected']
1761 assert only_one(l3.rpc.listpeers(l4.info['id'])['peers'])['connected']
1762
1763 # TODO Remove our reliance on HTLCs failing on startup and the need for
1764 # this plugin
1765 l4.daemon.opts['plugin'] = os.path.join(os.getcwd(), 'tests/plugins/fail_htlcs.py')
1766
1767 # Restarting tail node will stop it ignoring HTLCs (it will actually
1768 # fail them immediately).
1769 l4.restart()
1770 l3.rpc.connect(l4.info['id'], 'localhost', l4.port)
1771
1772 wait_for(lambda: only_one(l1.rpc.listsendpays()['payments'])['status'] == 'failed')
1773 wait_for(lambda: only_one(l2.rpc.listsendpays()['payments'])['status'] == 'failed')
1774 wait_for(lambda: only_one(l3.rpc.listsendpays()['payments'])['status'] == 'failed')
1775
1776 # Should all still be connected.
1777 assert only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['connected']
1778 assert only_one(l2.rpc.listpeers(l3.info['id'])['peers'])['connected']
1779 assert only_one(l3.rpc.listpeers(l4.info['id'])['peers'])['connected']
1780
1781
1782def test_pay_variants(node_factory):

Callers

nothing calls this directly

Calls 13

sync_blockheightFunction · 0.90
only_oneFunction · 0.90
wait_forFunction · 0.90
line_graphMethod · 0.80
single_routeMethod · 0.80
sendpayMethod · 0.80
generate_blockMethod · 0.80
joinMethod · 0.80
restartMethod · 0.80
listsendpaysMethod · 0.80
invoiceMethod · 0.45
listpeersMethod · 0.45

Tested by

no test coverage detected