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

Function test_connection_moved

tests/test_connection.py:296–318  ·  view source on GitHub ↗
(node_factory, executor)

Source from the content-addressed store, hash-verified

294
295
296def test_connection_moved(node_factory, executor):
297 slow_start = os.path.join(os.getcwd(), 'tests/plugins/slow_start.py')
298 options = {'may_reconnect': True, 'plugin': slow_start}
299 l1, l2 = node_factory.get_nodes(2, opts=options)
300
301 # Set up the plugin to wait for a connection
302 executor.submit(l1.rpc.waitconn)
303 log = l1.daemon.wait_for_log('listening for connections')
304 match = re.search(r'on port (\d*)', log)
305 assert match and len(match.groups()) == 1
306 hang_port = int(match.groups()[0])
307
308 # Attempt connection
309 fut_hang = executor.submit(l1.rpc.connect, l2.info['id'],
310 'localhost', hang_port)
311 l1.daemon.wait_for_log('connection from')
312
313 # Provide correct connection details
314 ret = l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
315 assert ret['address'] == {'type': 'ipv4', 'address': '127.0.0.1', 'port': l2.port}
316
317 # If we failed to update the connection, this call will error
318 fut_hang.result(TIMEOUT)
319
320
321def test_balance(node_factory):

Callers

nothing calls this directly

Calls 4

joinMethod · 0.80
get_nodesMethod · 0.80
wait_for_logMethod · 0.80
connectMethod · 0.45

Tested by

no test coverage detected