Test that if we crash with an unconfirmed connection to a known peer, we don't have a dangling peer in db
(node_factory, bitcoind, executor)
| 3340 | @pytest.mark.openchannel('v1') |
| 3341 | @pytest.mark.openchannel('v2') |
| 3342 | def test_fail_unconfirmed(node_factory, bitcoind, executor): |
| 3343 | """Test that if we crash with an unconfirmed connection to a known |
| 3344 | peer, we don't have a dangling peer in db""" |
| 3345 | if EXPERIMENTAL_DUAL_FUND: |
| 3346 | disconnect = ['=WIRE_OPEN_CHANNEL2'] |
| 3347 | else: |
| 3348 | disconnect = ['=WIRE_OPEN_CHANNEL'] |
| 3349 | # = is a NOOP disconnect, but sets up file. |
| 3350 | l1 = node_factory.get_node(disconnect=disconnect) |
| 3351 | l2 = node_factory.get_node() |
| 3352 | |
| 3353 | # First one, we close by mutual agreement. |
| 3354 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3355 | l1.fundchannel(l2, 200000, wait_for_active=True) |
| 3356 | l1.rpc.close(l2.info['id']) |
| 3357 | |
| 3358 | # Make sure it's closed |
| 3359 | l1.wait_for_channel_onchain(l2.info['id']) |
| 3360 | bitcoind.generate_block(1) |
| 3361 | l1.daemon.wait_for_log('State changed from CLOSINGD_COMPLETE to FUNDING_SPEND_SEEN') |
| 3362 | |
| 3363 | l1.stop() |
| 3364 | # Mangle disconnect file so this time it blackholes.... |
| 3365 | with open(l1.daemon.disconnect_file, "w") as f: |
| 3366 | if EXPERIMENTAL_DUAL_FUND: |
| 3367 | f.write("0WIRE_OPEN_CHANNEL2\n") |
| 3368 | else: |
| 3369 | f.write("0WIRE_OPEN_CHANNEL\n") |
| 3370 | l1.start() |
| 3371 | |
| 3372 | # Now we establish a new channel, which gets stuck. |
| 3373 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3374 | l1.fundwallet(10**7) |
| 3375 | executor.submit(l1.rpc.fundchannel, l2.info['id'], 100000) |
| 3376 | |
| 3377 | l1.daemon.wait_for_log("dev_disconnect") |
| 3378 | |
| 3379 | # Now complete old channel. |
| 3380 | bitcoind.generate_block(100) |
| 3381 | l1.daemon.wait_for_log('onchaind complete, forgetting peer') |
| 3382 | |
| 3383 | # And crash l1, which is stuck. |
| 3384 | l1.daemon.kill() |
| 3385 | |
| 3386 | # Now, restart and see if it can connect OK. |
| 3387 | l1.daemon.disconnect = None |
| 3388 | l1.start() |
| 3389 | |
| 3390 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3391 | l1.fundchannel(l2, 200000, wait_for_active=True) |
| 3392 | |
| 3393 | |
| 3394 | @pytest.mark.skip('needs blackhold support') |
nothing calls this directly
no test coverage detected