Search in sources :

Example 1 with DeterministicManualExecutor

use of com.radixdlt.harness.deterministic.DeterministicTest.DeterministicManualExecutor 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);
}
Also used : HashVerifier(com.radixdlt.hotstuff.HashVerifier) ControlledMessage(com.radixdlt.environment.deterministic.network.ControlledMessage) BFTInsertUpdate(com.radixdlt.hotstuff.bft.BFTInsertUpdate) ImmutableMap(com.google.common.collect.ImmutableMap) ScheduledLocalTimeout(com.radixdlt.hotstuff.liveness.ScheduledLocalTimeout) ECDSASignature(com.radixdlt.crypto.ECDSASignature) Vote(com.radixdlt.hotstuff.Vote) VoteData(com.radixdlt.hotstuff.VoteData) Test(org.junit.Test) ViewUpdate(com.radixdlt.hotstuff.bft.ViewUpdate) TimestampedECDSASignatures(com.radixdlt.hotstuff.TimestampedECDSASignatures) DeterministicTest(com.radixdlt.harness.deterministic.DeterministicTest) UnverifiedVertex(com.radixdlt.hotstuff.UnverifiedVertex) BFTNode(com.radixdlt.hotstuff.bft.BFTNode) HashSigner(com.radixdlt.hotstuff.HashSigner) QuorumCertificate(com.radixdlt.hotstuff.QuorumCertificate) TimestampedECDSASignature(com.radixdlt.hotstuff.TimestampedECDSASignature) DeterministicManualExecutor(com.radixdlt.harness.deterministic.DeterministicTest.DeterministicManualExecutor) Map(java.util.Map) Pair(com.radixdlt.utils.Pair) Optional(java.util.Optional) MessageMutator(com.radixdlt.environment.deterministic.network.MessageMutator) Proposal(com.radixdlt.hotstuff.Proposal) AbstractModule(com.google.inject.AbstractModule) DeterministicManualExecutor(com.radixdlt.harness.deterministic.DeterministicTest.DeterministicManualExecutor) AbstractModule(com.google.inject.AbstractModule) Test(org.junit.Test) DeterministicTest(com.radixdlt.harness.deterministic.DeterministicTest)

Example 2 with DeterministicManualExecutor

use of com.radixdlt.harness.deterministic.DeterministicTest.DeterministicManualExecutor in project radixdlt by radixdlt.

the class DifferentTimestampsCauseTimeoutTest method when_four_nodes_receive_qcs_with_same_timestamps__quorum_is_achieved.

@Test
public void when_four_nodes_receive_qcs_with_same_timestamps__quorum_is_achieved() {
    final int numNodes = 4;
    DeterministicManualExecutor executor = DeterministicTest.builder().numNodes(numNodes).messageMutator(mutateProposalsBy(0)).buildWithoutEpochs().createExecutor();
    executor.start();
    executeTwoViews(executor);
    executor.processNext(3, 3, ViewUpdate.class);
    executor.processNext(3, 3, Proposal.class);
    executor.processNext(3, 3, BFTInsertUpdate.class);
    executor.processNext(3, 0, Proposal.class);
    executor.processNext(0, 0, ViewUpdate.class);
    executor.processNext(0, 0, BFTInsertUpdate.class);
    executor.processNext(3, 1, Proposal.class);
    executor.processNext(1, 1, ViewUpdate.class);
    executor.processNext(1, 1, BFTInsertUpdate.class);
    executor.processNext(3, 2, Proposal.class);
    executor.processNext(2, 2, ViewUpdate.class);
    executor.processNext(2, 2, BFTInsertUpdate.class);
}
Also used : DeterministicManualExecutor(com.radixdlt.harness.deterministic.DeterministicTest.DeterministicManualExecutor) Test(org.junit.Test) DeterministicTest(com.radixdlt.harness.deterministic.DeterministicTest)

Aggregations

DeterministicTest (com.radixdlt.harness.deterministic.DeterministicTest)2 DeterministicManualExecutor (com.radixdlt.harness.deterministic.DeterministicTest.DeterministicManualExecutor)2 Test (org.junit.Test)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 AbstractModule (com.google.inject.AbstractModule)1 ECDSASignature (com.radixdlt.crypto.ECDSASignature)1 ControlledMessage (com.radixdlt.environment.deterministic.network.ControlledMessage)1 MessageMutator (com.radixdlt.environment.deterministic.network.MessageMutator)1 HashSigner (com.radixdlt.hotstuff.HashSigner)1 HashVerifier (com.radixdlt.hotstuff.HashVerifier)1 Proposal (com.radixdlt.hotstuff.Proposal)1 QuorumCertificate (com.radixdlt.hotstuff.QuorumCertificate)1 TimestampedECDSASignature (com.radixdlt.hotstuff.TimestampedECDSASignature)1 TimestampedECDSASignatures (com.radixdlt.hotstuff.TimestampedECDSASignatures)1 UnverifiedVertex (com.radixdlt.hotstuff.UnverifiedVertex)1 Vote (com.radixdlt.hotstuff.Vote)1 VoteData (com.radixdlt.hotstuff.VoteData)1 BFTInsertUpdate (com.radixdlt.hotstuff.bft.BFTInsertUpdate)1 BFTNode (com.radixdlt.hotstuff.bft.BFTNode)1 ViewUpdate (com.radixdlt.hotstuff.bft.ViewUpdate)1