use of tech.pegasys.web3signer.dsl.utils.Eth2BlockSigningRequestUtil in project web3signer by ConsenSys.
the class Eth2AltairBlockSigningAcceptanceTest method signAndVerifyLegacyBlockSignature.
@Test
void signAndVerifyLegacyBlockSignature() throws Exception {
final Eth2BlockSigningRequestUtil util = new Eth2BlockSigningRequestUtil(SpecMilestone.PHASE0);
setupEth2SignerMinimalWithoutAltairFork();
final Eth2SigningRequestBody request = util.createLegacyBlockRequest();
final Response response = signer.eth2Sign(keyPair.getPublicKey().toString(), request, ContentType.JSON);
final Bytes signature = verifyAndGetSignatureResponse(response, ContentType.JSON);
final BLSSignature expectedSignature = BLS.sign(keyPair.getSecretKey(), request.getSigningRoot());
assertThat(signature).isEqualTo(expectedSignature.toBytesCompressed());
}
use of tech.pegasys.web3signer.dsl.utils.Eth2BlockSigningRequestUtil in project web3signer by ConsenSys.
the class Eth2CustomNetworkFileAcceptanceTest method createBlockV2SigningRequest.
private Eth2SigningRequestBody createBlockV2SigningRequest(final Spec spec, final ForkAndSpecMilestone forkAndMilestone) {
final UInt64 forkEpoch = forkAndMilestone.getFork().getEpoch();
final UInt64 startSlot = spec.computeStartSlotAtEpoch(forkEpoch);
final Eth2BlockSigningRequestUtil util = new Eth2BlockSigningRequestUtil(spec, forkEpoch, startSlot);
return util.createBlockV2Request();
}
use of tech.pegasys.web3signer.dsl.utils.Eth2BlockSigningRequestUtil in project web3signer by ConsenSys.
the class Eth2BlockSigningAcceptanceTest method signAndVerifyLegacyBlockSignature.
@Test
void signAndVerifyLegacyBlockSignature() throws Exception {
final Eth2BlockSigningRequestUtil util = new Eth2BlockSigningRequestUtil(SpecMilestone.PHASE0);
setupEth2Signer(Eth2Network.MINIMAL, SpecMilestone.PHASE0);
final Eth2SigningRequestBody request = util.createLegacyBlockRequest();
final Response response = signer.eth2Sign(keyPair.getPublicKey().toString(), request, ContentType.JSON);
final Bytes signature = verifyAndGetSignatureResponse(response, ContentType.JSON);
final BLSSignature expectedSignature = BLS.sign(keyPair.getSecretKey(), request.getSigningRoot());
assertThat(signature).isEqualTo(expectedSignature.toBytesCompressed());
}
use of tech.pegasys.web3signer.dsl.utils.Eth2BlockSigningRequestUtil 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);
}
use of tech.pegasys.web3signer.dsl.utils.Eth2BlockSigningRequestUtil in project web3signer by ConsenSys.
the class Eth2BlockSigningAcceptanceTest method signAndVerifyBlockV2Signature.
@ParameterizedTest
@EnumSource(value = SpecMilestone.class, names = { "PHASE0", "ALTAIR", "BELLATRIX" })
void signAndVerifyBlockV2Signature(final SpecMilestone specMilestone) throws Exception {
final Eth2BlockSigningRequestUtil util = new Eth2BlockSigningRequestUtil(specMilestone);
setupEth2Signer(Eth2Network.MINIMAL, specMilestone);
final Eth2SigningRequestBody request = util.createBlockV2Request();
final Response response = signer.eth2Sign(keyPair.getPublicKey().toString(), request, ContentType.JSON);
final Bytes signature = verifyAndGetSignatureResponse(response, ContentType.JSON);
final BLSSignature expectedSignature = BLS.sign(keyPair.getSecretKey(), request.getSigningRoot());
assertThat(signature).isEqualTo(expectedSignature.toBytesCompressed());
}
Aggregations