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

Function test_old_htlcs_cleanup

tests/test_wallet.py:2568–2588  ·  view source on GitHub ↗

We lazily delete htlcs from channel_htlcs table

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

2566
2567
2568def test_old_htlcs_cleanup(node_factory, bitcoind):
2569 """We lazily delete htlcs from channel_htlcs table"""
2570 l1, l2 = node_factory.line_graph(2)
2571
2572 for _ in range(10):
2573 l1.pay(l2, 1000)
2574
2575 l1.rpc.close(l2.info['id'])
2576 bitcoind.generate_block(100, wait_for_mempool=1)
2577 wait_for(lambda: l1.rpc.listpeerchannels() == {'channels': []})
2578 # We don't see them!
2579 assert l1.rpc.listhtlcs() == {'htlcs': []}
2580
2581 l1.stop()
2582 # They're still there.
2583 assert l1.db_query('SELECT COUNT(*) as c FROM channel_htlcs')[0]['c'] == 10
2584
2585 l1.start()
2586 # Now they're not
2587 assert l1.db_query('SELECT COUNT(*) as c FROM channel_htlcs')[0]['c'] == 0
2588 assert l1.rpc.listhtlcs() == {'htlcs': []}
2589
2590
2591@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "Makes use of the sqlite3 db")

Callers

nothing calls this directly

Calls 9

wait_forFunction · 0.90
line_graphMethod · 0.80
generate_blockMethod · 0.80
listpeerchannelsMethod · 0.80
db_queryMethod · 0.80
payMethod · 0.45
closeMethod · 0.45
stopMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected