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

Function test_connection_moved

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

Source from the content-addressed store, hash-verified

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