use of tech.pegasys.web3signer.dsl.utils.MetadataFileHelpers in project web3signer by ConsenSys.
the class MetricsAcceptanceTest method signMetricIncrementsWhenSecpSignRequestReceived.
@Test
void signMetricIncrementsWhenSecpSignRequestReceived(@TempDir Path testDirectory) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException {
final MetadataFileHelpers fileHelpers = new MetadataFileHelpers();
final ECKeyPair keyPair = Keys.createEcKeyPair();
fileHelpers.createUnencryptedYamlFileAt(testDirectory.resolve(keyPair.getPublicKey().toString() + ".yaml"), Numeric.toHexStringWithPrefixZeroPadded(keyPair.getPrivateKey(), 64), SECP256K1);
final SignerConfiguration signerConfiguration = new SignerConfigurationBuilder().withMetricsCategories("SIGNING").withMetricsEnabled(true).withKeyStoreDirectory(testDirectory).withMode("eth1").build();
startSigner(signerConfiguration);
final List<String> metricsOfInterest = List.of("signing_" + SECP256K1.name().toLowerCase() + "_signing_duration_count", "signing_" + SECP256K1.name().toLowerCase() + "_missing_identifier_count");
final Set<String> initialMetrics = signer.getMetricsMatching(metricsOfInterest);
assertThat(initialMetrics).hasSize(metricsOfInterest.size());
assertThat(initialMetrics).allMatch(s -> s.endsWith("0.0"));
signer.eth1Sign(Numeric.toHexStringWithPrefixZeroPadded(keyPair.getPublicKey(), 128), Bytes.fromHexString("1122"));
final Set<String> metricsAfterSign = signer.getMetricsMatching(metricsOfInterest);
assertThat(metricsAfterSign).containsOnly("signing_" + SECP256K1.name().toLowerCase() + "_signing_duration_count 1.0", "signing_" + SECP256K1.name().toLowerCase() + "_missing_identifier_count 0.0");
}
use of tech.pegasys.web3signer.dsl.utils.MetadataFileHelpers in project web3signer by ConsenSys.
the class MetricsAcceptanceTest method signMetricIncrementsWhenBlsSignRequestReceived.
@Test
void signMetricIncrementsWhenBlsSignRequestReceived(@TempDir Path testDirectory) throws JsonProcessingException {
final MetadataFileHelpers fileHelpers = new MetadataFileHelpers();
final BLSKeyPair keyPair = BLSTestUtil.randomKeyPair(1);
fileHelpers.createUnencryptedYamlFileAt(testDirectory.resolve(keyPair.getPublicKey().toBytesCompressed().toHexString() + ".yaml"), keyPair.getSecretKey().toBytes().toHexString(), BLS);
final SignerConfiguration signerConfiguration = new SignerConfigurationBuilder().withMetricsCategories("SIGNING").withMetricsEnabled(true).withKeyStoreDirectory(testDirectory).withMode("eth2").build();
startSigner(signerConfiguration);
final List<String> metricsOfInterest = List.of("signing_" + BLS.name().toLowerCase() + "_signing_duration_count", "signing_" + BLS.name().toLowerCase() + "_missing_identifier_count");
final Set<String> initialMetrics = signer.getMetricsMatching(metricsOfInterest);
assertThat(initialMetrics).hasSize(metricsOfInterest.size());
assertThat(initialMetrics).allMatch(s -> s.endsWith("0.0"));
signer.eth2Sign(keyPair.getPublicKey().toBytesCompressed().toHexString(), Eth2RequestUtils.createBlockRequest(UInt64.valueOf(1), Bytes32.fromHexString("0x1111")));
final Set<String> metricsAfterSign = signer.getMetricsMatching(metricsOfInterest);
assertThat(metricsAfterSign).containsOnly("signing_" + BLS.name().toLowerCase() + "_signing_duration_count 1.0", "signing_" + BLS.name().toLowerCase() + "_missing_identifier_count 0.0");
}
Aggregations