|
|
@ -86,7 +86,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void handleLoginRequestWithAuthDisabled() throws Exception { |
|
|
|
public void handleLoginRequestWithAuthDisabled() throws Exception { |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create(JSON, "{\"username\":\"user\",\"password\":\"pass\"}"); |
|
|
|
RequestBody.create("{\"username\":\"user\",\"password\":\"pass\"}", JSON); |
|
|
|
final Request request = new Request.Builder().post(body).url(baseUrl + "/login").build(); |
|
|
|
final Request request = new Request.Builder().post(body).url(baseUrl + "/login").build(); |
|
|
|
try (final Response resp = client.newCall(request).execute()) { |
|
|
|
try (final Response resp = client.newCall(request).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
@ -122,10 +122,10 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
// Create a request with an extra "beta" param
|
|
|
|
// Create a request with an extra "beta" param
|
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"net_version\", \"beta\":true}"); |
|
|
|
+ ",\"method\":\"net_version\", \"beta\":true}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -177,10 +177,10 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "123"; |
|
|
|
final String id = "123"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"web3_clientVersion\"}"); |
|
|
|
+ ",\"method\":\"web3_clientVersion\"}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.header("Content-Type")).isEqualTo("application/json"); |
|
|
|
assertThat(resp.header("Content-Type")).isEqualTo("application/json"); |
|
|
@ -192,10 +192,10 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "123"; |
|
|
|
final String id = "123"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"web3_clientVersion\"}"); |
|
|
|
+ ",\"method\":\"web3_clientVersion\"}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -213,8 +213,8 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "123"; |
|
|
|
final String id = "123"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" + Json.encode(id) + ",\"method\":\"net_version\"}", |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" + Json.encode(id) + ",\"method\":\"net_version\"}"); |
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -232,8 +232,8 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "123"; |
|
|
|
final String id = "123"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" + Json.encode(id) + ",\"method\":\"eth_accounts\"}", |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" + Json.encode(id) + ",\"method\":\"eth_accounts\"}"); |
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -253,8 +253,8 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "123"; |
|
|
|
final String id = "123"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" + Json.encode(id) + ",\"method\":\"net_peerCount\"}", |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" + Json.encode(id) + ",\"method\":\"net_peerCount\"}"); |
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -277,12 +277,12 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String params = "\"params\": [\"" + blockHash + "\"]"; |
|
|
|
final String params = "\"params\": [\"" + blockHash + "\"]"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ "," |
|
|
|
+ "," |
|
|
|
+ params |
|
|
|
+ params |
|
|
|
+ ",\"method\":\"eth_getUncleCountByBlockHash\"}"); |
|
|
|
+ ",\"method\":\"eth_getUncleCountByBlockHash\"}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -305,12 +305,12 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String params = "\"params\": [\"" + blockHash + "\"]"; |
|
|
|
final String params = "\"params\": [\"" + blockHash + "\"]"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ "," |
|
|
|
+ "," |
|
|
|
+ params |
|
|
|
+ params |
|
|
|
+ ",\"method\":\"eth_getUncleCountByBlockHash\"}"); |
|
|
|
+ ",\"method\":\"eth_getUncleCountByBlockHash\"}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -334,12 +334,12 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String params = "\"params\": [\"" + number + "\"]"; |
|
|
|
final String params = "\"params\": [\"" + number + "\"]"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ "," |
|
|
|
+ "," |
|
|
|
+ params |
|
|
|
+ params |
|
|
|
+ ",\"method\":\"eth_getUncleCountByBlockNumber\"}"); |
|
|
|
+ ",\"method\":\"eth_getUncleCountByBlockNumber\"}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -362,12 +362,12 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String params = "\"params\": [\"" + number + "\"]"; |
|
|
|
final String params = "\"params\": [\"" + number + "\"]"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ "," |
|
|
|
+ "," |
|
|
|
+ params |
|
|
|
+ params |
|
|
|
+ ",\"method\":\"eth_getUncleCountByBlockNumber\"}"); |
|
|
|
+ ",\"method\":\"eth_getUncleCountByBlockNumber\"}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -389,12 +389,12 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String params = "\"params\": [\"earliest\"]"; |
|
|
|
final String params = "\"params\": [\"earliest\"]"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ "," |
|
|
|
+ "," |
|
|
|
+ params |
|
|
|
+ params |
|
|
|
+ ",\"method\":\"eth_getUncleCountByBlockNumber\"}"); |
|
|
|
+ ",\"method\":\"eth_getUncleCountByBlockNumber\"}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -417,12 +417,12 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String params = "\"params\": [\"latest\"]"; |
|
|
|
final String params = "\"params\": [\"latest\"]"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ "," |
|
|
|
+ "," |
|
|
|
+ params |
|
|
|
+ params |
|
|
|
+ ",\"method\":\"eth_getUncleCountByBlockNumber\"}"); |
|
|
|
+ ",\"method\":\"eth_getUncleCountByBlockNumber\"}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -445,12 +445,12 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String params = "\"params\": [\"pending\"]"; |
|
|
|
final String params = "\"params\": [\"pending\"]"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ "," |
|
|
|
+ "," |
|
|
|
+ params |
|
|
|
+ params |
|
|
|
+ ",\"method\":\"eth_getUncleCountByBlockNumber\"}"); |
|
|
|
+ ",\"method\":\"eth_getUncleCountByBlockNumber\"}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -468,12 +468,12 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String params = "\"params\": [\"pending\"]"; |
|
|
|
final String params = "\"params\": [\"pending\"]"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ "," |
|
|
|
+ "," |
|
|
|
+ params |
|
|
|
+ params |
|
|
|
+ ",\"method\":\"eth_getUncleCountByBlockNumber\"}"); |
|
|
|
+ ",\"method\":\"eth_getUncleCountByBlockNumber\"}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -493,8 +493,8 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "123"; |
|
|
|
final String id = "123"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" + Json.encode(id) + ",\"method\":\"net_peerCount\"}", |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" + Json.encode(id) + ",\"method\":\"net_peerCount\"}"); |
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -525,12 +525,12 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "123"; |
|
|
|
final String id = "123"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getBalance\", \"params\": [\"" |
|
|
|
+ ",\"method\":\"eth_getBalance\", \"params\": [\"" |
|
|
|
+ address |
|
|
|
+ address |
|
|
|
+ "\",\"latest\"]}"); |
|
|
|
+ "\",\"latest\"]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -561,12 +561,12 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "123"; |
|
|
|
final String id = "123"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getBalance\", \"params\": [\"" |
|
|
|
+ ",\"method\":\"eth_getBalance\", \"params\": [\"" |
|
|
|
+ address |
|
|
|
+ address |
|
|
|
+ "\",\"latest\"]}"); |
|
|
|
+ "\",\"latest\"]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -594,12 +594,12 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "123"; |
|
|
|
final String id = "123"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getBalance\", \"params\": [\"" |
|
|
|
+ ",\"method\":\"eth_getBalance\", \"params\": [\"" |
|
|
|
+ address |
|
|
|
+ address |
|
|
|
+ "\",\"earliest\"]}"); |
|
|
|
+ "\",\"earliest\"]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -629,14 +629,14 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "123"; |
|
|
|
final String id = "123"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getBalance\", \"params\": [\"" |
|
|
|
+ ",\"method\":\"eth_getBalance\", \"params\": [\"" |
|
|
|
+ address |
|
|
|
+ address |
|
|
|
+ "\",\"0x" |
|
|
|
+ "\",\"0x" |
|
|
|
+ Long.toString(blockNumber, 16) |
|
|
|
+ Long.toString(blockNumber, 16) |
|
|
|
+ "\"]}"); |
|
|
|
+ "\"]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -658,12 +658,12 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final Hash blockHash = Hash.fromHexString(blockHashString); |
|
|
|
final Hash blockHash = Hash.fromHexString(blockHashString); |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getBlockByHash\", \"params\": [\"" |
|
|
|
+ ",\"method\":\"eth_getBlockByHash\", \"params\": [\"" |
|
|
|
+ blockHashString |
|
|
|
+ blockHashString |
|
|
|
+ "\",true]}"); |
|
|
|
+ "\",true]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
// Setup mocks
|
|
|
|
// Setup mocks
|
|
|
|
when(blockchainQueries.blockByHash(eq(blockHash))).thenReturn(Optional.empty()); |
|
|
|
when(blockchainQueries.blockByHash(eq(blockHash))).thenReturn(Optional.empty()); |
|
|
@ -693,12 +693,12 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "123"; |
|
|
|
final String id = "123"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getBlockByHash\", \"params\": [\"" |
|
|
|
+ ",\"method\":\"eth_getBlockByHash\", \"params\": [\"" |
|
|
|
+ blockHash |
|
|
|
+ blockHash |
|
|
|
+ "\",true]}"); |
|
|
|
+ "\",true]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -725,12 +725,12 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "123"; |
|
|
|
final String id = "123"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getBlockByHash\", \"params\": [\"" |
|
|
|
+ ",\"method\":\"eth_getBlockByHash\", \"params\": [\"" |
|
|
|
+ blockHash |
|
|
|
+ blockHash |
|
|
|
+ "\",false]}"); |
|
|
|
+ "\",false]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -749,10 +749,10 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "123"; |
|
|
|
final String id = "123"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getBlockByHash\", \"params\": [true]}"); |
|
|
|
+ ",\"method\":\"eth_getBlockByHash\", \"params\": [true]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
// Setup mocks
|
|
|
|
// Setup mocks
|
|
|
|
when(blockchainQueries.blockByHash(ArgumentMatchers.isA(Hash.class))) |
|
|
|
when(blockchainQueries.blockByHash(ArgumentMatchers.isA(Hash.class))) |
|
|
@ -775,12 +775,12 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273321"; |
|
|
|
"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273321"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getBlockByHash\", \"params\": [\"" |
|
|
|
+ ",\"method\":\"eth_getBlockByHash\", \"params\": [\"" |
|
|
|
+ blockHashString |
|
|
|
+ blockHashString |
|
|
|
+ "\"]}"); |
|
|
|
+ "\"]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
@ -798,12 +798,12 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String blockHashString = "0xe"; |
|
|
|
final String blockHashString = "0xe"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getBlockByHash\", \"params\": [\"" |
|
|
|
+ ",\"method\":\"eth_getBlockByHash\", \"params\": [\"" |
|
|
|
+ blockHashString |
|
|
|
+ blockHashString |
|
|
|
+ "\",true]}"); |
|
|
|
+ "\",true]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
@ -821,12 +821,12 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String blockHashString = "0xe670"; |
|
|
|
final String blockHashString = "0xe670"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getBlockByHash\", \"params\": [\"" |
|
|
|
+ ",\"method\":\"eth_getBlockByHash\", \"params\": [\"" |
|
|
|
+ blockHashString |
|
|
|
+ blockHashString |
|
|
|
+ "\",true]}"); |
|
|
|
+ "\",true]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
@ -845,12 +845,12 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273321"; |
|
|
|
"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273321"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getBlockByHash\", \"params\": [\"" |
|
|
|
+ ",\"method\":\"eth_getBlockByHash\", \"params\": [\"" |
|
|
|
+ blockHashString |
|
|
|
+ blockHashString |
|
|
|
+ "\",{}]}"); |
|
|
|
+ "\",{}]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
@ -867,10 +867,10 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "123"; |
|
|
|
final String id = "123"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getBlockByHash\", \"params\": []}"); |
|
|
|
+ ",\"method\":\"eth_getBlockByHash\", \"params\": []}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
@ -887,10 +887,10 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "123"; |
|
|
|
final String id = "123"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getBlockByHash\"}"); |
|
|
|
+ ",\"method\":\"eth_getBlockByHash\"}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
@ -915,12 +915,12 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "123"; |
|
|
|
final String id = "123"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getBlockByNumber\", \"params\": [\"0x" |
|
|
|
+ ",\"method\":\"eth_getBlockByNumber\", \"params\": [\"0x" |
|
|
|
+ Long.toString(number, 16) |
|
|
|
+ Long.toString(number, 16) |
|
|
|
+ "\",true]}"); |
|
|
|
+ "\",true]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -947,12 +947,12 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "123"; |
|
|
|
final String id = "123"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getBlockByNumber\", \"params\": [\"0x" |
|
|
|
+ ",\"method\":\"eth_getBlockByNumber\", \"params\": [\"0x" |
|
|
|
+ Long.toString(number, 16) |
|
|
|
+ Long.toString(number, 16) |
|
|
|
+ "\",false]}"); |
|
|
|
+ "\",false]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -972,10 +972,10 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
|
|
|
|
|
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getBlockByNumber\", \"params\": [\"bla\",false]}"); |
|
|
|
+ ",\"method\":\"eth_getBlockByNumber\", \"params\": [\"bla\",false]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
@ -1001,10 +1001,10 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "123"; |
|
|
|
final String id = "123"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getBlockByNumber\", \"params\": [\"earliest\",true]}"); |
|
|
|
+ ",\"method\":\"eth_getBlockByNumber\", \"params\": [\"earliest\",true]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -1023,10 +1023,10 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "123"; |
|
|
|
final String id = "123"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getBlockByNumber\", \"params\": [\"0x0\",true]}"); |
|
|
|
+ ",\"method\":\"eth_getBlockByNumber\", \"params\": [\"0x0\",true]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
// Setup mocks to return a block
|
|
|
|
// Setup mocks to return a block
|
|
|
|
final BlockDataGenerator gen = new BlockDataGenerator(); |
|
|
|
final BlockDataGenerator gen = new BlockDataGenerator(); |
|
|
@ -1052,10 +1052,10 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "123"; |
|
|
|
final String id = "123"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getBlockByNumber\", \"params\": [\"latest\",true]}"); |
|
|
|
+ ",\"method\":\"eth_getBlockByNumber\", \"params\": [\"latest\",true]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
// Setup mocks to return a block
|
|
|
|
// Setup mocks to return a block
|
|
|
|
final BlockDataGenerator gen = new BlockDataGenerator(); |
|
|
|
final BlockDataGenerator gen = new BlockDataGenerator(); |
|
|
@ -1088,10 +1088,10 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "123"; |
|
|
|
final String id = "123"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getBlockByNumber\", \"params\": [\"pending\",true]}"); |
|
|
|
+ ",\"method\":\"eth_getBlockByNumber\", \"params\": [\"pending\",true]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
// Setup mocks to return a block
|
|
|
|
// Setup mocks to return a block
|
|
|
|
final BlockDataGenerator gen = new BlockDataGenerator(); |
|
|
|
final BlockDataGenerator gen = new BlockDataGenerator(); |
|
|
|
final Block block = gen.genesisBlock(); |
|
|
|
final Block block = gen.genesisBlock(); |
|
|
@ -1123,10 +1123,10 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "123"; |
|
|
|
final String id = "123"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"web3_clientVersion\", \"params\": [1,2,3]}"); |
|
|
|
+ ",\"method\":\"web3_clientVersion\", \"params\": [1,2,3]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -1144,7 +1144,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "456"; |
|
|
|
final String id = "456"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, "{\"id\":" + Json.encode(id) + ",\"method\":\"web3_clientVersion\"}"); |
|
|
|
"{\"id\":" + Json.encode(id) + ",\"method\":\"web3_clientVersion\"}", JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -1159,7 +1159,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
public void notification() throws Exception { |
|
|
|
public void notification() throws Exception { |
|
|
|
// No id field is present - marking this as a notification
|
|
|
|
// No id field is present - marking this as a notification
|
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create(JSON, "{\"jsonrpc\":\"2.0\",\"method\":\"web3_clientVersion\"}"); |
|
|
|
RequestBody.create("{\"jsonrpc\":\"2.0\",\"method\":\"web3_clientVersion\"}", JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
// Notifications return an empty response
|
|
|
|
// Notifications return an empty response
|
|
|
@ -1174,7 +1174,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
// Be lenient - allow explicit null id fields
|
|
|
|
// Be lenient - allow explicit null id fields
|
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, "{\"jsonrpc\":\"2.0\",\"id\":null,\"method\":\"web3_clientVersion\"}"); |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":null,\"method\":\"web3_clientVersion\"}", JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -1192,10 +1192,10 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = ""; |
|
|
|
final String id = ""; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"web3_clientVersion\"}"); |
|
|
|
+ ",\"method\":\"web3_clientVersion\"}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
// An empty string is still a string, so should be a valid id
|
|
|
|
// An empty string is still a string, so should be a valid id
|
|
|
@ -1214,10 +1214,10 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final int id = -1; |
|
|
|
final int id = -1; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"web3_clientVersion\"}"); |
|
|
|
+ ",\"method\":\"web3_clientVersion\"}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -1238,10 +1238,10 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
|
|
|
|
|
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"web3_clientVersion\"}"); |
|
|
|
+ ",\"method\":\"web3_clientVersion\"}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -1264,10 +1264,10 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
|
|
|
|
|
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"web3_clientVersion\"}"); |
|
|
|
+ ",\"method\":\"web3_clientVersion\"}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -1285,10 +1285,10 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final double id = 1.5; |
|
|
|
final double id = 1.5; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"web3_clientVersion\"}"); |
|
|
|
+ ",\"method\":\"web3_clientVersion\"}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -1305,7 +1305,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
public void objectId() throws Exception { |
|
|
|
public void objectId() throws Exception { |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, "{\"jsonrpc\":\"2.0\",\"id\":{},\"method\":\"web3_clientVersion\"}"); |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":{},\"method\":\"web3_clientVersion\"}", JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
@ -1320,7 +1320,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
public void arrayId() throws Exception { |
|
|
|
public void arrayId() throws Exception { |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, "{\"jsonrpc\":\"2.0\",\"id\":[],\"method\":\"web3_clientVersion\"}"); |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":[],\"method\":\"web3_clientVersion\"}", JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
@ -1335,7 +1335,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
public void missingMethodField() throws Exception { |
|
|
|
public void missingMethodField() throws Exception { |
|
|
|
final Integer id = 2; |
|
|
|
final Integer id = 2; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create(JSON, "{\"jsonrpc\":\"2.0\",\"id\":" + Json.encode(id) + "}"); |
|
|
|
RequestBody.create("{\"jsonrpc\":\"2.0\",\"id\":" + Json.encode(id) + "}", JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
@ -1351,10 +1351,10 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "234"; |
|
|
|
final String id = "234"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"1.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"1.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"web3_clientVersion\"}"); |
|
|
|
+ ",\"method\":\"web3_clientVersion\"}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -1370,7 +1370,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "234"; |
|
|
|
final String id = "234"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, "{\"jsonrpc\":\"2.0\",\"id\":" + Json.encode(id) + ",\"method\":\"bla\"}"); |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" + Json.encode(id) + ",\"method\":\"bla\"}", JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -1388,12 +1388,12 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "234"; |
|
|
|
final String id = "234"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"" |
|
|
|
+ ",\"method\":\"" |
|
|
|
+ methodName |
|
|
|
+ methodName |
|
|
|
+ "\"}"); |
|
|
|
+ "\"}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
when(rpcMethods.get(any(String.class))).thenReturn(null); |
|
|
|
when(rpcMethods.get(any(String.class))).thenReturn(null); |
|
|
|
when(rpcMethods.containsKey(any(String.class))).thenReturn(false); |
|
|
|
when(rpcMethods.containsKey(any(String.class))).thenReturn(false); |
|
|
@ -1421,7 +1421,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
doReturn(jsonRpcMethod).when(rpcMethods).get("foo"); |
|
|
|
doReturn(jsonRpcMethod).when(rpcMethods).get("foo"); |
|
|
|
|
|
|
|
|
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create(JSON, "{\"jsonrpc\":\"2.0\",\"id\":\"666\",\"method\":\"foo\"}"); |
|
|
|
RequestBody.create("{\"jsonrpc\":\"2.0\",\"id\":\"666\",\"method\":\"foo\"}", JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -1441,10 +1441,10 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
|
|
|
|
|
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"[{\"jsonrpc\":\"2.0\",\"id\":\"000\",\"method\":\"web3_clientVersion\"}," |
|
|
|
"[{\"jsonrpc\":\"2.0\",\"id\":\"000\",\"method\":\"web3_clientVersion\"}," |
|
|
|
+ "{\"jsonrpc\":\"2.0\",\"id\":\"111\",\"method\":\"foo\"}," |
|
|
|
+ "{\"jsonrpc\":\"2.0\",\"id\":\"111\",\"method\":\"foo\"}," |
|
|
|
+ "{\"jsonrpc\":\"2.0\",\"id\":\"222\",\"method\":\"net_version\"}]"); |
|
|
|
+ "{\"jsonrpc\":\"2.0\",\"id\":\"222\",\"method\":\"net_version\"}]", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -1464,7 +1464,6 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final int netVersionRequestId = 4; |
|
|
|
final int netVersionRequestId = 4; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"[{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"[{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(clientVersionRequestId) |
|
|
|
+ Json.encode(clientVersionRequestId) |
|
|
|
+ ",\"method\":\"web3_clientVersion\"}," |
|
|
|
+ ",\"method\":\"web3_clientVersion\"}," |
|
|
@ -1473,7 +1472,8 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
+ ",\"method\":\"bla\"}," |
|
|
|
+ ",\"method\":\"bla\"}," |
|
|
|
+ "{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ "{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(netVersionRequestId) |
|
|
|
+ Json.encode(netVersionRequestId) |
|
|
|
+ ",\"method\":\"net_version\"}]"); |
|
|
|
+ ",\"method\":\"net_version\"}]", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -1521,7 +1521,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
+ Json.encode(netVersionRequestId) |
|
|
|
+ Json.encode(netVersionRequestId) |
|
|
|
+ ",\"method\":\"net_version\"}"; |
|
|
|
+ ",\"method\":\"net_version\"}"; |
|
|
|
final String batchRequest = "[" + String.join(", ", reqs) + "]"; |
|
|
|
final String batchRequest = "[" + String.join(", ", reqs) + "]"; |
|
|
|
final RequestBody body = RequestBody.create(JSON, batchRequest); |
|
|
|
final RequestBody body = RequestBody.create(batchRequest, JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -1568,7 +1568,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
+ " {\"jsonrpc\": \"2.0\", \"method\"\n" |
|
|
|
+ " {\"jsonrpc\": \"2.0\", \"method\"\n" |
|
|
|
+ "]"; |
|
|
|
+ "]"; |
|
|
|
|
|
|
|
|
|
|
|
final RequestBody body = RequestBody.create(JSON, req); |
|
|
|
final RequestBody body = RequestBody.create(req, JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
@ -1585,14 +1585,14 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final int netVersionRequestId = 3; |
|
|
|
final int netVersionRequestId = 3; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"[{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"[{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(clientVersionRequestId) |
|
|
|
+ Json.encode(clientVersionRequestId) |
|
|
|
+ ",\"method\":\"web3_clientVersion\"}," |
|
|
|
+ ",\"method\":\"web3_clientVersion\"}," |
|
|
|
+ "{\"jsonrpc\":\"2.0\", \"method\":\"web3_clientVersion\"}," |
|
|
|
+ "{\"jsonrpc\":\"2.0\", \"method\":\"web3_clientVersion\"}," |
|
|
|
+ "{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ "{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(netVersionRequestId) |
|
|
|
+ Json.encode(netVersionRequestId) |
|
|
|
+ ",\"method\":\"net_version\"}]"); |
|
|
|
+ ",\"method\":\"net_version\"}]", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -1625,7 +1625,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void emptyBatchRequest() throws Exception { |
|
|
|
public void emptyBatchRequest() throws Exception { |
|
|
|
final RequestBody body = RequestBody.create(JSON, "[]"); |
|
|
|
final RequestBody body = RequestBody.create("[]", JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
@ -1764,8 +1764,8 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "007"; |
|
|
|
final String id = "007"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" + Json.encode(id) + ",\"method\":\"eth_syncing\"}", |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" + Json.encode(id) + ",\"method\":\"eth_syncing\"}"); |
|
|
|
JSON); |
|
|
|
when(synchronizer.getSyncStatus()).thenReturn(Optional.empty()); |
|
|
|
when(synchronizer.getSyncStatus()).thenReturn(Optional.empty()); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
@ -1786,8 +1786,8 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "999"; |
|
|
|
final String id = "999"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" + Json.encode(id) + ",\"method\":\"eth_syncing\"}", |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" + Json.encode(id) + ",\"method\":\"eth_syncing\"}"); |
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
final String respBody = resp.body().string(); |
|
|
|
final String respBody = resp.body().string(); |
|
|
@ -1810,8 +1810,8 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "999"; |
|
|
|
final String id = "999"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" + Json.encode(id) + ",\"method\":\"eth_syncing\"}", |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" + Json.encode(id) + ",\"method\":\"eth_syncing\"}"); |
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
final String respBody = resp.body().string(); |
|
|
|
final String respBody = resp.body().string(); |
|
|
@ -1880,14 +1880,14 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "88"; |
|
|
|
final String id = "88"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getStorageAt\", \"params\": [\"" |
|
|
|
+ ",\"method\":\"eth_getStorageAt\", \"params\": [\"" |
|
|
|
+ address |
|
|
|
+ address |
|
|
|
+ "\",\"" |
|
|
|
+ "\",\"" |
|
|
|
+ UInt256.ZERO |
|
|
|
+ UInt256.ZERO |
|
|
|
+ "\",\"latest\"]}"); |
|
|
|
+ "\",\"latest\"]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -1919,14 +1919,14 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "88"; |
|
|
|
final String id = "88"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getStorageAt\", \"params\": [\"" |
|
|
|
+ ",\"method\":\"eth_getStorageAt\", \"params\": [\"" |
|
|
|
+ address |
|
|
|
+ address |
|
|
|
+ "\",\"" |
|
|
|
+ "\",\"" |
|
|
|
+ UInt256.ONE |
|
|
|
+ UInt256.ONE |
|
|
|
+ "\",\"latest\"]}"); |
|
|
|
+ "\",\"latest\"]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -1955,14 +1955,14 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "88"; |
|
|
|
final String id = "88"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getStorageAt\", \"params\": [\"" |
|
|
|
+ ",\"method\":\"eth_getStorageAt\", \"params\": [\"" |
|
|
|
+ address |
|
|
|
+ address |
|
|
|
+ "\",\"" |
|
|
|
+ "\",\"" |
|
|
|
+ UInt256.ONE |
|
|
|
+ UInt256.ONE |
|
|
|
+ "\",\"earliest\"]}"); |
|
|
|
+ "\",\"earliest\"]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -1991,7 +1991,6 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "999"; |
|
|
|
final String id = "999"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getStorageAt\", \"params\": [\"" |
|
|
|
+ ",\"method\":\"eth_getStorageAt\", \"params\": [\"" |
|
|
@ -2000,7 +1999,8 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
+ UInt256.ZERO |
|
|
|
+ UInt256.ZERO |
|
|
|
+ "\",\"" |
|
|
|
+ "\",\"" |
|
|
|
+ 0L |
|
|
|
+ 0L |
|
|
|
+ "\"]}"); |
|
|
|
+ "\"]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
|
assertThat(resp.code()).isEqualTo(200); |
|
|
@ -2025,14 +2025,14 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase { |
|
|
|
final String id = "88"; |
|
|
|
final String id = "88"; |
|
|
|
final RequestBody body = |
|
|
|
final RequestBody body = |
|
|
|
RequestBody.create( |
|
|
|
RequestBody.create( |
|
|
|
JSON, |
|
|
|
|
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
"{\"jsonrpc\":\"2.0\",\"id\":" |
|
|
|
+ Json.encode(id) |
|
|
|
+ Json.encode(id) |
|
|
|
+ ",\"method\":\"eth_getStorageAt\", \"params\": [\"" |
|
|
|
+ ",\"method\":\"eth_getStorageAt\", \"params\": [\"" |
|
|
|
+ address |
|
|
|
+ address |
|
|
|
+ "\",\"" |
|
|
|
+ "\",\"" |
|
|
|
+ "blah" |
|
|
|
+ "blah" |
|
|
|
+ "\",\"latest\"]}"); |
|
|
|
+ "\",\"latest\"]}", |
|
|
|
|
|
|
|
JSON); |
|
|
|
|
|
|
|
|
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
|
assertThat(resp.code()).isEqualTo(400); |
|
|
|