Search in sources :

Example 11 with SimulationTest

use of com.radixdlt.harness.simulation.SimulationTest in project radixdlt by radixdlt.

the class MovingWindowValidatorsTest method given_correct_1_node_bft_with_4_total_nodes_with_changing_epochs_per_100_views__then_should_pass_bft_and_epoch_invariants.

@Test
public void given_correct_1_node_bft_with_4_total_nodes_with_changing_epochs_per_100_views__then_should_pass_bft_and_epoch_invariants() {
    SimulationTest bftTest = bftTestBuilder.numNodes(4).ledgerAndEpochs(View.of(100), windowedEpochToNodesMapper(1, 4)).pacemakerTimeout(5000).addTestModules(ConsensusMonitors.liveness(5, TimeUnit.SECONDS), ConsensusMonitors.epochCeilingView(View.of(100))).build();
    final var checkResults = bftTest.run().awaitCompletion();
    assertThat(checkResults).allSatisfy((name, err) -> assertThat(err).isEmpty());
}
Also used : SimulationTest(com.radixdlt.harness.simulation.SimulationTest) Test(org.junit.Test) SimulationTest(com.radixdlt.harness.simulation.SimulationTest)

Example 12 with SimulationTest

use of com.radixdlt.harness.simulation.SimulationTest in project radixdlt by radixdlt.

the class RandomValidatorsTest method given_deterministic_randomized_validator_sets__then_should_pass_bft_and_epoch_invariants.

@Test
public void given_deterministic_randomized_validator_sets__then_should_pass_bft_and_epoch_invariants() {
    SimulationTest bftTest = bftTestBuilder.ledgerAndEpochs(View.of(100), goodRandomEpochToNodesMapper()).build();
    final var checkResults = bftTest.run().awaitCompletion();
    assertThat(checkResults).allSatisfy((name, err) -> AssertionsForClassTypes.assertThat(err).isEmpty());
}
Also used : SimulationTest(com.radixdlt.harness.simulation.SimulationTest) Test(org.junit.Test) SimulationTest(com.radixdlt.harness.simulation.SimulationTest)

Example 13 with SimulationTest

use of com.radixdlt.harness.simulation.SimulationTest in project radixdlt by radixdlt.

the class IncreasingValidatorsTest method when_increasing_validators__then_they_should_be_getting_registered.

@Test
public void when_increasing_validators__then_they_should_be_getting_registered() {
    SimulationTest simulationTest = bftTestBuilder.build();
    final var runningTest = simulationTest.run();
    final var checkResults = runningTest.awaitCompletion();
    assertThat(checkResults).allSatisfy((name, err) -> assertThat(err).isEmpty());
}
Also used : SimulationTest(com.radixdlt.harness.simulation.SimulationTest) Test(org.junit.Test) SimulationTest(com.radixdlt.harness.simulation.SimulationTest)

Example 14 with SimulationTest

use of com.radixdlt.harness.simulation.SimulationTest in project radixdlt by radixdlt.

the class FPlusOneOutOfBoundsTest method given_1_out_of_3_nodes_out_of_synchrony_bounds.

/**
 * Tests a configuration of 1 out of 3 nodes out of synchrony bounds
 */
@Test
public void given_1_out_of_3_nodes_out_of_synchrony_bounds() {
    SimulationTest test = bftTestBuilder.numNodes(3).networkModules(NetworkOrdering.inOrder(), NetworkLatencies.oneOutOfBounds(LATENCY_MS, LIVENESS_MS)).build();
    final var runningTest = test.run();
    final var checkResults = runningTest.awaitCompletion();
    assertThat(checkResults).hasEntrySatisfying(Monitor.CONSENSUS_LIVENESS, error -> assertThat(error).isPresent()).hasEntrySatisfying(Monitor.CONSENSUS_SAFETY, error -> assertThat(error).isNotPresent());
}
Also used : Monitor(com.radixdlt.harness.simulation.Monitor) TimeUnit(java.util.concurrent.TimeUnit) Builder(com.radixdlt.harness.simulation.SimulationTest.Builder) NetworkLatencies(com.radixdlt.harness.simulation.NetworkLatencies) AssertionsForInterfaceTypes.assertThat(org.assertj.core.api.AssertionsForInterfaceTypes.assertThat) NetworkOrdering(com.radixdlt.harness.simulation.NetworkOrdering) Test(org.junit.Test) ConsensusMonitors(com.radixdlt.harness.simulation.monitors.consensus.ConsensusMonitors) SimulationTest(com.radixdlt.harness.simulation.SimulationTest) SimulationTest(com.radixdlt.harness.simulation.SimulationTest) Test(org.junit.Test) SimulationTest(com.radixdlt.harness.simulation.SimulationTest)

Example 15 with SimulationTest

use of com.radixdlt.harness.simulation.SimulationTest in project radixdlt by radixdlt.

the class OneByzantineGenesisTest method given_3_correct_bfts_and_1_byzantine__then_should_make_progress.

@Test
public void given_3_correct_bfts_and_1_byzantine__then_should_make_progress() {
    SimulationTest bftTest = bftTestBuilder.numNodes(4).addOverrideModuleToInitialNodes(nodes -> ImmutableList.of(nodes.get(0).getPublicKey()), new MockedRecoveryModule(HashUtils.random256())).addTestModules(ConsensusMonitors.liveness(5, TimeUnit.SECONDS)).build();
    final var checkResults = bftTest.run().awaitCompletion();
    assertThat(checkResults).allSatisfy((name, err) -> assertThat(err).isEmpty());
}
Also used : SimulationTest(com.radixdlt.harness.simulation.SimulationTest) MockedRecoveryModule(com.radixdlt.recovery.MockedRecoveryModule) Test(org.junit.Test) SimulationTest(com.radixdlt.harness.simulation.SimulationTest)

Aggregations

SimulationTest (com.radixdlt.harness.simulation.SimulationTest)43 Test (org.junit.Test)43 NetworkLatencies (com.radixdlt.harness.simulation.NetworkLatencies)10 NetworkOrdering (com.radixdlt.harness.simulation.NetworkOrdering)10 ConsensusMonitors (com.radixdlt.harness.simulation.monitors.consensus.ConsensusMonitors)10 TimeUnit (java.util.concurrent.TimeUnit)10 Builder (com.radixdlt.harness.simulation.SimulationTest.Builder)9 CounterType (com.radixdlt.counters.SystemCounters.CounterType)8 NetworkDroppers (com.radixdlt.harness.simulation.NetworkDroppers)8 LongSummaryStatistics (java.util.LongSummaryStatistics)8 LedgerMonitors (com.radixdlt.harness.simulation.monitors.ledger.LedgerMonitors)7 AbstractModule (com.google.inject.AbstractModule)6 AssertionsForInterfaceTypes.assertThat (org.assertj.core.api.AssertionsForInterfaceTypes.assertThat)6 SyncConfig (com.radixdlt.sync.SyncConfig)5 AssertionsForClassTypes (org.assertj.core.api.AssertionsForClassTypes)5 LogManager (org.apache.logging.log4j.LogManager)4 Logger (org.apache.logging.log4j.Logger)4 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)4 TypeLiteral (com.google.inject.TypeLiteral)3 ProvidesIntoSet (com.google.inject.multibindings.ProvidesIntoSet)3