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

Function test_fail_unconfirmed

tests/test_connection.py:3162–3211  ·  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

3160@pytest.mark.openchannel('v1')
3161@pytest.mark.openchannel('v2')
3162def test_fail_unconfirmed(node_factory, bitcoind, executor):
3163 """Test that if we crash with an unconfirmed connection to a known
3164 peer, we don't have a dangling peer in db"""
3165 if EXPERIMENTAL_DUAL_FUND:
3166 disconnect = ['=WIRE_OPEN_CHANNEL2']
3167 else:
3168 disconnect = ['=WIRE_OPEN_CHANNEL']
3169 # = is a NOOP disconnect, but sets up file.
3170 l1 = node_factory.get_node(disconnect=disconnect)
3171 l2 = node_factory.get_node()
3172
3173 # First one, we close by mutual agreement.
3174 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
3175 l1.fundchannel(l2, 200000, wait_for_active=True)
3176 l1.rpc.close(l2.info['id'])
3177
3178 # Make sure it's closed
3179 l1.wait_for_channel_onchain(l2.info['id'])
3180 bitcoind.generate_block(1)
3181 l1.daemon.wait_for_log('State changed from CLOSINGD_COMPLETE to FUNDING_SPEND_SEEN')
3182
3183 l1.stop()
3184 # Mangle disconnect file so this time it blackholes....
3185 with open(l1.daemon.disconnect_file, "w") as f:
3186 if EXPERIMENTAL_DUAL_FUND:
3187 f.write("0WIRE_OPEN_CHANNEL2\n")
3188 else:
3189 f.write("0WIRE_OPEN_CHANNEL\n")
3190 l1.start()
3191
3192 # Now we establish a new channel, which gets stuck.
3193 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
3194 l1.fundwallet(10**7)
3195 executor.submit(l1.rpc.fundchannel, l2.info['id'], 100000)
3196
3197 l1.daemon.wait_for_log("dev_disconnect")
3198
3199 # Now complete old channel.
3200 bitcoind.generate_block(100)
3201 l1.daemon.wait_for_log('onchaind complete, forgetting peer')
3202
3203 # And crash l1, which is stuck.
3204 l1.daemon.kill()
3205
3206 # Now, restart and see if it can connect OK.
3207 del l1.daemon.opts['dev-disconnect']
3208 l1.start()
3209
3210 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
3211 l1.fundchannel(l2, 200000, wait_for_active=True)
3212
3213
3214@pytest.mark.skip('needs blackhold support')

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