Search in sources :

Example 1 with SimulationTest

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

the class RandomVoteAndViewTimeoutDropperTest method when_random_validators__then_sanity_checks_should_pass.

@Test
public void when_random_validators__then_sanity_checks_should_pass() {
    SimulationTest simulationTest = bftTestBuilder.build();
    final var runningTest = simulationTest.run(Duration.of(2, ChronoUnit.MINUTES));
    final var checkResults = runningTest.awaitCompletion();
    List<CounterType> counterTypes = List.of(CounterType.BFT_VERTEX_STORE_FORKS, CounterType.BFT_COMMITTED_VERTICES, CounterType.BFT_PACEMAKER_TIMEOUTS_SENT, CounterType.LEDGER_STATE_VERSION);
    Map<CounterType, LongSummaryStatistics> statistics = counterTypes.stream().collect(Collectors.toMap(counterType -> counterType, counterType -> runningTest.getNetwork().getSystemCounters().values().stream().mapToLong(s -> s.get(counterType)).summaryStatistics()));
    System.out.println("statistics:\n" + print(statistics.entrySet()));
    assertThat(checkResults).allSatisfy((name, error) -> AssertionsForClassTypes.assertThat(error).isNotPresent());
}
Also used : LongSummaryStatistics(java.util.LongSummaryStatistics) RadixEngineForksLatestOnlyModule(com.radixdlt.statecomputer.forks.RadixEngineForksLatestOnlyModule) AssertionsForClassTypes(org.assertj.core.api.AssertionsForClassTypes) NetworkDroppers(com.radixdlt.harness.simulation.NetworkDroppers) RERulesConfig(com.radixdlt.statecomputer.forks.RERulesConfig) Duration(java.time.Duration) Map(java.util.Map) AssertionsForInterfaceTypes.assertThat(org.assertj.core.api.AssertionsForInterfaceTypes.assertThat) ConsensusMonitors(com.radixdlt.harness.simulation.monitors.consensus.ConsensusMonitors) LongSummaryStatistics(java.util.LongSummaryStatistics) NetworkOrdering(com.radixdlt.harness.simulation.NetworkOrdering) NodeValidatorRandomRegistrator(com.radixdlt.harness.simulation.application.NodeValidatorRandomRegistrator) RadixEngineMonitors(com.radixdlt.harness.simulation.monitors.radix_engine.RadixEngineMonitors) Set(java.util.Set) Test(org.junit.Test) Collectors(java.util.stream.Collectors) ForksModule(com.radixdlt.statecomputer.forks.ForksModule) SimulationTest(com.radixdlt.harness.simulation.SimulationTest) TimeUnit(java.util.concurrent.TimeUnit) Builder(com.radixdlt.harness.simulation.SimulationTest.Builder) List(java.util.List) NetworkLatencies(com.radixdlt.harness.simulation.NetworkLatencies) ChronoUnit(java.time.temporal.ChronoUnit) MainnetForksModule(com.radixdlt.statecomputer.forks.modules.MainnetForksModule) LedgerMonitors(com.radixdlt.harness.simulation.monitors.ledger.LedgerMonitors) CounterType(com.radixdlt.counters.SystemCounters.CounterType) CounterType(com.radixdlt.counters.SystemCounters.CounterType) SimulationTest(com.radixdlt.harness.simulation.SimulationTest) Test(org.junit.Test) SimulationTest(com.radixdlt.harness.simulation.SimulationTest)

Example 2 with SimulationTest

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

the class MempoolSanityTest method when_submitting_items_to_mempool__then_they_should_get_executed.

@Test
public void when_submitting_items_to_mempool__then_they_should_get_executed() {
    SimulationTest simulationTest = bftTestBuilder.build();
    final var checkResults = simulationTest.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 3 with SimulationTest

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

the class ByzantineSyncTest method given_a_sometimes_byzantine_sync_layer_with_incorrect_accumulator_verifier__sanity_tests_should_not_pass.

@Test
public void given_a_sometimes_byzantine_sync_layer_with_incorrect_accumulator_verifier__sanity_tests_should_not_pass() {
    SimulationTest simulationTest = bftTestBuilder.addOverrideModuleToAllInitialNodes(new IncorrectAlwaysAcceptingAccumulatorVerifierModule()).build();
    final var runningTest = simulationTest.run();
    final var checkResults = runningTest.awaitCompletion();
    LongSummaryStatistics statistics = runningTest.getNetwork().getSystemCounters().values().stream().map(s -> s.get(CounterType.SYNC_VALID_RESPONSES_RECEIVED)).mapToLong(l -> l).summaryStatistics();
    logger.info("{}", statistics);
    assertThat(checkResults).hasEntrySatisfying(Monitor.LEDGER_IN_ORDER, error -> assertThat(error).isPresent());
}
Also used : LongSummaryStatistics(java.util.LongSummaryStatistics) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) IncorrectAlwaysAcceptingAccumulatorVerifierModule(com.radixdlt.ledger.IncorrectAlwaysAcceptingAccumulatorVerifierModule) NetworkDroppers(com.radixdlt.harness.simulation.NetworkDroppers) ConsensusMonitors(com.radixdlt.harness.simulation.monitors.consensus.ConsensusMonitors) SometimesByzantineCommittedReader(com.radixdlt.sync.SometimesByzantineCommittedReader) LongSummaryStatistics(java.util.LongSummaryStatistics) Monitor(com.radixdlt.harness.simulation.Monitor) ProvidesIntoSet(com.google.inject.multibindings.ProvidesIntoSet) EventProcessorOnDispatch(com.radixdlt.environment.EventProcessorOnDispatch) NetworkOrdering(com.radixdlt.harness.simulation.NetworkOrdering) Test(org.junit.Test) Scopes(com.google.inject.Scopes) SimulationTest(com.radixdlt.harness.simulation.SimulationTest) LedgerUpdate(com.radixdlt.ledger.LedgerUpdate) TimeUnit(java.util.concurrent.TimeUnit) Builder(com.radixdlt.harness.simulation.SimulationTest.Builder) NetworkLatencies(com.radixdlt.harness.simulation.NetworkLatencies) Logger(org.apache.logging.log4j.Logger) CommittedReader(com.radixdlt.sync.CommittedReader) SyncConfig(com.radixdlt.sync.SyncConfig) LedgerMonitors(com.radixdlt.harness.simulation.monitors.ledger.LedgerMonitors) CounterType(com.radixdlt.counters.SystemCounters.CounterType) LogManager(org.apache.logging.log4j.LogManager) AbstractModule(com.google.inject.AbstractModule) Singleton(com.google.inject.Singleton) SimulationTest(com.radixdlt.harness.simulation.SimulationTest) IncorrectAlwaysAcceptingAccumulatorVerifierModule(com.radixdlt.ledger.IncorrectAlwaysAcceptingAccumulatorVerifierModule) Test(org.junit.Test) SimulationTest(com.radixdlt.harness.simulation.SimulationTest)

Example 4 with SimulationTest

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

the class ByzantineSyncTest method given_a_sometimes_byzantine_sync_layer__sanity_tests_should_pass.

@Test
public void given_a_sometimes_byzantine_sync_layer__sanity_tests_should_pass() {
    SimulationTest simulationTest = bftTestBuilder.build();
    final var runningTest = simulationTest.run();
    final var results = runningTest.awaitCompletion();
    assertThat(results).allSatisfy((name, err) -> assertThat(err).isEmpty());
    LongSummaryStatistics statistics = runningTest.getNetwork().getSystemCounters().values().stream().map(s -> s.get(CounterType.SYNC_VALID_RESPONSES_RECEIVED)).mapToLong(l -> l).summaryStatistics();
    logger.info("{}", statistics);
    assertThat(statistics.getSum()).isGreaterThan(0L);
}
Also used : LongSummaryStatistics(java.util.LongSummaryStatistics) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) IncorrectAlwaysAcceptingAccumulatorVerifierModule(com.radixdlt.ledger.IncorrectAlwaysAcceptingAccumulatorVerifierModule) NetworkDroppers(com.radixdlt.harness.simulation.NetworkDroppers) ConsensusMonitors(com.radixdlt.harness.simulation.monitors.consensus.ConsensusMonitors) SometimesByzantineCommittedReader(com.radixdlt.sync.SometimesByzantineCommittedReader) LongSummaryStatistics(java.util.LongSummaryStatistics) Monitor(com.radixdlt.harness.simulation.Monitor) ProvidesIntoSet(com.google.inject.multibindings.ProvidesIntoSet) EventProcessorOnDispatch(com.radixdlt.environment.EventProcessorOnDispatch) NetworkOrdering(com.radixdlt.harness.simulation.NetworkOrdering) Test(org.junit.Test) Scopes(com.google.inject.Scopes) SimulationTest(com.radixdlt.harness.simulation.SimulationTest) LedgerUpdate(com.radixdlt.ledger.LedgerUpdate) TimeUnit(java.util.concurrent.TimeUnit) Builder(com.radixdlt.harness.simulation.SimulationTest.Builder) NetworkLatencies(com.radixdlt.harness.simulation.NetworkLatencies) Logger(org.apache.logging.log4j.Logger) CommittedReader(com.radixdlt.sync.CommittedReader) SyncConfig(com.radixdlt.sync.SyncConfig) LedgerMonitors(com.radixdlt.harness.simulation.monitors.ledger.LedgerMonitors) CounterType(com.radixdlt.counters.SystemCounters.CounterType) LogManager(org.apache.logging.log4j.LogManager) AbstractModule(com.google.inject.AbstractModule) Singleton(com.google.inject.Singleton) SimulationTest(com.radixdlt.harness.simulation.SimulationTest) Test(org.junit.Test) SimulationTest(com.radixdlt.harness.simulation.SimulationTest)

Example 5 with SimulationTest

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

the class FNodesNeverReceiveProposalDropperTest method sanity_tests_should_pass.

@Test
public void sanity_tests_should_pass() {
    SimulationTest simulationTest = bftTestBuilder.build();
    final var runningTest = simulationTest.run();
    final var checkResults = runningTest.awaitCompletion();
    assertThat(checkResults).allSatisfy((name, err) -> assertThat(err).isEmpty());
    LongSummaryStatistics statistics = runningTest.getNetwork().getSystemCounters().values().stream().map(s -> s.get(CounterType.SYNC_VALID_RESPONSES_RECEIVED)).mapToLong(l -> l).summaryStatistics();
    logger.info("{}", statistics);
    assertThat(statistics.getSum()).isGreaterThan(0L);
}
Also used : LongSummaryStatistics(java.util.LongSummaryStatistics) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Collection(java.util.Collection) NetworkOrdering(com.radixdlt.harness.simulation.NetworkOrdering) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) 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) List(java.util.List) NetworkLatencies(com.radixdlt.harness.simulation.NetworkLatencies) Logger(org.apache.logging.log4j.Logger) SyncConfig(com.radixdlt.sync.SyncConfig) LedgerMonitors(com.radixdlt.harness.simulation.monitors.ledger.LedgerMonitors) ConsensusMonitors(com.radixdlt.harness.simulation.monitors.consensus.ConsensusMonitors) CounterType(com.radixdlt.counters.SystemCounters.CounterType) LogManager(org.apache.logging.log4j.LogManager) LongSummaryStatistics(java.util.LongSummaryStatistics) Parameterized(org.junit.runners.Parameterized) 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