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