use of com.radixdlt.utils.Pair in project radixdlt by radixdlt.
the class ConsensusModuleTest method on_sync_request_timeout_should_retry.
@Test
public void on_sync_request_timeout_should_retry() {
// Arrange
BFTNode bftNode = BFTNode.random();
QuorumCertificate parent = vertexStore.highQC().highestQC();
Pair<QuorumCertificate, VerifiedVertex> nextVertex = createNextVertex(parent, bftNode);
HighQC unsyncedHighQC = HighQC.from(nextVertex.getFirst(), nextVertex.getFirst(), Optional.empty());
bftSync.syncToQC(unsyncedHighQC, bftNode);
GetVerticesRequest request = new GetVerticesRequest(nextVertex.getSecond().getId(), 1);
VertexRequestTimeout timeout = VertexRequestTimeout.create(request);
// Act
// FIXME: Remove when rate limit on send removed
nothrowSleep(100);
bftSync.vertexRequestTimeoutEventProcessor().process(timeout);
// Assert
verify(requestSender, times(2)).dispatch(eq(bftNode), argThat(r -> r.getCount() == 1 && r.getVertexId().equals(nextVertex.getSecond().getId())));
}
use of com.radixdlt.utils.Pair in project radixdlt by radixdlt.
the class StateComputerLedgerTest method genesisIsEndOfEpoch.
public void genesisIsEndOfEpoch(boolean endOfEpoch) {
this.ledgerHeader = LedgerHeader.create(genesisEpoch, View.of(5), new AccumulatorState(genesisStateVersion, HashUtils.zero256()), 12345, endOfEpoch ? BFTValidatorSet.from(Stream.of(BFTValidator.from(BFTNode.random(), UInt256.ONE))) : null);
this.genesis = UnverifiedVertex.createGenesis(ledgerHeader);
this.genesisVertex = new VerifiedVertex(genesis, hasher.hash(genesis));
this.genesisQC = QuorumCertificate.ofGenesis(genesisVertex, ledgerHeader);
this.currentLedgerHeader = this.genesisQC.getCommittedAndLedgerStateProof(hasher).map(Pair::getSecond).orElseThrow();
this.sut = new StateComputerLedger(mock(TimeSupplier.class), currentLedgerHeader, headerComparator, stateComputer, accumulator, accumulatorVerifier, counters);
}
use of com.radixdlt.utils.Pair in project radixdlt by radixdlt.
the class ConsensusModuleTest method on_sync_request_timeout_should_retry.
@Test
public void on_sync_request_timeout_should_retry() {
// Arrange
QuorumCertificate parent = vertexStore.highQC().highestQC();
Pair<QuorumCertificate, VerifiedVertex> nextVertex = createNextVertex(parent, validatorKeyPair);
HighQC unsyncedHighQC = HighQC.from(nextVertex.getFirst(), nextVertex.getFirst(), Optional.empty());
bftSync.syncToQC(unsyncedHighQC, validatorBftNode);
GetVerticesRequest request = new GetVerticesRequest(nextVertex.getSecond().getId(), 1);
VertexRequestTimeout timeout = VertexRequestTimeout.create(request);
// Act
// FIXME: Remove when rate limit on send removed
nothrowSleep(100);
bftSync.vertexRequestTimeoutEventProcessor().process(timeout);
// Assert
verify(requestSender, times(2)).dispatch(eq(validatorBftNode), argThat(r -> r.getCount() == 1 && r.getVertexId().equals(nextVertex.getSecond().getId())));
}
use of com.radixdlt.utils.Pair in project radixdlt by radixdlt.
the class ConsensusModuleTest method on_synced_to_vertex_should_request_for_parent.
@Test
public void on_synced_to_vertex_should_request_for_parent() {
// Arrange
BFTNode bftNode = BFTNode.random();
QuorumCertificate parent = vertexStore.highQC().highestQC();
Pair<QuorumCertificate, VerifiedVertex> nextVertex = createNextVertex(parent, validatorKeyPair);
Pair<QuorumCertificate, VerifiedVertex> nextNextVertex = createNextVertex(nextVertex.getFirst(), validatorKeyPair);
HighQC unsyncedHighQC = HighQC.from(nextNextVertex.getFirst(), nextNextVertex.getFirst(), Optional.empty());
bftSync.syncToQC(unsyncedHighQC, bftNode);
// Act
// FIXME: Remove when rate limit on send removed
nothrowSleep(100);
GetVerticesResponse response = new GetVerticesResponse(ImmutableList.of(nextNextVertex.getSecond()));
bftSync.responseProcessor().process(bftNode, response);
// Assert
verify(requestSender, times(1)).dispatch(eq(bftNode), argThat(r -> r.getCount() == 1 && r.getVertexId().equals(nextVertex.getSecond().getId())));
}
use of com.radixdlt.utils.Pair in project radixdlt by radixdlt.
the class StateComputerLedgerTest method setup.
@Before
public void setup() {
this.mempool = TypedMocks.rmock(Mempool.class);
// No type check issues with mocking generic here
this.stateComputer = mock(StateComputer.class);
this.counters = mock(SystemCounters.class);
this.headerComparator = TypedMocks.rmock(Comparator.class);
this.accumulator = new SimpleLedgerAccumulatorAndVerifier(hasher);
this.accumulatorVerifier = new SimpleLedgerAccumulatorAndVerifier(hasher);
var accumulatorState = new AccumulatorState(0, HashUtils.zero256());
this.ledgerHeader = LedgerHeader.genesis(accumulatorState, null, 0);
this.genesis = UnverifiedVertex.createGenesis(ledgerHeader);
this.genesisVertex = new VerifiedVertex(genesis, hasher.hash(genesis));
this.genesisQC = QuorumCertificate.ofGenesis(genesisVertex, ledgerHeader);
this.currentLedgerHeader = this.genesisQC.getCommittedAndLedgerStateProof(hasher).map(Pair::getSecond).orElseThrow();
this.sut = new StateComputerLedger(mock(TimeSupplier.class), currentLedgerHeader, headerComparator, stateComputer, accumulator, accumulatorVerifier, counters);
}
Aggregations