Skip to content

Commit fa16b1e

Browse files
committed
pytest: test that we don't delete htlcs as soon as channel closed, wait for restart.
Signed-off-by: Rusty Russell <[email protected]>
1 parent 959e713 commit fa16b1e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/test_wallet.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,3 +1885,26 @@ def test_onchain_missing_no_p2tr_migrate(node_factory, bitcoind):
18851885

18861886
# This can actually take a while for 100 blocks!
18871887
l2.daemon.wait_for_log('Rescan finished! 1 outputs recovered')
1888+
1889+
1890+
def test_old_htlcs_cleanup(node_factory, bitcoind):
1891+
"""We lazily delete htlcs from channel_htlcs table"""
1892+
l1, l2 = node_factory.line_graph(2)
1893+
1894+
for _ in range(10):
1895+
l1.pay(l2, 1000)
1896+
1897+
l1.rpc.close(l2.info['id'])
1898+
bitcoind.generate_block(100, wait_for_mempool=1)
1899+
wait_for(lambda: l1.rpc.listpeerchannels() == {'channels': []})
1900+
# We don't see them!
1901+
assert l1.rpc.listhtlcs() == {'htlcs': []}
1902+
1903+
l1.stop()
1904+
# They're still there.,
1905+
assert l1.db_query('SELECT COUNT(*) as c FROM channel_htlcs')[0]['c'] == 10
1906+
1907+
l1.start()
1908+
# Now they're not
1909+
assert l1.db_query('SELECT COUNT(*) as c FROM channel_htlcs')[0]['c'] == 0
1910+
assert l1.rpc.listhtlcs() == {'htlcs': []}

0 commit comments

Comments
 (0)