|
|
|
@ -22,6 +22,7 @@ import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcError; |
|
|
|
|
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcErrorResponse; |
|
|
|
|
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse; |
|
|
|
|
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse; |
|
|
|
|
import tech.pegasys.pantheon.ethereum.p2p.P2pDisabledException; |
|
|
|
|
import tech.pegasys.pantheon.ethereum.p2p.api.P2PNetwork; |
|
|
|
|
|
|
|
|
|
import org.junit.Before; |
|
|
|
@ -113,4 +114,31 @@ public class AdminAddPeerTest { |
|
|
|
|
|
|
|
|
|
assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void requestReturnsErrorWhenP2pDisabled() { |
|
|
|
|
when(p2pNetwork.addMaintainConnectionPeer(any())) |
|
|
|
|
.thenThrow( |
|
|
|
|
new P2pDisabledException("P2P networking disabled. Unable to connect to add peer.")); |
|
|
|
|
|
|
|
|
|
final JsonRpcRequest request = |
|
|
|
|
new JsonRpcRequest( |
|
|
|
|
"2.0", |
|
|
|
|
"admin_addPeer", |
|
|
|
|
new String[] { |
|
|
|
|
"enode://" |
|
|
|
|
+ "00000000000000000000000000000000" |
|
|
|
|
+ "00000000000000000000000000000000" |
|
|
|
|
+ "00000000000000000000000000000000" |
|
|
|
|
+ "00000000000000000000000000000000" |
|
|
|
|
+ "@127.0.0.1:30303" |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
final JsonRpcResponse expectedResponse = |
|
|
|
|
new JsonRpcErrorResponse(request.getId(), JsonRpcError.P2P_DISABLED); |
|
|
|
|
|
|
|
|
|
final JsonRpcResponse actualResponse = method.response(request); |
|
|
|
|
|
|
|
|
|
assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|