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

Function test_connection_moved

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

Source from the content-addressed store, hash-verified

242
243
244def test_connection_moved(node_factory, executor):
245 slow_start = os.path.join(os.getcwd(), 'tests/plugins/slow_start.py')
246 options = {'may_reconnect': True, 'plugin': slow_start}
247 l1, l2 = node_factory.get_nodes(2, opts=options)
248
249 # Set up the plugin to wait for a connection
250 executor.submit(l1.rpc.waitconn)
251 log = l1.daemon.wait_for_log('listening for connections')
252 match = re.search(r'on port (\d*)', log)
253 assert match and len(match.groups()) == 1
254 hang_port = int(match.groups()[0])
255
256 # Attempt connection
257 fut_hang = executor.submit(l1.rpc.connect, l2.info['id'],
258 'localhost', hang_port)
259 l1.daemon.wait_for_log('connection from')
260
261 # Provide correct connection details
262 ret = l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
263 assert ret['address'] == {'type': 'ipv4', 'address': '127.0.0.1', 'port': l2.port}
264
265 # If we failed to update the connection, this call will error
266 fut_hang.result(TIMEOUT)
267
268
269def 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