Search in sources :

Example 1 with BesuNode

use of tech.pegasys.teku.test.acceptance.dsl.BesuNode in project teku by ConsenSys.

the class VoluntaryExitAcceptanceTest method shouldChangeValidatorStatusAfterSubmittingVoluntaryExit.

@Test
void shouldChangeValidatorStatusAfterSubmittingVoluntaryExit() throws Exception {
    final String networkName = "less-swift";
    final BesuNode eth1Node = createBesuNode();
    eth1Node.start();
    final ValidatorKeystores validatorKeystores = createTekuDepositSender(networkName).sendValidatorDeposits(eth1Node, 4);
    final TekuNode beaconNode = createTekuNode(config -> config.withNetwork(networkName).withDepositsFrom(eth1Node));
    final TekuVoluntaryExit voluntaryExitProcessFailing = createVoluntaryExit(config -> config.withBeaconNode(beaconNode)).withValidatorKeystores(validatorKeystores);
    final TekuVoluntaryExit voluntaryExitProcessSuccessful = createVoluntaryExit(config -> config.withBeaconNode(beaconNode)).withValidatorKeystores(validatorKeystores);
    final TekuValidatorNode validatorClient = createValidatorNode(config -> config.withNetwork(networkName).withInteropModeDisabled().withBeaconNode(beaconNode)).withValidatorKeystores(validatorKeystores);
    beaconNode.start();
    validatorClient.start();
    validatorClient.waitForLogMessageContaining("Published block");
    validatorClient.waitForLogMessageContaining("Published attestation");
    validatorClient.waitForLogMessageContaining("Published aggregate");
    beaconNode.waitForLogMessageContaining("Epoch: 1");
    voluntaryExitProcessFailing.start();
    beaconNode.waitForLogMessageContaining("Epoch: 3");
    voluntaryExitProcessSuccessful.start();
    validatorClient.waitForLogMessageContaining("has changed status from");
    assertThat(voluntaryExitProcessFailing.getLoggedErrors()).contains("Failed to submit exit for validator");
}
Also used : Test(org.junit.jupiter.api.Test) AcceptanceTestBase(tech.pegasys.teku.test.acceptance.dsl.AcceptanceTestBase) 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) BesuNode(tech.pegasys.teku.test.acceptance.dsl.BesuNode) TekuVoluntaryExit(tech.pegasys.teku.test.acceptance.dsl.TekuVoluntaryExit) AssertionsForClassTypes.assertThat(org.assertj.core.api.AssertionsForClassTypes.assertThat) BesuNode(tech.pegasys.teku.test.acceptance.dsl.BesuNode) TekuVoluntaryExit(tech.pegasys.teku.test.acceptance.dsl.TekuVoluntaryExit) 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) Test(org.junit.jupiter.api.Test)

Example 2 with BesuNode

use of tech.pegasys.teku.test.acceptance.dsl.BesuNode in project teku by ConsenSys.

the class GenesisStateAcceptanceTest method shouldCreateTheSameGenesisState.

@Test
public void shouldCreateTheSameGenesisState() throws Exception {
    final BesuNode eth1Node = createBesuNode();
    eth1Node.start();
    createTekuDepositSender(Config.DEFAULT_NETWORK_NAME).sendValidatorDeposits(eth1Node, 4);
    final TekuNode firstTeku = createTekuNode(config -> config.withDepositsFrom(eth1Node));
    firstTeku.start();
    firstTeku.waitForGenesis();
    final TekuNode lateJoinTeku = createTekuNode(config -> config.withDepositsFrom(eth1Node));
    lateJoinTeku.start();
    lateJoinTeku.waitForGenesis();
    // Even though the nodes aren't connected to each other they should generate the same genesis
    // state because they processed the same deposits from the same ETH1 chain.
    lateJoinTeku.waitUntilInSyncWith(firstTeku);
}
Also used : BesuNode(tech.pegasys.teku.test.acceptance.dsl.BesuNode) TekuNode(tech.pegasys.teku.test.acceptance.dsl.TekuNode) Test(org.junit.jupiter.api.Test)

Example 3 with BesuNode

use of tech.pegasys.teku.test.acceptance.dsl.BesuNode in project teku by ConsenSys.

the class GenesisStateAcceptanceTest method shouldCreateGenesisFromPartialDeposits.

@Test
public void shouldCreateGenesisFromPartialDeposits() throws Exception {
    final BesuNode eth1Node = createBesuNode();
    eth1Node.start();
    int numberOfValidators = 4;
    final TekuDepositSender depositSender = createTekuDepositSender(Config.DEFAULT_NETWORK_NAME);
    final List<ValidatorKeys> validatorKeys = depositSender.generateValidatorKeys(numberOfValidators);
    depositSender.sendValidatorDeposits(eth1Node, validatorKeys, depositSender.getMinDepositAmount());
    depositSender.sendValidatorDeposits(eth1Node, validatorKeys, depositSender.getMaxEffectiveBalance().minus(depositSender.getMinDepositAmount()));
    final TekuNode teku = createTekuNode(config -> config.withDepositsFrom(eth1Node));
    teku.start();
    teku.waitForGenesis();
    teku.waitForValidators(numberOfValidators);
}
Also used : BesuNode(tech.pegasys.teku.test.acceptance.dsl.BesuNode) ValidatorKeys(tech.pegasys.teku.test.acceptance.dsl.tools.deposits.ValidatorKeys) TekuNode(tech.pegasys.teku.test.acceptance.dsl.TekuNode) TekuDepositSender(tech.pegasys.teku.test.acceptance.dsl.TekuDepositSender) Test(org.junit.jupiter.api.Test)

Example 4 with BesuNode

use of tech.pegasys.teku.test.acceptance.dsl.BesuNode 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)

Example 5 with BesuNode

use of tech.pegasys.teku.test.acceptance.dsl.BesuNode 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();
}
Also used : BesuNode(tech.pegasys.teku.test.acceptance.dsl.BesuNode) 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) BLSPublicKey(tech.pegasys.teku.bls.BLSPublicKey) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)7 BesuNode (tech.pegasys.teku.test.acceptance.dsl.BesuNode)7 TekuNode (tech.pegasys.teku.test.acceptance.dsl.TekuNode)7 ValidatorKeystores (tech.pegasys.teku.test.acceptance.dsl.tools.deposits.ValidatorKeystores)4 TekuValidatorNode (tech.pegasys.teku.test.acceptance.dsl.TekuValidatorNode)3 BLSPublicKey (tech.pegasys.teku.bls.BLSPublicKey)2 ValidatorKeysApi (tech.pegasys.teku.test.acceptance.dsl.tools.ValidatorKeysApi)2 IOException (java.io.IOException)1 URL (java.net.URL)1 AssertionsForClassTypes.assertThat (org.assertj.core.api.AssertionsForClassTypes.assertThat)1 AcceptanceTestBase (tech.pegasys.teku.test.acceptance.dsl.AcceptanceTestBase)1 TekuDepositSender (tech.pegasys.teku.test.acceptance.dsl.TekuDepositSender)1 TekuVoluntaryExit (tech.pegasys.teku.test.acceptance.dsl.TekuVoluntaryExit)1 Web3SignerNode (tech.pegasys.teku.test.acceptance.dsl.Web3SignerNode)1 ValidatorKeys (tech.pegasys.teku.test.acceptance.dsl.tools.deposits.ValidatorKeys)1