Skip to content

Commit d2c056b

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 5720db0 commit d2c056b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/test_wallet.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,3 +1885,23 @@ 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+
1901+
l1.stop()
1902+
# They're still there.
1903+
assert l1.db_query('SELECT COUNT(*) as c FROM channel_htlcs')[0]['c'] == 10
1904+
1905+
l1.start()
1906+
# Now they're not
1907+
assert l1.db_query('SELECT COUNT(*) as c FROM channel_htlcs')[0]['c'] == 0

0 commit comments

Comments
 (0)