Just because we've seen the block doesn't mean onchaind has finished
starting up.
```
_____________________________ test_restorefrompeer _____________________________
[gw0] linux -- Python 3.10.15 /home/runner/.cache/pypoetry/virtualenvs/cln-meta-project-AqJ9wMix-py3.10/bin/python
node_factory = <pyln.testing.utils.NodeFactory object at 0x7fb8f3887f70>
bitcoind = <pyln.testing.utils.BitcoinD object at 0x7fb8f3886f50>
@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "deletes database, which is assumed sqlite3")
def test_restorefrompeer(node_factory, bitcoind):
"""
Test restorefrompeer
"""
l1, l2 = node_factory.get_nodes(2, [{'broken_log': 'ERROR: Unknown commitment #.*, recovering our funds!',
'experimental-peer-storage': None,
'may_reconnect': True,
'allow_bad_gossip': True},
{'experimental-peer-storage': None,
'may_reconnect': True}])
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
c12, _ = l1.fundchannel(l2, 10**5)
assert l1.daemon.is_in_log('Peer storage sent!')
assert l2.daemon.is_in_log('Peer storage sent!')
l1.stop()
os.unlink(os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, "lightningd.sqlite3"))
l1.start()
assert l1.daemon.is_in_log('Server started with public key')
# If this happens fast enough, connect fails with "disconnected
# during connection"
try:
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
except RpcError as err:
assert "disconnected during connection" in err.error['message']
l1.daemon.wait_for_log('peer_in WIRE_YOUR_PEER_STORAGE')
assert l1.rpc.restorefrompeer()['stubs'][0] == _['channel_id']
l1.daemon.wait_for_log('peer_out WIRE_ERROR')
l2.daemon.wait_for_log('State changed from CHANNELD_NORMAL to AWAITING_UNILATERAL')
bitcoind.generate_block(5, wait_for_mempool=1)
sync_blockheight(bitcoind, [l1, l2])
l1.daemon.wait_for_log(r'All outputs resolved.*')
wait_for(lambda: l1.rpc.listfunds()["channels"][0]["state"] == "ONCHAIN")
# Check if funds are recovered.
assert l1.rpc.listfunds()["channels"][0]["state"] == "ONCHAIN"
> assert l2.rpc.listfunds()["channels"][0]["state"] == "ONCHAIN"
E AssertionError: assert 'FUNDING_SPEND_SEEN' == 'ONCHAIN'
E - ONCHAIN
E + FUNDING_SPEND_SEEN
tests/test_misc.py:3044: AssertionError
```
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
182 KiB
182 KiB