use of com.radixdlt.environment.deterministic.network.MessageMutator 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.MessageMutator in project radixdlt by radixdlt.
the class DifferentTimestampsCauseTimeoutTest method when_four_nodes_receive_qcs_with_different_timestamps__quorum_is_not_achieved.
@Test
public void when_four_nodes_receive_qcs_with_different_timestamps__quorum_is_not_achieved() {
final int numNodes = 4;
// TODO: this test isn't exactly right and should be updated so that
// TODO: byzantine node sends different sets of valid QCs to each node
DeterministicManualExecutor executor = DeterministicTest.builder().overrideWithIncorrectModule(new AbstractModule() {
@Override
protected void configure() {
bind(HashVerifier.class).toInstance((pubKey, hash, sig) -> true);
bind(HashSigner.class).toInstance(h -> ECDSASignature.zeroSignature());
}
}).numNodes(numNodes).messageMutator(mutateProposalsBy(1)).buildWithoutEpochs().createExecutor();
executor.start();
executeTwoViews(executor);
// Timeouts from nodes
executor.processNext(0, 0, ScheduledLocalTimeout.class);
executor.processNext(1, 1, ScheduledLocalTimeout.class);
executor.processNext(2, 2, ScheduledLocalTimeout.class);
executor.processNext(3, 3, ScheduledLocalTimeout.class);
}
use of com.radixdlt.environment.deterministic.network.MessageMutator 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