use of com.google.showcase.v1beta1.BlockRequest in project web3signer by ConsenSys.
the class BlockRequestDeserializer method deserialize.
@Override
public BlockRequest deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
final ObjectCodec codec = p.getCodec();
final JsonNode node = codec.readTree(p);
final SpecMilestone specMilestone = SpecMilestone.valueOf(node.findValue("version").asText());
final BeaconBlock beaconBlock;
final BeaconBlockHeader beaconBlockHeader;
final BlockRequest blockRequest;
switch(specMilestone) {
case PHASE0:
beaconBlock = codec.treeToValue(node.findValue("block"), BeaconBlock.class);
blockRequest = new BlockRequest(specMilestone, beaconBlock);
break;
case ALTAIR:
beaconBlock = codec.treeToValue(node.findValue("block"), BeaconBlockAltair.class);
blockRequest = new BlockRequest(specMilestone, beaconBlock);
break;
case BELLATRIX:
// for BELLATRIX we only need block_header instead of complete block
beaconBlockHeader = codec.treeToValue(node.findValue("block_header"), BeaconBlockHeader.class);
blockRequest = new BlockRequest(specMilestone, beaconBlockHeader);
break;
default:
throw new IllegalStateException("Fork version not yet supported: " + specMilestone);
}
return blockRequest;
}
use of com.google.showcase.v1beta1.BlockRequest in project web3signer by ConsenSys.
the class Eth2BlockSigningAcceptanceTest method emptyBlockRequestReturnsBadRequestStatus.
@Test
void emptyBlockRequestReturnsBadRequestStatus() throws JsonProcessingException {
final Eth2BlockSigningRequestUtil util = new Eth2BlockSigningRequestUtil(SpecMilestone.BELLATRIX);
setupEth2Signer(Eth2Network.MINIMAL, SpecMilestone.BELLATRIX);
final Eth2SigningRequestBody request = util.createBlockV2Request(new BlockRequest(SpecMilestone.BELLATRIX));
final Response response = signer.eth2Sign(keyPair.getPublicKey().toString(), request, ContentType.JSON);
response.then().statusCode(400);
}
Aggregations