use of tech.pegasys.teku.validator.api.ValidatorConfig in project teku by ConsenSys.
the class ValidatorLoaderTest method initializeValidatorsWithExternalSignerAndNoSlashingProtection.
@Test
void initializeValidatorsWithExternalSignerAndNoSlashingProtection() {
final ValidatorConfig config = ValidatorConfig.builder().validatorExternalSignerUrl(SIGNER_URL).validatorExternalSignerPublicKeySources(Collections.singletonList(PUBLIC_KEY1.toString())).validatorExternalSignerSlashingProtectionEnabled(false).build();
final ValidatorLoader validatorLoader = ValidatorLoader.create(spec, config, disabledInteropConfig, httpClientFactory, slashingProtector, slashingProtectionLogger, publicKeyLoader, asyncRunner, metricsSystem, Optional.empty());
validatorLoader.loadValidators();
final OwnedValidators validators = validatorLoader.getOwnedValidators();
assertThat(validators.getValidatorCount()).isEqualTo(1);
final Validator validator = validators.getValidator(PUBLIC_KEY1).orElseThrow();
assertThat(validator).isNotNull();
assertThat(validator.getPublicKey()).isEqualTo(PUBLIC_KEY1);
assertThat(validator.getSigner().isLocal()).isFalse();
final BeaconBlock block = dataStructureUtil.randomBeaconBlock(10);
final ForkInfo forkInfo = dataStructureUtil.randomForkInfo();
when(slashingProtector.maySignBlock(PUBLIC_KEY1, forkInfo.getGenesisValidatorsRoot(), block.getSlot())).thenReturn(SafeFuture.completedFuture(true));
when(httpClient.sendAsync(any(), any())).thenReturn(new SafeFuture<>());
final SafeFuture<BLSSignature> result = validator.getSigner().signBlock(block, forkInfo);
assertThat(result).isNotDone();
// Confirm request was sent without checking with the slashing protector
verifyNoInteractions(slashingProtector);
verify(httpClient).sendAsync(any(), any());
}
Aggregations