MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_fail_unconfirmed_openchannel2

Function test_fail_unconfirmed_openchannel2

tests/test_connection.py:3218–3260  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

3216@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
3217@pytest.mark.openchannel('v2')
3218def test_fail_unconfirmed_openchannel2(node_factory, bitcoind, executor):
3219 """Test that if we crash with an unconfirmed connection to a known
3220 peer, we don't have a dangling peer in db"""
3221 # = is a NOOP disconnect, but sets up file.
3222 l1 = node_factory.get_node(disconnect=['=WIRE_OPEN_CHANNEL2'])
3223 l2 = node_factory.get_node()
3224
3225 # First one, we close by mutual agreement.
3226 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
3227 l1.fundchannel(l2, 200000, wait_for_active=True)
3228 l1.rpc.close(l2.info['id'])
3229
3230 # Make sure it's closed
3231 l1.wait_for_channel_onchain(l2.info['id'])
3232 bitcoind.generate_block(1)
3233 l1.daemon.wait_for_log('State changed from CLOSINGD_COMPLETE to FUNDING_SPEND_SEEN')
3234
3235 l1.stop()
3236 # Mangle disconnect file so this time it blackholes....
3237 with open(l1.daemon.disconnect_file, "w") as f:
3238 f.write("0WIRE_OPEN_CHANNEL2\n")
3239 l1.start()
3240
3241 # Now we establish a new channel, which gets stuck.
3242 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
3243 l1.fundwallet(10**7)
3244 executor.submit(l1.rpc.fundchannel, l2.info['id'], 100000)
3245
3246 l1.daemon.wait_for_log("dev_disconnect")
3247
3248 # Now complete old channel.
3249 bitcoind.generate_block(100)
3250 l1.daemon.wait_for_log('onchaind complete, forgetting peer')
3251
3252 # And crash l1, which is stuck.
3253 l1.daemon.kill()
3254
3255 # Now, restart and see if it can connect OK.
3256 del l1.daemon.opts['dev-disconnect']
3257 l1.start()
3258
3259 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
3260 l1.fundchannel(l2, 200000, wait_for_active=True)
3261
3262
3263@pytest.mark.openchannel('v1')

Callers

nothing calls this directly

Calls 12

generate_blockMethod · 0.80
wait_for_logMethod · 0.80
fundwalletMethod · 0.80
killMethod · 0.80
get_nodeMethod · 0.45
connectMethod · 0.45
fundchannelMethod · 0.45
closeMethod · 0.45
stopMethod · 0.45
writeMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected