mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
pytest: fix race in test_gossip_not_dying
Writing to the gossip_store file is not explicitly synchronized, so it seems that connectd has not caught up with the dying flags we've set. Simply wait for a second. Hacky, but should work. ``` def test_gossip_not_dying(node_factory, bitcoind): l1 = node_factory.get_node() l2, l3 = node_factory.line_graph(2, wait_for_announce=True) l1.rpc.connect(l2.info['id'], 'localhost', l2.port) # Wait until it sees all the updates, node announcments. wait_for(lambda: len([n for n in l1.rpc.listnodes()['nodes'] if 'alias' in n]) + len(l1.rpc.listchannels()['channels']) == 4) def get_gossip(node): out = subprocess.run(['devtools/gossipwith', '--initial-sync', '--timeout-after=2', '{}@localhost:{}'.format(node.info['id'], node.port)], check=True, timeout=TIMEOUT, stdout=subprocess.PIPE).stdout msgs = [] while len(out): l, t = struct.unpack('>HH', out[0:4]) msg = out[2:2 + l] out = out[2 + l:] # Ignore pings, timestamp_filter if t == 265 or t == 18: continue # channel_announcement node_announcement or channel_update assert t == 256 or t == 257 or t == 258 msgs.append(msg) return msgs assert len(get_gossip(l1)) == 5 # Close l2->l3, mine block. l2.rpc.close(l3.info['id']) bitcoind.generate_block(1, wait_for_mempool=1) l1.daemon.wait_for_log("closing soon due to the funding outpoint being spent") # We won't gossip the dead channel any more (but we still propagate node_announcement) > assert len(get_gossip(l1)) == 2 E assert 4 == 2 E + where 4 = len([b'\x01\x01L\xc2\xbe\x08\xbb\xa8~\x8f\x80R\x9e`J\x1cS\x18|\x12\n\xe5_6\xb0\xa6S\x9fU\xae\x19\x9c\x1fXB\xab\x81N\x13\xdc\x8e}\xb9\xb0\xb6\xe6\x14h\xd4:\x90\xce\xc3\xad\x9ezR`~\xba@\xc9\x91e\x89\xab\x00\x07\x88\xa0\x00\n\x02i\xa2d\xb8\xa9`\x02-"6 \xa3Y\xa4\x7f\xf7\xf7\xacD|\x85\xc4l\x92=\xa53\x89"\x1a\x00T\xc1\x1c\x1e<\xa3\x1dY\x02-"SILENTARTIST-27fc801-modded\x00\x00\x00\x00\x00\x00\x00', b'\x01\x01M\x00\x86\x8e4\xc8\x90p\n\x98\xf7\xce4\x1e\xd9\xd6-6\xfb(\xf0\xe4\xb7\x90\x7f\x89\xb9\xfa\x00\x82\x1b\xeb\x1fY\x93\x1e\xe0c\xb2\x0e<\xe6\x06x\xb7\xe54};\xfbd\xa0\x01S\xcf\xe8{\xf8\x8f/\xa7\xc0\xe2h\x00\x07\x88\xa0\x00\n\x02i\xa2d\xb8\xa9`\x03]+\x11\x92\xdf\xba\x13N\x10\xe5@\x87]6n\xbc\x8b\xc3S\xd5\xaavk\x80\xc0\x90\xb3\x9c:]\x88]\x03]+HOPPINGFIRE-27fc801-modded\x00\x00\x00\x00\x00\x00\x00\x00', b'\x01\x02~\xe0\x13\xb4\x84Gz\xcf(\xd4w\xa7\x9bZ\x1a\xe82\xd1\xe1\x1bLm\xc8\n\xcd\xd4\xfb\x88\xf8\xc6\xdbt\\v\x89~\xd1.e\xc8\xa8o\x9c`\xd5\xa8\x97\x11l\xf2g\xcb\xa8\xcf\r\x869\xd3\xb5\xd5\x9a\xa0my\x9f\x87\xebX\x0b\x9e_\x11\xdc!\x1e\x9f\xb6j\xbb6\x99\x99\x90D\xf8\xfe\x14h\x01\x16#\x936B\x86\xc6\x00\x00g\x00\x00\x01\x00\x00d\xb8\xa9d\x01\x02\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\n\x00\x00\x00\x00;\x023\x80', b"\x01\x0284\xf1a\x86z\x8e\xf2\xe5'\xf7\xfe1\x8d\x96R\x0c\xe7\x1fj#\xaf\xbd/\xba\x10e\xd1\xccQ-\xcf/>\xa5g\xc6\xd8\x9cO \xe7~\xb3\xda\xe0\\vg\xfb\x02&T\x93\xa0\xd4\x95\x8e\xd5L\x12\x9a\xf7\xe6\x9f\x87\xebX\x0b\x9e_\x11\xdc!\x1e\x9f\xb6j\xbb6\x99\x99\x90D\xf8\xfe\x14h\x01\x16#\x936B\x86\xc6\x00\x00g\x00\x00\x01\x00\x00d\xb8\xa9d\x01\x03\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\n\x00\x00\x00\x00;\x023\x80"]) ``` Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
0ceee9390a
commit
745d3f6226
1 changed files with 2 additions and 1 deletions
|
@ -2268,7 +2268,8 @@ def test_gossip_not_dying(node_factory, bitcoind):
|
|||
|
||||
l1.daemon.wait_for_log("closing soon due to the funding outpoint being spent")
|
||||
|
||||
# We won't gossip the dead channel any more (but we still propagate node_announcement)
|
||||
# We won't gossip the dead channel any more (but we still propagate node_announcement). But connectd is not explicitly synced, so wait for "a bit".
|
||||
time.sleep(1)
|
||||
assert len(get_gossip(l1)) == 2
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue