Test that we recognize we haven't got all blocks from bitcoind
(node_factory, bitcoind, executor)
| 142 | @pytest.mark.openchannel('v1') |
| 143 | @pytest.mark.openchannel('v2') |
| 144 | def test_lightningd_still_loading(node_factory, bitcoind, executor): |
| 145 | """Test that we recognize we haven't got all blocks from bitcoind""" |
| 146 | |
| 147 | mock_release = Event() |
| 148 | |
| 149 | # This is slow enough that we're going to notice. |
| 150 | def mock_getblock(r): |
| 151 | conf_file = os.path.join(bitcoind.bitcoin_dir, 'bitcoin.conf') |
| 152 | brpc = RawProxy(btc_conf_file=conf_file) |
| 153 | if r['params'][0] == slow_blockid: |
| 154 | mock_release.wait(TIMEOUT) |
| 155 | return { |
| 156 | "result": brpc._call(r['method'], *r['params']), |
| 157 | "error": None, |
| 158 | "id": r['id'] |
| 159 | } |
| 160 | |
| 161 | # Start it, establish channel, get extra funds. |
| 162 | l1, l2, l3 = node_factory.get_nodes(3, opts=[{'may_reconnect': True, |
| 163 | 'wait_for_bitcoind_sync': False}, |
| 164 | {'may_reconnect': True, |
| 165 | 'wait_for_bitcoind_sync': False}, |
| 166 | {}]) |
| 167 | node_factory.join_nodes([l1, l2]) |
| 168 | |
| 169 | # Balance l1<->l2 channel |
| 170 | l1.pay(l2, 10**9 // 2) |
| 171 | |
| 172 | l1.stop() |
| 173 | |
| 174 | # Now make sure l2 is behind. |
| 175 | bitcoind.generate_block(2) |
| 176 | # Make sure l2/l3 are synced |
| 177 | sync_blockheight(bitcoind, [l2, l3]) |
| 178 | |
| 179 | # Make it slow grabbing the final block. |
| 180 | slow_blockid = bitcoind.rpc.getblockhash(bitcoind.rpc.getblockcount()) |
| 181 | l1.daemon.rpcproxy.mock_rpc('getblock', mock_getblock) |
| 182 | |
| 183 | l1.start(wait_for_bitcoind_sync=False) |
| 184 | |
| 185 | # It will warn about being out-of-sync. |
| 186 | assert 'warning_bitcoind_sync' not in l1.rpc.getinfo() |
| 187 | assert 'warning_lightningd_sync' in l1.rpc.getinfo() |
| 188 | |
| 189 | # Make sure it's connected to l2 (otherwise we get TEMPORARY_CHANNEL_FAILURE) |
| 190 | wait_for(lambda: only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['connected']) |
| 191 | |
| 192 | # Payments will fail. FIXME: More informative msg? |
| 193 | with pytest.raises(RpcError, match=r'TEMPORARY_NODE_FAILURE'): |
| 194 | l1.pay(l2, 1000) |
| 195 | |
| 196 | # Can't fund a new channel. |
| 197 | l1.rpc.connect(l3.info['id'], 'localhost', l3.port) |
| 198 | with pytest.raises(RpcError, match=r'304'): |
| 199 | if l1.config('experimental-dual-fund'): |
| 200 | psbt = l1.rpc.fundpsbt('10000sat', '253perkw', 250)['psbt'] |
| 201 | l1.rpc.openchannel_init(l3.info['id'], '10000sat', psbt) |
nothing calls this directly
no test coverage detected