use of tech.pegasys.teku.test.acceptance.dsl.tools.ValidatorKeysApi in project teku by ConsenSys.
the class RemoteValidatorKeysAcceptanceTest method shouldMaintainValidatorsInMutableClient.
@Test
void shouldMaintainValidatorsInMutableClient() throws Exception {
final String networkName = "less-swift";
final BesuNode eth1Node = createBesuNode();
eth1Node.start();
final URL resource = Resources.getResource("tech/pegasys/teku/spec/config/configs/less-swift.yaml");
final ValidatorKeystores validatorKeystores = createTekuDepositSender(networkName).sendValidatorDeposits(eth1Node, 8);
final TekuNode beaconNode = createTekuNode(config -> {
try {
config.withNetwork(resource.openStream(), networkName).withDepositsFrom(eth1Node);
} catch (IOException e) {
LOG.error("BN configuration failed", e);
}
});
final Web3SignerNode web3SignerNode = createWeb3SignerNode(config -> {
try {
config.withNetwork(resource.openStream());
} catch (IOException e) {
LOG.error("Signer configuration failed", e);
}
});
web3SignerNode.start();
final ValidatorKeysApi signerApi = web3SignerNode.getValidatorKeysApi();
final TekuValidatorNode validatorClient = createValidatorNode(config -> {
try {
config.withNetwork(resource.openStream()).withValidatorApiEnabled().withExternalSignerUrl(web3SignerNode.getValidatorRestApiUrl()).withInteropModeDisabled().withBeaconNode(beaconNode);
} catch (IOException e) {
LOG.error("VC configuration failed", e);
}
});
beaconNode.start();
validatorClient.start();
signerApi.addLocalValidatorsAndExpect(validatorKeystores, "imported");
signerApi.assertLocalValidatorListing(validatorKeystores.getPublicKeys());
final ValidatorKeysApi validatorNodeApi = validatorClient.getValidatorKeysApi();
validatorNodeApi.assertLocalValidatorListing(Collections.emptyList());
validatorNodeApi.assertRemoteValidatorListing(Collections.emptyList());
validatorNodeApi.addRemoteValidatorsAndExpect(validatorKeystores.getPublicKeys(), web3SignerNode.getValidatorRestApiUrl(), "imported");
validatorClient.waitForLogMessageContaining("Added validator");
validatorNodeApi.assertLocalValidatorListing(Collections.emptyList());
validatorNodeApi.assertRemoteValidatorListing(validatorKeystores.getPublicKeys());
// add Local should see duplicates, as they're already loaded
validatorNodeApi.addLocalValidatorsAndExpect(validatorKeystores, "duplicate");
// second remote add should also see as duplicates
validatorNodeApi.addRemoteValidatorsAndExpect(validatorKeystores.getPublicKeys(), web3SignerNode.getValidatorRestApiUrl(), "duplicate");
validatorClient.waitForLogMessageContaining("Published block");
// remove a validator
final BLSPublicKey removedPubKey = validatorKeystores.getPublicKeys().get(0);
validatorNodeApi.removeRemoteValidatorAndCheckStatus(removedPubKey, "deleted");
// should only be 7 validators left
validatorClient.waitForLogMessageContaining("Removed remote validator");
validatorClient.waitForLogMessageContaining("Published block");
validatorNodeApi.assertRemoteValidatorListing(validatorKeystores.getPublicKeys().subList(1, 7));
// remove validator that doesn't exist
validatorNodeApi.removeRemoteValidatorAndCheckStatus(removedPubKey, "not_found");
validatorClient.stop();
web3SignerNode.stop();
beaconNode.stop();
eth1Node.stop();
}
use of tech.pegasys.teku.test.acceptance.dsl.tools.ValidatorKeysApi in project teku by ConsenSys.
the class LocalValidatorKeysAcceptanceTest method shouldMaintainValidatorsInMutableClient.
@Test
void shouldMaintainValidatorsInMutableClient() throws Exception {
final String networkName = "less-swift";
final BesuNode eth1Node = createBesuNode();
eth1Node.start();
final ValidatorKeystores validatorKeystores = createTekuDepositSender(networkName).sendValidatorDeposits(eth1Node, 8);
final ValidatorKeystores extraKeys = createTekuDepositSender(networkName).sendValidatorDeposits(eth1Node, 1);
final TekuNode beaconNode = createTekuNode(config -> config.withNetwork(networkName).withDepositsFrom(eth1Node));
final TekuValidatorNode validatorClient = createValidatorNode(config -> config.withNetwork(networkName).withValidatorApiEnabled().withInteropModeDisabled().withBeaconNode(beaconNode));
final ValidatorKeysApi api = validatorClient.getValidatorKeysApi();
beaconNode.start();
validatorClient.start();
api.assertLocalValidatorListing(Collections.emptyList());
api.addLocalValidatorsAndExpect(validatorKeystores, "imported");
validatorClient.waitForLogMessageContaining("Added validator");
validatorClient.waitForLogMessageContaining("Published block");
api.assertLocalValidatorListing(validatorKeystores.getPublicKeys());
// second add attempt would be duplicates
api.addLocalValidatorsAndExpect(validatorKeystores, "duplicate");
// a random key won't be found, remove should give not_found
api.removeLocalValidatorAndCheckStatus(extraKeys.getPublicKeys().get(0), "not_found");
beaconNode.waitForEpoch(2);
// remove a validator
final BLSPublicKey removedPubkey = validatorKeystores.getPublicKeys().get(0);
api.removeLocalValidatorAndCheckStatus(removedPubkey, "deleted");
// should only be 7 validators left
validatorClient.waitForLogMessageContaining("Removed validator");
validatorClient.waitForLogMessageContaining("Published block");
api.assertLocalValidatorListing(validatorKeystores.getPublicKeys().subList(1, 7));
// remove the same validator again
api.removeLocalValidatorAndCheckStatus(removedPubkey, "not_active");
validatorClient.stop();
beaconNode.stop();
eth1Node.stop();
}
Aggregations