Test that we recognize we haven't got all blocks from bitcoind
(node_factory, bitcoind, executor)
| 264 | @pytest.mark.openchannel('v1') |
| 265 | @pytest.mark.openchannel('v2') |
| 266 | def test_lightningd_still_loading(node_factory, bitcoind, executor): |
| 267 | """Test that we recognize we haven't got all blocks from bitcoind""" |
| 268 | |
| 269 | mock_release = Event() |
| 270 | |
| 271 | # This is slow enough that we're going to notice. |
| 272 | def mock_getblock(r): |
| 273 | conf_file = os.path.join(bitcoind.bitcoin_dir, 'bitcoin.conf') |
| 274 | brpc = RawProxy(btc_conf_file=conf_file) |
| 275 | if r['params'][0] == slow_blockid: |
| 276 | mock_release.wait(TIMEOUT) |
| 277 | return { |
| 278 | "result": brpc._call(r['method'], *r['params']), |
| 279 | "error": None, |
| 280 | "id": r['id'] |
| 281 | } |
| 282 | |
| 283 | # Start it, establish channel, get extra funds. |
| 284 | l1, l2, l3 = node_factory.get_nodes(3, opts=[{'may_reconnect': True, |
| 285 | 'wait_for_bitcoind_sync': False}, |
| 286 | {'may_reconnect': True, |
| 287 | 'wait_for_bitcoind_sync': False}, |
| 288 | {}]) |
| 289 | node_factory.join_nodes([l1, l2]) |
| 290 | |
| 291 | # Balance l1<->l2 channel |
| 292 | l1.pay(l2, 10**9 // 2) |
| 293 | |
| 294 | l1.stop() |
| 295 | |
| 296 | # Now make sure l2 is behind. |
| 297 | bitcoind.generate_block(2) |
| 298 | # Make sure l2/l3 are synced |
| 299 | sync_blockheight(bitcoind, [l2, l3]) |
| 300 | |
| 301 | # Make it slow grabbing the final block. |
| 302 | slow_blockid = bitcoind.rpc.getblockhash(bitcoind.rpc.getblockcount()) |
| 303 | l1.daemon.rpcproxy.mock_rpc('getblock', mock_getblock) |
| 304 | |
| 305 | l1.start(wait_for_bitcoind_sync=False) |
| 306 | |
| 307 | # It will warn about being out-of-sync. |
| 308 | assert 'warning_bitcoind_sync' not in l1.rpc.getinfo() |
| 309 | assert 'warning_lightningd_sync' in l1.rpc.getinfo() |
| 310 | |
| 311 | # Make sure it's connected to l2 (otherwise we get TEMPORARY_CHANNEL_FAILURE) |
| 312 | wait_for(lambda: only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['connected']) |
| 313 | wait_for(lambda: l1.rpc.getinfo()['blockheight'] == 104) |
| 314 | |
| 315 | # Payments will succced. |
| 316 | l1.pay(l2, 1000) |
| 317 | assert l1.daemon.is_in_log(r"Sending HTLC while still syncing with bitcoin network \(104 vs 105\)") |
| 318 | |
| 319 | # Attempting to fund an extremely large transaction should fail |
| 320 | # with a 'unsynced' error |
| 321 | with pytest.raises(RpcError, match=r'304'): |
| 322 | l1.rpc.txprepare([{l1.rpc.newaddr('bech32')['bech32']: '200000000sat'}]) |
| 323 |
nothing calls this directly
no test coverage detected