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

Function test_close_72_block_delay

tests/test_gossip.py:2044–2082  ·  view source on GitHub ↗
(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

2042
2043
2044def test_close_72_block_delay(node_factory, bitcoind):
2045 l1, l2, l3, l4 = node_factory.line_graph(4, wait_for_announce=True)
2046
2047 # Close l1-l2
2048 txid = only_one(l1.rpc.close(l2.info['id'])['txids'])
2049 bitcoind.generate_block(1, txid)
2050
2051 # But l4 doesn't believe it immediately.
2052 l4.daemon.wait_for_log("channel .* closing soon due to the funding outpoint being spent")
2053
2054 # Close l2-l3 one block later.
2055 txid = only_one(l2.rpc.close(l3.info['id'])['txids'])
2056 bitcoind.generate_block(1, txid)
2057 l4.daemon.wait_for_log("channel .* closing soon due to the funding outpoint being spent")
2058
2059 # BOLT #7:
2060 # - once its funding output has been spent OR reorganized out:
2061 # - SHOULD forget a channel after a 72-block delay.
2062
2063 # That implies 72 blocks *after* spending, i.e. 73 blocks deep!
2064
2065 # 72 blocks deep, l4 still sees it
2066 bitcoind.generate_block(70)
2067 sync_blockheight(bitcoind, [l4])
2068 assert len(l4.rpc.listchannels(source=l1.info['id'])['channels']) == 1
2069
2070 # 73 blocks deep does it.
2071 bitcoind.generate_block(1)
2072 wait_for(lambda: l4.rpc.listchannels(source=l1.info['id'])['channels'] == [])
2073
2074 # Other channel still visible.
2075 assert len(l4.rpc.listchannels(source=l2.info['id'])['channels']) == 1
2076
2077 # Restart: it remembers channel is dying.
2078 l4.restart()
2079
2080 # One more block, it's forgotten too.
2081 bitcoind.generate_block(1)
2082 wait_for(lambda: l4.rpc.listchannels(source=l2.info['id'])['channels'] == [])
2083
2084
2085def test_gossip_not_dying(node_factory, bitcoind):

Callers

nothing calls this directly

Calls 9

only_oneFunction · 0.90
sync_blockheightFunction · 0.90
wait_forFunction · 0.90
line_graphMethod · 0.80
generate_blockMethod · 0.80
wait_for_logMethod · 0.80
restartMethod · 0.80
closeMethod · 0.45
listchannelsMethod · 0.45

Tested by

no test coverage detected