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)
| 3291 | @pytest.mark.openchannel('v1') |
| 3292 | @pytest.mark.openchannel('v2') |
| 3293 | def test_fail_unconfirmed(node_factory, bitcoind, executor): |
| 3294 | """Test that if we crash with an unconfirmed connection to a known |
| 3295 | peer, we don't have a dangling peer in db""" |
| 3296 | if EXPERIMENTAL_DUAL_FUND: |
| 3297 | disconnect = ['=WIRE_OPEN_CHANNEL2'] |
| 3298 | else: |
| 3299 | disconnect = ['=WIRE_OPEN_CHANNEL'] |
| 3300 | # = is a NOOP disconnect, but sets up file. |
| 3301 | l1 = node_factory.get_node(disconnect=disconnect) |
| 3302 | l2 = node_factory.get_node() |
| 3303 | |
| 3304 | # First one, we close by mutual agreement. |
| 3305 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3306 | l1.fundchannel(l2, 200000, wait_for_active=True) |
| 3307 | l1.rpc.close(l2.info['id']) |
| 3308 | |
| 3309 | # Make sure it's closed |
| 3310 | l1.wait_for_channel_onchain(l2.info['id']) |
| 3311 | bitcoind.generate_block(1) |
| 3312 | l1.daemon.wait_for_log('State changed from CLOSINGD_COMPLETE to FUNDING_SPEND_SEEN') |
| 3313 | |
| 3314 | l1.stop() |
| 3315 | # Mangle disconnect file so this time it blackholes.... |
| 3316 | with open(l1.daemon.disconnect_file, "w") as f: |
| 3317 | if EXPERIMENTAL_DUAL_FUND: |
| 3318 | f.write("0WIRE_OPEN_CHANNEL2\n") |
| 3319 | else: |
| 3320 | f.write("0WIRE_OPEN_CHANNEL\n") |
| 3321 | l1.start() |
| 3322 | |
| 3323 | # Now we establish a new channel, which gets stuck. |
| 3324 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3325 | l1.fundwallet(10**7) |
| 3326 | executor.submit(l1.rpc.fundchannel, l2.info['id'], 100000) |
| 3327 | |
| 3328 | l1.daemon.wait_for_log("dev_disconnect") |
| 3329 | |
| 3330 | # Now complete old channel. |
| 3331 | bitcoind.generate_block(100) |
| 3332 | l1.daemon.wait_for_log('onchaind complete, forgetting peer') |
| 3333 | |
| 3334 | # And crash l1, which is stuck. |
| 3335 | l1.daemon.kill() |
| 3336 | |
| 3337 | # Now, restart and see if it can connect OK. |
| 3338 | l1.daemon.disconnect = None |
| 3339 | l1.start() |
| 3340 | |
| 3341 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3342 | l1.fundchannel(l2, 200000, wait_for_active=True) |
| 3343 | |
| 3344 | |
| 3345 | @pytest.mark.skip('needs blackhold support') |
nothing calls this directly
no test coverage detected