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"));
}
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));
}
Aggregations