Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -299,20 +299,19 @@ public Bytes32 parseLiteral(
}
};

private static final Coercing<Number, Number> LONG_COERCING =
private static final Coercing<Number, String> LONG_COERCING =
new Coercing<>() {
@Override
public Number serialize(
public String serialize(
final Object input, final GraphQLContext graphQLContext, final Locale locale)
throws CoercingSerializeException {
if (input instanceof Number number) {
return number;
return Bytes.ofUnsignedLong(number.longValue()).toQuantityHexString();
} else if (input instanceof String string) {
final String value = string.toLowerCase();
if (value.startsWith("0x")) {
return Bytes.fromHexStringLenient(value).toLong();
if (string.startsWith("0x")) {
return string;
} else {
return Long.parseLong(value);
return "0x" + string;
}
}
throw new CoercingSerializeException("Unable to serialize " + input + " as an Long");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,18 +280,18 @@ public void query_untypedPost() throws Exception {
@Test
public void getSocketAddressWhenActive() {
final InetSocketAddress socketAddress = service.socketAddress();
Assertions.assertThat("127.0.0.1").isEqualTo(socketAddress.getAddress().getHostAddress());
Assertions.assertThat(socketAddress.getPort() > 0).isTrue();
Assertions.assertThat(socketAddress.getAddress().getHostAddress()).isEqualTo("127.0.0.1");
Assertions.assertThat(socketAddress.getPort()).isPositive();
}

@Test
public void getSocketAddressWhenStoppedIsEmpty() throws Exception {
final GraphQLHttpService service = createGraphQLHttpService();

final InetSocketAddress socketAddress = service.socketAddress();
Assertions.assertThat("0.0.0.0").isEqualTo(socketAddress.getAddress().getHostAddress());
Assertions.assertThat(0).isEqualTo(socketAddress.getPort());
Assertions.assertThat("").isEqualTo(service.url());
Assertions.assertThat(socketAddress.getAddress().getHostAddress()).isEqualTo("0.0.0.0");
Assertions.assertThat(socketAddress.getPort()).isZero();
Assertions.assertThat(service.url()).isEmpty();
}

@Test
Expand All @@ -303,8 +303,8 @@ public void getSocketAddressWhenBindingToAllInterfaces() throws Exception {

try {
final InetSocketAddress socketAddress = service.socketAddress();
Assertions.assertThat("0.0.0.0").isEqualTo(socketAddress.getAddress().getHostAddress());
Assertions.assertThat(socketAddress.getPort() > 0).isTrue();
Assertions.assertThat(socketAddress.getAddress().getHostAddress()).isEqualTo("0.0.0.0");
Assertions.assertThat(socketAddress.getPort()).isPositive();
Assertions.assertThat(!service.url().contains("0.0.0.0")).isTrue();
} finally {
service.stop().join();
Expand All @@ -331,21 +331,21 @@ public void ethGetUncleCountByBlockHash() throws Exception {
@SuppressWarnings("unchecked")
final List<Hash> list = Mockito.mock(List.class);

Mockito.when(blockchainQueries.blockByHash(ArgumentMatchers.eq(blockHash)))
.thenReturn(Optional.of(block));
Mockito.when(blockchainQueries.blockByHash(blockHash)).thenReturn(Optional.of(block));
Mockito.when(block.getOmmers()).thenReturn(list);
Mockito.when(list.size()).thenReturn(uncleCount);

final String query = "{block(hash:\"" + blockHash.toString() + "\") {ommerCount}}";
final String query = "{block(hash:\"" + blockHash + "\") {ommerCount}}";

final RequestBody body = RequestBody.create(query, GRAPHQL);
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) {
Assertions.assertThat(resp.code()).isEqualTo(200);
final String jsonStr = resp.body().string();
final JsonObject json = new JsonObject(jsonStr);
testHelper.assertValidGraphQLResult(json);
final int result = json.getJsonObject("data").getJsonObject("block").getInteger("ommerCount");
Assertions.assertThat(result).isEqualTo(uncleCount);
final String result =
json.getJsonObject("data").getJsonObject("block").getString("ommerCount");
Assertions.assertThat(Bytes.fromHexStringLenient(result).toInt()).isEqualTo(uncleCount);
}
}

Expand All @@ -370,8 +370,9 @@ public void ethGetUncleCountByBlockNumber() throws Exception {
final String jsonStr = resp.body().string();
final JsonObject json = new JsonObject(jsonStr);
testHelper.assertValidGraphQLResult(json);
final int result = json.getJsonObject("data").getJsonObject("block").getInteger("ommerCount");
Assertions.assertThat(result).isEqualTo(uncleCount);
final String result =
json.getJsonObject("data").getJsonObject("block").getString("ommerCount");
Assertions.assertThat(Bytes.fromHexStringLenient(result).toInt()).isEqualTo(uncleCount);
}
}

Expand All @@ -395,8 +396,9 @@ public void ethGetUncleCountByBlockLatest() throws Exception {
final String jsonStr = resp.body().string();
final JsonObject json = new JsonObject(jsonStr);
testHelper.assertValidGraphQLResult(json);
final int result = json.getJsonObject("data").getJsonObject("block").getInteger("ommerCount");
Assertions.assertThat(result).isEqualTo(uncleCount);
final String result =
json.getJsonObject("data").getJsonObject("block").getString("ommerCount");
Assertions.assertThat(Bytes.fromHexStringLenient(result).toInt()).isEqualTo(uncleCount);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void serializeLongTest() {
scalar
.getCoercing()
.serialize(value, GraphQLContext.newContext().build(), Locale.ENGLISH))
.isEqualTo(value);
.isEqualTo(str);
}

@Test
Expand All @@ -84,7 +84,7 @@ public void serializeStringTest() {
scalar
.getCoercing()
.serialize(str, GraphQLContext.newContext().build(), Locale.ENGLISH))
.isEqualTo(value);
.isEqualTo(str);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"request":
"{ block (number: 33) { number withdrawalsRoot withdrawals { index amount validator address } } }",

"request": "{ block (number: 33) { number withdrawalsRoot withdrawals { index amount validator address } } }",
"response": {
"data" : {
"block" : {
"number" : 33,
"data": {
"block": {
"number": "0x21",
"withdrawalsRoot": "0x37945ab58d2712a26df2a38d217e822694927e29b30d5993d7a53ccea618d1f3",
"withdrawals": [{
"index": 0,
"amount": 10000000000,
"validator": 10,
"address": "0x0000000000000000000000000000000000000dad"
}]
"withdrawals": [
{
"index": "0x0",
"amount": "0x2540be400",
"validator": "0xa",
"address": "0x0000000000000000000000000000000000000dad"
}
]
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
"request":
"{ block (number: 32) { number withdrawalsRoot withdrawals { index amount } } }",

"request": "{ block (number: 32) { number withdrawalsRoot withdrawals { index amount } } }",
"response": {
"data" : {
"block" : {
"number" : 32,
"data": {
"block": {
"number": "0x20",
"withdrawalsRoot": null,
"withdrawals": null
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
"request":
"{ block { number } }",

"response": {
"data" : {
"block" : {
"number" : 33
"request": "{ block { number } }",
"response": {
"data": {
"block": {
"number": "0x21"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"request": "{block(number :\"0x8\") {number call (data : {from : \"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\", to: \"0x6295ee1b4f6dd65047762f924ecd367c17eabf8f\", data :\"0x12a7b914\"}){data status}}}"
,
"response":{
"data" : {
"block" : {
"number" : 8,
"call" : {
"data" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"status" : 1
"request": "{block(number :\"0x8\") {number call (data : {from : \"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\", to: \"0x6295ee1b4f6dd65047762f924ecd367c17eabf8f\", data :\"0x12a7b914\"}){data status}}}",
"response": {
"data": {
"block": {
"number": "0x8",
"call": {
"data": "0x0000000000000000000000000000000000000000000000000000000000000000",
"status": "0x1"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"request": "{block(number :\"0x8\") {number call (data : {from : \"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\", to: \"0x6295ee1b4f6dd65047762f924ecd367c17eabf8f\", data :\"12a7b914\"}){data status}}}"
,
"request": "{block(number :\"0x8\") {number call (data : {from : \"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\", to: \"0x6295ee1b4f6dd65047762f924ecd367c17eabf8f\", data :\"12a7b914\"}){data status}}}",
"response": {
"errors": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"request": "{block {number call (data : {from : \"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\", to: \"0x6295ee1b4f6dd65047762f924ecd367c17eabf8f\", data :\"0x12a7b914\"}){data status}}}"
,
"response":{
"data" : {
"block" : {
"number" : 33,
"call" : {
"data" : "0x0000000000000000000000000000000000000000000000000000000000000001",
"status" : 1
"request": "{block {number call (data : {from : \"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\", to: \"0x6295ee1b4f6dd65047762f924ecd367c17eabf8f\", data :\"0x12a7b914\"}){data status}}}",
"response": {
"data": {
"block": {
"number": "0x21",
"call": {
"data": "0x0000000000000000000000000000000000000000000000000000000000000001",
"status": "0x1"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"request": "{block {number call (data : {from : \"0x6295ee1b4f6dd65047762f924ecd367c17eabf8f\", to: \"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\", data :\"0x123456\"}){data status}}}"
,
"response":{
"data" : {
"block" : {
"number" : 33,
"call" : {
"data" : "0x",
"status" : 1
"request": "{block {number call (data : {from : \"0x6295ee1b4f6dd65047762f924ecd367c17eabf8f\", to: \"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\", data :\"0x123456\"}){data status}}}",
"response": {
"data": {
"block": {
"number": "0x21",
"call": {
"data": "0x",
"status": "0x1"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{

"request" :"{block{estimateGas (data: {from :\"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\", data :\"0x608060405234801561001057600080fd5b50610157806100206000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633bdab8bf146100515780639ae97baa14610068575b600080fd5b34801561005d57600080fd5b5061006661007f565b005b34801561007457600080fd5b5061007d6100b9565b005b7fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60016040518082815260200191505060405180910390a1565b7fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60026040518082815260200191505060405180910390a17fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60036040518082815260200191505060405180910390a15600a165627a7a7230582010ddaa52e73a98c06dbcd22b234b97206c1d7ed64a7c048e10c2043a3d2309cb0029\"})}}",
"response":{
"data" : {
"block" : {
"estimateGas" : 127129
"request": "{block{estimateGas (data: {from :\"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\", data :\"0x608060405234801561001057600080fd5b50610157806100206000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633bdab8bf146100515780639ae97baa14610068575b600080fd5b34801561005d57600080fd5b5061006661007f565b005b34801561007457600080fd5b5061007d6100b9565b005b7fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60016040518082815260200191505060405180910390a1565b7fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60026040518082815260200191505060405180910390a17fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60036040518082815260200191505060405180910390a15600a165627a7a7230582010ddaa52e73a98c06dbcd22b234b97206c1d7ed64a7c048e10c2043a3d2309cb0029\"})}}",
"response": {
"data": {
"block": {
"estimateGas": "0x1f099"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"request" :"{block{estimateGas (data : {from : \"0x6295ee1b4f6dd65047762f924ecd367c17eabf8f\", to: \"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\", data :\"0x123456\"})}}",
"response":{
"data" : {
"block" : {
"estimateGas" : 21048
"request": "{block{estimateGas (data : {from : \"0x6295ee1b4f6dd65047762f924ecd367c17eabf8f\", to: \"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\", data :\"0x123456\"})}}",
"response": {
"data": {
"block": {
"estimateGas": "0x5238"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"request" :"{block{ estimateGas(data:{}) }}",
"response":{
"data" : {
"block" : {
"estimateGas" : 53000
"request": "{block{ estimateGas(data:{}) }}",
"response": {
"data": {
"block": {
"estimateGas": "0xcf08"
}
}
},

"statusCode": 200
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"request" :"{block{estimateGas (data: {from :\"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\", to :\"0x8888f1f195afa192cfee860698584c030f4c9db1\"})}}",
"response":{
"data" : {
"block" : {
"estimateGas" : 21000
"request": "{block{estimateGas (data: {from :\"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\", to :\"0x8888f1f195afa192cfee860698584c030f4c9db1\"})}}",
"response": {
"data": {
"block": {
"estimateGas": "0x5208"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"request":
"{ gasPrice maxPriorityFeePerGas }",

"request": "{ gasPrice maxPriorityFeePerGas }",
"response": {
"data" : {
"gasPrice" : "0x1",
"data": {
"gasPrice": "0x1",
"maxPriorityFeePerGas": "0x0"
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"request": "{ block(number:\"0x19\") { account(address: \"0x6295ee1b4f6dd65047762f924ecd367c17eabf8f\") { balance } } }",
"response": {
"data" : {
"data": {
"block": {
"account" : {
"balance" : "0xfa"
"account": {
"balance": "0xfa"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"data": {
"pending": {
"account": {
"balance": "0x0"
"balance": "0x0"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"request": "{ pending { account(address: \"0x6295ee1b4f6dd65047762f924ecd367c17eabf8f\") { balance } } }",
"response": {
"data" : {
"pending" : {
"data": {
"pending": {
"account": {
"balance": "0x140"
}
Expand Down
Loading