Search in sources :

Example 6 with SimulationTest

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

the class OneNodeFallingBehindTest method sanity_test.

@Test
public void sanity_test() {
    SimulationTest test = bftTestBuilder.build();
    final var runningTest = test.run(Duration.ofSeconds(60));
    final var checkResults = runningTest.awaitCompletion();
    LongSummaryStatistics statistics = runningTest.getNetwork().getSystemCounters().values().stream().map(s -> s.get(CounterType.BFT_SYNC_REQUESTS_SENT)).mapToLong(l -> l).summaryStatistics();
    System.out.println(statistics);
    assertThat(checkResults).allSatisfy((name, error) -> AssertionsForClassTypes.assertThat(error).isNotPresent());
}
Also used : LongSummaryStatistics(java.util.LongSummaryStatistics) IntStream(java.util.stream.IntStream) NetworkOrdering(com.radixdlt.harness.simulation.NetworkOrdering) AssertionsForClassTypes(org.assertj.core.api.AssertionsForClassTypes) Test(org.junit.Test) NetworkDroppers(com.radixdlt.harness.simulation.NetworkDroppers) SimulationTest(com.radixdlt.harness.simulation.SimulationTest) TimeUnit(java.util.concurrent.TimeUnit) Builder(com.radixdlt.harness.simulation.SimulationTest.Builder) NetworkLatencies(com.radixdlt.harness.simulation.NetworkLatencies) View(com.radixdlt.hotstuff.bft.View) SyncConfig(com.radixdlt.sync.SyncConfig) Duration(java.time.Duration) AssertionsForInterfaceTypes.assertThat(org.assertj.core.api.AssertionsForInterfaceTypes.assertThat) LedgerMonitors(com.radixdlt.harness.simulation.monitors.ledger.LedgerMonitors) ConsensusMonitors(com.radixdlt.harness.simulation.monitors.consensus.ConsensusMonitors) CounterType(com.radixdlt.counters.SystemCounters.CounterType) LongSummaryStatistics(java.util.LongSummaryStatistics) SimulationTest(com.radixdlt.harness.simulation.SimulationTest) Test(org.junit.Test) SimulationTest(com.radixdlt.harness.simulation.SimulationTest)

Example 7 with SimulationTest

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

the class OneOutOfBoundsTest method given_1_out_of_4_nodes_out_of_synchrony_bounds.

/**
 * Tests a configuration of 1 out of 4 nodes out of synchrony bounds
 */
@Test
public void given_1_out_of_4_nodes_out_of_synchrony_bounds() {
    SimulationTest test = bftTestBuilder.numNodes(4).build();
    final var runningTest = test.run();
    final var checkResults = runningTest.awaitCompletion();
    assertThat(checkResults).allSatisfy((name, error) -> assertThat(error).isNotPresent());
}
Also used : SimulationTest(com.radixdlt.harness.simulation.SimulationTest) Test(org.junit.Test) SimulationTest(com.radixdlt.harness.simulation.SimulationTest)

Example 8 with SimulationTest

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

the class TimeoutPreviousVoteWithDroppedProposalsTest method sanity_test.

@Test
public void sanity_test() {
    SimulationTest test = bftTestBuilder.build();
    final var runningTest = test.run(Duration.ofSeconds(10));
    final var results = runningTest.awaitCompletion();
    final var statistics = runningTest.getNetwork().getSystemCounters().values().stream().map(s -> LongStream.of(s.get(CounterType.BFT_PACEMAKER_TIMEOUTS_SENT), s.get(CounterType.BFT_PACEMAKER_TIMED_OUT_ROUNDS))).map(LongStream::summaryStatistics).collect(ImmutableList.toImmutableList());
    statistics.forEach(s -> {
        // to make sure we've processed some views
        assertTrue(s.getMin() > 2);
        // this ensures that we only need a single timeout per view
        // BFT_TIMEOUT equal to BFT_TIMED_OUT_VIEWS
        assertEquals(s.getMin(), s.getMax());
    });
    assertThat(results).allSatisfy((name, error) -> AssertionsForClassTypes.assertThat(error).isNotPresent());
}
Also used : SimulationTest(com.radixdlt.harness.simulation.SimulationTest) Test(org.junit.Test) SimulationTest(com.radixdlt.harness.simulation.SimulationTest)

Example 9 with SimulationTest

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

the class MovingWindowValidatorsTest method given_correct_25_node_bft_with_50_total_nodes_with_changing_epochs_per_100_views__then_should_pass_bft_and_epoch_invariants.

@Test
public void given_correct_25_node_bft_with_50_total_nodes_with_changing_epochs_per_100_views__then_should_pass_bft_and_epoch_invariants() {
    SimulationTest bftTest = bftTestBuilder.numNodes(100).ledgerAndEpochs(View.of(100), windowedEpochToNodesMapper(25, 50)).pacemakerTimeout(5000).addTestModules(ConsensusMonitors.liveness(5, // High timeout to make Travis happy
    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 10 with SimulationTest

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

the class MovingWindowValidatorsTest method given_correct_25_node_bft_with_50_total_nodes_with_changing_epochs_per_1_view__then_should_pass_bft_and_epoch_invariants.

@Test
public void given_correct_25_node_bft_with_50_total_nodes_with_changing_epochs_per_1_view__then_should_pass_bft_and_epoch_invariants() {
    SimulationTest bftTest = bftTestBuilder.numNodes(100).ledgerAndEpochs(View.of(1), windowedEpochToNodesMapper(25, 50)).pacemakerTimeout(5000).addTestModules(ConsensusMonitors.epochCeilingView(View.of(1)), // High timeout to make Travis happy
    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) 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