use of com.radixdlt.ledger.VerifiedTxnsAndProof in project radixdlt by radixdlt.
the class MockedStateComputer method commit.
@Override
public void commit(VerifiedTxnsAndProof txnsAndProof, VerifiedVertexStoreState vertexStoreState) {
var output = txnsAndProof.getProof().getNextValidatorSet().map(validatorSet -> {
LedgerProof header = txnsAndProof.getProof();
UnverifiedVertex genesisVertex = UnverifiedVertex.createGenesis(header.getRaw());
VerifiedVertex verifiedGenesisVertex = new VerifiedVertex(genesisVertex, hasher.hash(genesisVertex));
LedgerHeader nextLedgerHeader = LedgerHeader.create(header.getEpoch() + 1, View.genesis(), header.getAccumulatorState(), header.timestamp());
QuorumCertificate genesisQC = QuorumCertificate.ofGenesis(verifiedGenesisVertex, nextLedgerHeader);
final var initialState = VerifiedVertexStoreState.create(HighQC.from(genesisQC), verifiedGenesisVertex, Optional.empty(), hasher);
var proposerElection = new WeightedRotatingLeaders(validatorSet);
var bftConfiguration = new BFTConfiguration(proposerElection, validatorSet, initialState);
return new EpochChange(header, bftConfiguration);
}).map(e -> ImmutableClassToInstanceMap.<Object, EpochChange>of(EpochChange.class, e)).orElse(ImmutableClassToInstanceMap.of());
var ledgerUpdate = new LedgerUpdate(txnsAndProof, output);
ledgerUpdateDispatcher.dispatch(ledgerUpdate);
}
use of com.radixdlt.ledger.VerifiedTxnsAndProof in project radixdlt by radixdlt.
the class RemoteSyncServiceTest method when_remote_sync_request__then_process_it.
@Test
public void when_remote_sync_request__then_process_it() {
SyncRequest request = mock(SyncRequest.class);
DtoLedgerProof header = mock(DtoLedgerProof.class);
when(header.getOpaque()).thenReturn(HashUtils.zero256());
when(header.getLedgerHeader()).thenReturn(mock(LedgerHeader.class));
when(header.getSignatures()).thenReturn(mock(TimestampedECDSASignatures.class));
when(request.getHeader()).thenReturn(header);
BFTNode node = mock(BFTNode.class);
VerifiedTxnsAndProof verifiedTxnsAndProof = mock(VerifiedTxnsAndProof.class);
LedgerProof verifiedHeader = mock(LedgerProof.class);
when(verifiedHeader.toDto()).thenReturn(header);
when(verifiedTxnsAndProof.getProof()).thenReturn(verifiedHeader);
when(reader.getNextCommittedTxns(any())).thenReturn(verifiedTxnsAndProof);
processor.syncRequestEventProcessor().process(node, SyncRequest.create(header));
verify(syncResponseDispatcher, times(1)).dispatch(eq(node), any());
}
Aggregations