use of tech.pegasys.teku.api.schema.BLSSignature in project teku by ConsenSys.
the class SingleQueryParameterUtilsTest method getParameterAsBLSSignature_shouldParseBytes96Data.
@Test
public void getParameterAsBLSSignature_shouldParseBytes96Data() {
BLSSignature signature = new BLSSignature(Bytes.random(96));
Map<String, List<String>> data = Map.of(KEY, List.of(signature.toHexString()));
BLSSignature result = getParameterValueAsBLSSignature(data, KEY);
assertEquals(signature, result);
}
use of tech.pegasys.teku.api.schema.BLSSignature in project teku by ConsenSys.
the class OkHttpValidatorRestApiClientTest method createUnsignedBlock_WhenSuccess_ReturnsBeaconBlock.
@Test
public void createUnsignedBlock_WhenSuccess_ReturnsBeaconBlock() {
final UInt64 slot = UInt64.ONE;
final BLSSignature blsSignature = schemaObjects.blsSignature();
final Optional<Bytes32> graffiti = Optional.of(Bytes32.random());
final BeaconBlock expectedBeaconBlock = schemaObjects.beaconBlock();
mockWebServer.enqueue(new MockResponse().setResponseCode(SC_OK).setBody(asJson(new GetNewBlockResponseV2(SpecMilestone.PHASE0, expectedBeaconBlock))));
Optional<BeaconBlock> beaconBlock = apiClient.createUnsignedBlock(slot, blsSignature, graffiti);
assertThat(beaconBlock).isPresent();
assertThat(beaconBlock.get()).usingRecursiveComparison().isEqualTo(expectedBeaconBlock);
}
use of tech.pegasys.teku.api.schema.BLSSignature in project teku by ConsenSys.
the class OkHttpValidatorRestApiClientTest method createUnsignedBlock_MakesExpectedRequest.
@Test
public void createUnsignedBlock_MakesExpectedRequest() throws Exception {
final UInt64 slot = UInt64.ONE;
final BLSSignature blsSignature = schemaObjects.blsSignature();
final Optional<Bytes32> graffiti = Optional.of(Bytes32.random());
mockWebServer.enqueue(new MockResponse().setResponseCode(SC_NO_CONTENT));
apiClient.createUnsignedBlock(slot, blsSignature, graffiti);
RecordedRequest request = mockWebServer.takeRequest();
assertThat(request.getMethod()).isEqualTo("GET");
assertThat(request.getPath()).contains(ValidatorApiMethod.GET_UNSIGNED_BLOCK_V2.getPath(Map.of("slot", "1")));
assertThat(request.getRequestUrl().queryParameter("randao_reveal")).isEqualTo(blsSignature.toHexString());
assertThat(request.getRequestUrl().queryParameter("graffiti")).isEqualTo(graffiti.get().toHexString());
}
use of tech.pegasys.teku.api.schema.BLSSignature in project teku by ConsenSys.
the class OkHttpValidatorRestApiClientTest method createUnsignedBlock_WhenNoContent_ReturnsEmpty.
@Test
public void createUnsignedBlock_WhenNoContent_ReturnsEmpty() {
final UInt64 slot = UInt64.ONE;
final BLSSignature blsSignature = schemaObjects.blsSignature();
final Optional<Bytes32> graffiti = Optional.of(Bytes32.random());
mockWebServer.enqueue(new MockResponse().setResponseCode(SC_NO_CONTENT));
assertThat(apiClient.createUnsignedBlock(slot, blsSignature, graffiti)).isEmpty();
}
use of tech.pegasys.teku.api.schema.BLSSignature in project teku by ConsenSys.
the class OkHttpValidatorRestApiClientTest method createUnsignedBlock_WhenBadRequest_ThrowsIllegalArgumentException.
@Test
public void createUnsignedBlock_WhenBadRequest_ThrowsIllegalArgumentException() {
final UInt64 slot = UInt64.ONE;
final BLSSignature blsSignature = schemaObjects.blsSignature();
final Optional<Bytes32> graffiti = Optional.of(Bytes32.random());
mockWebServer.enqueue(new MockResponse().setResponseCode(SC_BAD_REQUEST));
assertThatThrownBy(() -> apiClient.createUnsignedBlock(slot, blsSignature, graffiti)).isInstanceOf(IllegalArgumentException.class);
}
Aggregations