Skip to content

Commit

Permalink
Fix voluntary exit flaky acceptance test (Consensys#7754)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov authored Nov 24, 2023
1 parent 04759b4 commit 992b224
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.test.acceptance.dsl.AcceptanceTestBase;
import tech.pegasys.teku.test.acceptance.dsl.GenesisGenerator.InitialStateData;
import tech.pegasys.teku.test.acceptance.dsl.TekuDepositSender;
import tech.pegasys.teku.test.acceptance.dsl.TekuNode;
import tech.pegasys.teku.test.acceptance.dsl.TekuValidatorNode;
import tech.pegasys.teku.test.acceptance.dsl.TekuVoluntaryExit;
Expand All @@ -31,25 +32,29 @@ public class VoluntaryExitAcceptanceTest extends AcceptanceTestBase {
@Test
void shouldChangeValidatorStatusAfterSubmittingVoluntaryExit() throws Exception {
final String networkName = "swift";
final ValidatorKeystores validatorKeystores =
createTekuDepositSender(networkName).generateValidatorKeys(4);
final ValidatorKeystores extraKeys =
createTekuDepositSender(networkName).generateValidatorKeys(1);

final TekuDepositSender depositSender = createTekuDepositSender(networkName);
final ValidatorKeystores validatorKeysToExit = depositSender.generateValidatorKeys(4);
// network of 8 validators (4 of them will exit)
final ValidatorKeystores validatorKeys =
ValidatorKeystores.add(validatorKeysToExit, depositSender.generateValidatorKeys(4));
// 1 unknown key to the network
final ValidatorKeystores unknownKeys = depositSender.generateValidatorKeys(1);

final InitialStateData genesis =
createGenesisGenerator().network(networkName).validatorKeys(validatorKeystores).generate();
createGenesisGenerator().network(networkName).validatorKeys(validatorKeys).generate();

final TekuNode beaconNode =
createTekuNode(config -> config.withNetwork(networkName).withInitialState(genesis));

final TekuVoluntaryExit voluntaryExitProcessFailing =
createVoluntaryExit(config -> config.withBeaconNode(beaconNode))
.withValidatorKeystores(validatorKeystores);
.withValidatorKeystores(validatorKeysToExit);

final TekuVoluntaryExit voluntaryExitProcessSuccessful =
createVoluntaryExit(config -> config.withBeaconNode(beaconNode))
.withValidatorKeystores(validatorKeystores)
.withValidatorKeystores(extraKeys);
.withValidatorKeystores(validatorKeysToExit)
.withValidatorKeystores(unknownKeys);

final TekuValidatorNode validatorClient =
createValidatorNode(
Expand All @@ -58,7 +63,7 @@ void shouldChangeValidatorStatusAfterSubmittingVoluntaryExit() throws Exception
.withNetwork(networkName)
.withInteropModeDisabled()
.withBeaconNode(beaconNode))
.withValidatorKeystores(validatorKeystores);
.withValidatorKeystores(validatorKeys);

beaconNode.start();
validatorClient.start();
Expand All @@ -83,6 +88,6 @@ void shouldChangeValidatorStatusAfterSubmittingVoluntaryExit() throws Exception
assertThat(validatorIds.size()).isEqualTo(4);
assertThat(validatorIds).containsExactlyInAnyOrder(0, 1, 2, 3);
assertThat(voluntaryExitProcessSuccessful.getLoggedErrors())
.contains("Validator not found: " + extraKeys.getPublicKeys().get(0).toString());
.contains("Validator not found: " + unknownKeys.getPublicKeys().get(0).toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ public void sendValidatorDeposits(
new DepositSenderService(
spec, eth1Node.getExternalJsonRpcUrl(), eth1Credentials, eth1Address, amount)) {
final List<SafeFuture<TransactionReceipt>> transactionReceipts =
validatorKeys.getValidatorKeys().stream()
.map(depositSenderService::sendDeposit)
.collect(Collectors.toList());
validatorKeys.getValidatorKeys().stream().map(depositSenderService::sendDeposit).toList();
final SafeFuture<Void> future =
SafeFuture.allOf(transactionReceipts.toArray(SafeFuture[]::new));
Waiter.waitFor(future, Duration.ofMinutes(2));
Expand Down

0 comments on commit 992b224

Please sign in to comment.