@Test public void shouldReturnArrayOfPeersIfPresent() throws Exception { final NetworkDataProvider network = new NetworkDataProvider(eth2Network); final GetPeers handler = new GetPeers(network, jsonProvider); final Eth2Peer peer1 = mock(Eth2Peer.class); final Eth2Peer peer2 = mock(Eth2Peer.class); final PeerId peerId1 = new PeerId(PeerId.random().getBytes()); final PeerId peerId2 = new PeerId(PeerId.random().getBytes()); final NodeId nodeId1 = new LibP2PNodeId(peerId1); final NodeId nodeId2 = new LibP2PNodeId(peerId2); when(peer1.getId()).thenReturn(nodeId1); when(peer2.getId()).thenReturn(nodeId2); when(eth2Network.streamPeers()).thenReturn(Stream.of(peer1, peer2)); final String response = jsonProvider.objectToJSON(new String[] {peerId1.toBase58(), peerId2.toBase58()}); handler.handle(context); verify(context).header(Header.CACHE_CONTROL, CACHE_NONE); verify(context).result(response); }
@OpenApi( deprecated = true, path = ROUTE, method = HttpMethod.GET, summary = "Get the PeerIds of connected peers.", tags = {TAG_NETWORK}, description = "Returns the base58-encoded PeerId of each peer connected to the beacon node." + " Replaced by standard api endpoint `/eth/v1/node/peers`.", responses = { @OpenApiResponse( status = RES_OK, content = @OpenApiContent(from = String.class, isArray = true)), @OpenApiResponse(status = RES_INTERNAL_ERROR) }) @Override public void handle(Context ctx) throws Exception { ctx.header(Header.CACHE_CONTROL, CACHE_NONE); ctx.result(jsonProvider.objectToJSON(network.getPeersAsBase58())); }
GetPeers implements Handler { @OpenApi( deprecated = true, path = ROUTE, method = HttpMethod.GET, summary = "Get the PeerIds of connected peers.", tags = {TAG_NETWORK}, description = "Returns the base58-encoded PeerId of each peer connected to the beacon node." + " Replaced by standard api endpoint `/eth/v1/node/peers`.", responses = { @OpenApiResponse( status = RES_OK, content = @OpenApiContent(from = String.class, isArray = true)), @OpenApiResponse(status = RES_INTERNAL_ERROR) }) @Override public void handle(Context ctx) throws Exception { ctx.header(Header.CACHE_CONTROL, CACHE_NONE); ctx.result(jsonProvider.objectToJSON(network.getPeersAsBase58())); } }
GetPeers implements Handler { @OpenApi( deprecated = true, path = ROUTE, method = HttpMethod.GET, summary = "Get the PeerIds of connected peers.", tags = {TAG_NETWORK}, description = "Returns the base58-encoded PeerId of each peer connected to the beacon node." + " Replaced by standard api endpoint `/eth/v1/node/peers`.", responses = { @OpenApiResponse( status = RES_OK, content = @OpenApiContent(from = String.class, isArray = true)), @OpenApiResponse(status = RES_INTERNAL_ERROR) }) @Override public void handle(Context ctx) throws Exception { ctx.header(Header.CACHE_CONTROL, CACHE_NONE); ctx.result(jsonProvider.objectToJSON(network.getPeersAsBase58())); } GetPeers(NetworkDataProvider network, JsonProvider jsonProvider); }
GetPeers implements Handler { @OpenApi( deprecated = true, path = ROUTE, method = HttpMethod.GET, summary = "Get the PeerIds of connected peers.", tags = {TAG_NETWORK}, description = "Returns the base58-encoded PeerId of each peer connected to the beacon node." + " Replaced by standard api endpoint `/eth/v1/node/peers`.", responses = { @OpenApiResponse( status = RES_OK, content = @OpenApiContent(from = String.class, isArray = true)), @OpenApiResponse(status = RES_INTERNAL_ERROR) }) @Override public void handle(Context ctx) throws Exception { ctx.header(Header.CACHE_CONTROL, CACHE_NONE); ctx.result(jsonProvider.objectToJSON(network.getPeersAsBase58())); } GetPeers(NetworkDataProvider network, JsonProvider jsonProvider); @OpenApi( deprecated = true, path = ROUTE, method = HttpMethod.GET, summary = "Get the PeerIds of connected peers.", tags = {TAG_NETWORK}, description = "Returns the base58-encoded PeerId of each peer connected to the beacon node." + " Replaced by standard api endpoint `/eth/v1/node/peers`.", responses = { @OpenApiResponse( status = RES_OK, content = @OpenApiContent(from = String.class, isArray = true)), @OpenApiResponse(status = RES_INTERNAL_ERROR) }) @Override void handle(Context ctx); }
GetPeers implements Handler { @OpenApi( deprecated = true, path = ROUTE, method = HttpMethod.GET, summary = "Get the PeerIds of connected peers.", tags = {TAG_NETWORK}, description = "Returns the base58-encoded PeerId of each peer connected to the beacon node." + " Replaced by standard api endpoint `/eth/v1/node/peers`.", responses = { @OpenApiResponse( status = RES_OK, content = @OpenApiContent(from = String.class, isArray = true)), @OpenApiResponse(status = RES_INTERNAL_ERROR) }) @Override public void handle(Context ctx) throws Exception { ctx.header(Header.CACHE_CONTROL, CACHE_NONE); ctx.result(jsonProvider.objectToJSON(network.getPeersAsBase58())); } GetPeers(NetworkDataProvider network, JsonProvider jsonProvider); @OpenApi( deprecated = true, path = ROUTE, method = HttpMethod.GET, summary = "Get the PeerIds of connected peers.", tags = {TAG_NETWORK}, description = "Returns the base58-encoded PeerId of each peer connected to the beacon node." + " Replaced by standard api endpoint `/eth/v1/node/peers`.", responses = { @OpenApiResponse( status = RES_OK, content = @OpenApiContent(from = String.class, isArray = true)), @OpenApiResponse(status = RES_INTERNAL_ERROR) }) @Override void handle(Context ctx); static final String ROUTE; }