Search in sources :

Example 1 with MessageSelector

use of com.radixdlt.environment.deterministic.network.MessageSelector in project radixdlt by radixdlt.

the class RandomChannelOrderResponsiveTest method run.

private void run(int numNodes, long viewsToRun) {
    assertEquals(0, viewsToRun % numNodes);
    final Random random = new Random(12345);
    DeterministicTest test = DeterministicTest.builder().numNodes(numNodes).messageSelector(MessageSelector.randomSelector(random)).messageMutator(MessageMutator.dropTimeouts()).buildWithoutEpochs().runUntil(DeterministicTest.hasReachedView(View.of(viewsToRun)));
    List<Long> proposalsMade = IntStream.range(0, numNodes).mapToObj(test::getSystemCounters).map(counters -> counters.get(CounterType.BFT_PACEMAKER_PROPOSALS_SENT)).collect(ImmutableList.toImmutableList());
    final long numViews = viewsToRun / numNodes;
    assertThat(proposalsMade).hasSize(numNodes).areAtLeast(numNodes - 1, new Condition<>(l -> l == numViews, "has as many proposals as views")).areAtMost(1, new Condition<>(l -> l == numViews - 1, "has one less proposal"));
}
Also used : IntStream(java.util.stream.IntStream) Random(java.util.Random) Test(org.junit.Test) DeterministicTest(com.radixdlt.harness.deterministic.DeterministicTest) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) MessageSelector(com.radixdlt.environment.deterministic.network.MessageSelector) Condition(org.assertj.core.api.Condition) Assertions(org.assertj.core.api.Assertions) MessageMutator(com.radixdlt.environment.deterministic.network.MessageMutator) CounterType(com.radixdlt.counters.SystemCounters.CounterType) Assert.assertEquals(org.junit.Assert.assertEquals) View(com.radixdlt.consensus.bft.View) Condition(org.assertj.core.api.Condition) Random(java.util.Random) DeterministicTest(com.radixdlt.harness.deterministic.DeterministicTest)

Example 2 with MessageSelector

use of com.radixdlt.environment.deterministic.network.MessageSelector in project radixdlt by radixdlt.

the class MovingWindowValidatorsTest method run.

private void run(int numNodes, int windowSize, long maxEpoch, View highView) {
    DeterministicTest bftTest = DeterministicTest.builder().numNodes(numNodes).messageMutator(mutator()).messageSelector(firstSelector()).epochNodeIndexesMapping(windowedEpochToNodesMapper(windowSize, numNodes)).buildWithEpochs(highView).runUntil(DeterministicTest.hasReachedEpochView(EpochView.of(maxEpoch, highView)));
    LinkedList<SystemCounters> testCounters = systemCounters(bftTest);
    assertThat(testCounters).extracting(sc -> sc.get(CounterType.BFT_VERTEX_STORE_INDIRECT_PARENTS)).containsOnly(0L);
    assertThat(testCounters).extracting(sc -> sc.get(CounterType.BFT_PACEMAKER_TIMEOUTS_SENT)).containsOnly(0L);
    long maxCount = maxProcessedFor(numNodes, windowSize, maxEpoch, highView.number());
    assertThat(testCounters).extracting(sc -> sc.get(CounterType.BFT_COMMITTED_VERTICES)).allMatch(between(maxCount - maxEpoch, maxCount));
}
Also used : IntStream(java.util.stream.IntStream) ControlledMessage(com.radixdlt.environment.deterministic.network.ControlledMessage) ScheduledLocalTimeout(com.radixdlt.consensus.liveness.ScheduledLocalTimeout) SystemCounters(com.radixdlt.counters.SystemCounters) Epoched(com.radixdlt.consensus.epoch.Epoched) LongFunction(java.util.function.LongFunction) Predicate(java.util.function.Predicate) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.junit.Test) Collectors(java.util.stream.Collectors) DeterministicTest(com.radixdlt.harness.deterministic.DeterministicTest) EpochView(com.radixdlt.consensus.epoch.EpochView) MessageSelector(com.radixdlt.environment.deterministic.network.MessageSelector) MessageMutator(com.radixdlt.environment.deterministic.network.MessageMutator) ChannelId(com.radixdlt.environment.deterministic.network.ChannelId) LinkedList(java.util.LinkedList) CounterType(com.radixdlt.counters.SystemCounters.CounterType) View(com.radixdlt.consensus.bft.View) DeterministicTest(com.radixdlt.harness.deterministic.DeterministicTest) SystemCounters(com.radixdlt.counters.SystemCounters)

Aggregations

View (com.radixdlt.consensus.bft.View)2 CounterType (com.radixdlt.counters.SystemCounters.CounterType)2 MessageMutator (com.radixdlt.environment.deterministic.network.MessageMutator)2 MessageSelector (com.radixdlt.environment.deterministic.network.MessageSelector)2 DeterministicTest (com.radixdlt.harness.deterministic.DeterministicTest)2 IntStream (java.util.stream.IntStream)2 Test (org.junit.Test)2 ImmutableList (com.google.common.collect.ImmutableList)1 EpochView (com.radixdlt.consensus.epoch.EpochView)1 Epoched (com.radixdlt.consensus.epoch.Epoched)1 ScheduledLocalTimeout (com.radixdlt.consensus.liveness.ScheduledLocalTimeout)1 SystemCounters (com.radixdlt.counters.SystemCounters)1 ChannelId (com.radixdlt.environment.deterministic.network.ChannelId)1 ControlledMessage (com.radixdlt.environment.deterministic.network.ControlledMessage)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Random (java.util.Random)1 LongFunction (java.util.function.LongFunction)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1