Search in sources :

Example 26 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) -> AssertionsForClassTypes.assertThat(error).isNotPresent());
}
Also used : SimulationTest(com.radixdlt.harness.simulation.SimulationTest) Test(org.junit.Test) SimulationTest(com.radixdlt.harness.simulation.SimulationTest)

Example 27 with SimulationTest

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

the class OneSlowNodeTest method given_4_nodes_3_fast_and_1_slow_node_and_sync_disabled__then_a_timeout_wont_occur.

/**
 * Tests a static configuration of 3 fast, equal nodes and 1 slow node. Test should pass even with
 * GetVertices RPC disabled
 */
@Test
public void given_4_nodes_3_fast_and_1_slow_node_and_sync_disabled__then_a_timeout_wont_occur() {
    SimulationTest test = bftTestBuilder.build();
    final var runningTest = test.run();
    final var checkResults = runningTest.awaitCompletion();
    assertThat(checkResults).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 28 with SimulationTest

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

the class RandomLatencyTest method given_3_correct_nodes_in_random_network_and_no_sync__then_all_synchronous_checks_should_pass.

/**
 * Tests a static configuration of 3 nodes with random, high variance in latency
 */
@Test
public void given_3_correct_nodes_in_random_network_and_no_sync__then_all_synchronous_checks_should_pass() {
    SimulationTest test = bftTestBuilder.numNodes(3).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 29 with SimulationTest

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

the class RandomVoteAndViewTimeoutDropperTest method sanity_test.

/**
 * Tests a configuration of 4 nodes with a dropping proposal adversary Test should fail with
 * GetVertices RPC disabled
 */
@Test
public void sanity_test() {
    SimulationTest test = bftTestBuilder.build();
    final var runningTest = test.run();
    final var checkResults = runningTest.awaitCompletion();
    LongSummaryStatistics statistics = runningTest.getNetwork().getSystemCounters().values().stream().map(s -> s.get(CounterType.BFT_VERTEX_STORE_FORKS)).mapToLong(l -> l).summaryStatistics();
    System.out.println(statistics);
    assertThat(checkResults).allSatisfy((name, error) -> AssertionsForClassTypes.assertThat(error).isNotPresent());
}
Also used : LongSummaryStatistics(java.util.LongSummaryStatistics) 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) AssertionsForClassTypes(org.assertj.core.api.AssertionsForClassTypes) Test(org.junit.Test) ConsensusMonitors(com.radixdlt.harness.simulation.monitors.consensus.ConsensusMonitors) CounterType(com.radixdlt.counters.SystemCounters.CounterType) LongSummaryStatistics(java.util.LongSummaryStatistics) NetworkDroppers(com.radixdlt.harness.simulation.NetworkDroppers) SimulationTest(com.radixdlt.harness.simulation.SimulationTest) SimulationTest(com.radixdlt.harness.simulation.SimulationTest) Test(org.junit.Test) SimulationTest(com.radixdlt.harness.simulation.SimulationTest)

Example 30 with SimulationTest

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

the class UniformLatencyTest method given_4_correct_bfts__then_should_pass_sanity_tests_over_1_minute.

/**
 * Sanity test check for a perfect network. 4 is the size used because it is the smallest network
 * size where quorum size (3) != network size. The sanity checks done are:
 *
 * <ol>
 *   <li>Committed vertices are the same across nodes
 *   <li>The size of vertex store does not increase for any node
 *   <li>A timeout never occurs for any node
 *   <li>Every proposal has a direct parent
 * </ol>
 */
@Test
public void given_4_correct_bfts__then_should_pass_sanity_tests_over_1_minute() {
    SimulationTest bftTest = SimulationTest.builder().networkModules(NetworkOrdering.inOrder(), NetworkLatencies.fixed()).numNodes(4).addTestModules(ConsensusMonitors.safety(), ConsensusMonitors.liveness(LIVENESS_MS, TimeUnit.MILLISECONDS), ConsensusMonitors.directParents()).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