GraphQL serializes BlobVersionedHashes (#6769)

Fix error where GraphQL fails to serialize the versioned hash of a
blob transaction.

Signed-off-by: Danno Ferrin (shemnon) <danno.ferrin@shemnon.com>
pull/6781/head
Danno Ferrin 8 months ago committed by GitHub
parent 010f947836
commit da4be733e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/Scalars.java
  2. 10
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/scalar/Bytes32ScalarTest.java

@ -15,6 +15,7 @@
package org.hyperledger.besu.ethereum.api.graphql.internal;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.VersionedHash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity;
import java.math.BigInteger;
@ -256,6 +257,8 @@ public class Scalars {
return null;
}
}
} else if (input instanceof VersionedHash versionedHash) {
return versionedHash.toBytes();
} else {
return null;
}

@ -17,6 +17,8 @@ package org.hyperledger.besu.ethereum.api.graphql.scalar;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.VersionedHash;
import org.hyperledger.besu.ethereum.api.graphql.internal.Scalars;
import java.util.Locale;
@ -42,6 +44,8 @@ public class Bytes32ScalarTest {
private final StringValue strValue = StringValue.newStringValue(str).build();
private final StringValue invalidStrValue = StringValue.newStringValue("0xgh").build();
private final VersionedHash versionedHash = new VersionedHash((byte)1, Hash.hash(value));
@Test
public void pareValueTest() {
final var result =
@ -121,6 +125,12 @@ public class Bytes32ScalarTest {
.isInstanceOf(CoercingParseLiteralException.class);
}
@Test
public void parseVersionedHash() {
assertThat(scalar.getCoercing().serialize(versionedHash, GraphQLContext.newContext().build(), Locale.ENGLISH))
.isEqualTo(versionedHash.toString());
}
@BeforeEach
public void before() {
scalar = Scalars.bytes32Scalar();

Loading…
Cancel
Save