mirror of
https://github.com/vacp2p/linea-besu.git
synced 2026-01-09 21:17:54 -05:00
Use port 0 when starting a websocket server in tests (#1416)
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
This commit is contained in:
@@ -266,6 +266,8 @@ public class JsonRpcHttpServiceRpcApisTest {
|
||||
final Set<Capability> supportedCapabilities = new HashSet<>();
|
||||
supportedCapabilities.add(EthProtocol.ETH62);
|
||||
supportedCapabilities.add(EthProtocol.ETH63);
|
||||
jsonRpcConfiguration.setPort(0);
|
||||
webSocketConfiguration.setPort(0);
|
||||
|
||||
final Map<String, JsonRpcMethod> rpcMethods =
|
||||
spy(
|
||||
|
||||
@@ -20,6 +20,7 @@ import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.JsonRpcMethod;
|
||||
import tech.pegasys.pantheon.ethereum.jsonrpc.websocket.methods.WebSocketMethodsFactory;
|
||||
import tech.pegasys.pantheon.ethereum.jsonrpc.websocket.subscription.SubscriptionManager;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -56,9 +57,11 @@ public class WebSocketHostWhitelistTest {
|
||||
private WebSocketService websocketService;
|
||||
private HttpClient httpClient;
|
||||
private static final int VERTX_AWAIT_TIMEOUT_MILLIS = 10000;
|
||||
private int websocketPort;
|
||||
|
||||
@Before
|
||||
public void initServerAndClient() {
|
||||
webSocketConfiguration.setPort(0);
|
||||
vertx = Vertx.vertx();
|
||||
|
||||
final Map<String, JsonRpcMethod> websocketMethods =
|
||||
@@ -68,11 +71,13 @@ public class WebSocketHostWhitelistTest {
|
||||
websocketService =
|
||||
new WebSocketService(vertx, webSocketConfiguration, webSocketRequestHandlerSpy);
|
||||
websocketService.start().join();
|
||||
final InetSocketAddress inetSocketAddress = websocketService.socketAddress();
|
||||
|
||||
websocketPort = inetSocketAddress.getPort();
|
||||
final HttpClientOptions httpClientOptions =
|
||||
new HttpClientOptions()
|
||||
.setDefaultHost(webSocketConfiguration.getHost())
|
||||
.setDefaultPort(webSocketConfiguration.getPort());
|
||||
.setDefaultPort(websocketPort);
|
||||
|
||||
httpClient = vertx.createHttpClient(httpClientOptions);
|
||||
}
|
||||
@@ -171,7 +176,7 @@ public class WebSocketHostWhitelistTest {
|
||||
|
||||
final HttpClientRequest request =
|
||||
httpClient.post(
|
||||
webSocketConfiguration.getPort(),
|
||||
websocketPort,
|
||||
webSocketConfiguration.getHost(),
|
||||
"/",
|
||||
response -> {
|
||||
|
||||
Reference in New Issue
Block a user