(node_factory, executor)
| 205 | |
| 206 | |
| 207 | def test_reconnect_channel_peers(node_factory, executor): |
| 208 | l1 = node_factory.get_node(may_reconnect=True) |
| 209 | l2 = node_factory.get_node(may_reconnect=True) |
| 210 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 211 | |
| 212 | l1.fundchannel(l2, 10**6) |
| 213 | l2.restart() |
| 214 | |
| 215 | # Should reconnect. |
| 216 | wait_for(lambda: only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['connected']) |
| 217 | wait_for(lambda: only_one(l2.rpc.listpeers(l1.info['id'])['peers'])['connected']) |
| 218 | # Connect command should succeed. |
| 219 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 220 | |
| 221 | # Stop l2 and wait for l1 to notice. |
| 222 | l2.stop() |
| 223 | wait_for(lambda: not only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['connected']) |
| 224 | |
| 225 | # Now should fail. |
| 226 | with pytest.raises(RpcError, match=r'(Connection refused|Bad file descriptor)'): |
| 227 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 228 | |
| 229 | # Wait for exponential backoff to give us a 2 second window. |
| 230 | l1.daemon.wait_for_log('Will try reconnect in 2 seconds') |
| 231 | |
| 232 | # It should now succeed when it restarts. |
| 233 | l2.start() |
| 234 | |
| 235 | # Multiples should be fine! |
| 236 | fut1 = executor.submit(l1.rpc.connect, l2.info['id'], 'localhost', l2.port) |
| 237 | fut2 = executor.submit(l1.rpc.connect, l2.info['id'], 'localhost', l2.port) |
| 238 | fut3 = executor.submit(l1.rpc.connect, l2.info['id'], 'localhost', l2.port) |
| 239 | fut1.result(10) |
| 240 | fut2.result(10) |
| 241 | fut3.result(10) |
| 242 | |
| 243 | |
| 244 | def test_connection_moved(node_factory, executor): |
nothing calls this directly
no test coverage detected