Search in sources :

Example 1 with Web3SignerNode

use of tech.pegasys.teku.test.acceptance.dsl.Web3SignerNode 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();
}
Also used : BesuNode(tech.pegasys.teku.test.acceptance.dsl.BesuNode) Web3SignerNode(tech.pegasys.teku.test.acceptance.dsl.Web3SignerNode) ValidatorKeysApi(tech.pegasys.teku.test.acceptance.dsl.tools.ValidatorKeysApi) TekuNode(tech.pegasys.teku.test.acceptance.dsl.TekuNode) TekuValidatorNode(tech.pegasys.teku.test.acceptance.dsl.TekuValidatorNode) ValidatorKeystores(tech.pegasys.teku.test.acceptance.dsl.tools.deposits.ValidatorKeystores) IOException(java.io.IOException) BLSPublicKey(tech.pegasys.teku.bls.BLSPublicKey) URL(java.net.URL) Test(org.junit.jupiter.api.Test)

Aggregations

IOException (java.io.IOException)1 URL (java.net.URL)1 Test (org.junit.jupiter.api.Test)1 BLSPublicKey (tech.pegasys.teku.bls.BLSPublicKey)1 BesuNode (tech.pegasys.teku.test.acceptance.dsl.BesuNode)1 TekuNode (tech.pegasys.teku.test.acceptance.dsl.TekuNode)1 TekuValidatorNode (tech.pegasys.teku.test.acceptance.dsl.TekuValidatorNode)1 Web3SignerNode (tech.pegasys.teku.test.acceptance.dsl.Web3SignerNode)1 ValidatorKeysApi (tech.pegasys.teku.test.acceptance.dsl.tools.ValidatorKeysApi)1 ValidatorKeystores (tech.pegasys.teku.test.acceptance.dsl.tools.deposits.ValidatorKeystores)1