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)
| 3395 | @unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need') |
| 3396 | @pytest.mark.openchannel('v2') |
| 3397 | def test_fail_unconfirmed_openchannel2(node_factory, bitcoind, executor): |
| 3398 | """Test that if we crash with an unconfirmed connection to a known |
| 3399 | peer, we don't have a dangling peer in db""" |
| 3400 | # = is a NOOP disconnect, but sets up file. |
| 3401 | l1 = node_factory.get_node(disconnect=['=WIRE_OPEN_CHANNEL2']) |
| 3402 | l2 = node_factory.get_node() |
| 3403 | |
| 3404 | # First one, we close by mutual agreement. |
| 3405 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3406 | l1.fundchannel(l2, 200000, wait_for_active=True) |
| 3407 | l1.rpc.close(l2.info['id']) |
| 3408 | |
| 3409 | # Make sure it's closed |
| 3410 | l1.wait_for_channel_onchain(l2.info['id']) |
| 3411 | bitcoind.generate_block(1) |
| 3412 | l1.daemon.wait_for_log('State changed from CLOSINGD_COMPLETE to FUNDING_SPEND_SEEN') |
| 3413 | |
| 3414 | l1.stop() |
| 3415 | # Mangle disconnect file so this time it blackholes.... |
| 3416 | with open(l1.daemon.disconnect_file, "w") as f: |
| 3417 | f.write("0WIRE_OPEN_CHANNEL2\n") |
| 3418 | l1.start() |
| 3419 | |
| 3420 | # Now we establish a new channel, which gets stuck. |
| 3421 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3422 | l1.fundwallet(10**7) |
| 3423 | executor.submit(l1.rpc.fundchannel, l2.info['id'], 100000) |
| 3424 | |
| 3425 | l1.daemon.wait_for_log("dev_disconnect") |
| 3426 | |
| 3427 | # Now complete old channel. |
| 3428 | bitcoind.generate_block(100) |
| 3429 | l1.daemon.wait_for_log('onchaind complete, forgetting peer') |
| 3430 | |
| 3431 | # And crash l1, which is stuck. |
| 3432 | l1.daemon.kill() |
| 3433 | |
| 3434 | # Now, restart and see if it can connect OK. |
| 3435 | l1.daemon.disconnect = None |
| 3436 | l1.start() |
| 3437 | |
| 3438 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3439 | l1.fundchannel(l2, 200000, wait_for_active=True) |
| 3440 | |
| 3441 | |
| 3442 | @pytest.mark.openchannel('v1') |
nothing calls this directly
no test coverage detected