use of org.hyperledger.besu.consensus.merge.MergeContext in project besu by hyperledger.
the class TransitionBesuControllerBuilder method createSynchronizer.
@Override
protected DefaultSynchronizer createSynchronizer(final ProtocolSchedule protocolSchedule, final WorldStateStorage worldStateStorage, final ProtocolContext protocolContext, final Optional<Pruner> maybePruner, final EthContext ethContext, final SyncState syncState, final EthProtocolManager ethProtocolManager, final PivotBlockSelector pivotBlockSelector) {
DefaultSynchronizer sync = super.createSynchronizer(protocolSchedule, worldStateStorage, protocolContext, maybePruner, ethContext, syncState, ethProtocolManager, pivotBlockSelector);
ConsensusContext cc = protocolContext.getConsensusContext(ConsensusContext.class);
if (cc instanceof MergeContext) {
protocolContext.getConsensusContext(MergeContext.class).addNewForkchoiceMessageListener(sync);
}
return sync;
}
use of org.hyperledger.besu.consensus.merge.MergeContext in project besu by hyperledger.
the class MergeBesuControllerBuilderTest method assertFinalizedBlockIsPresentWhenStored.
@Test
public void assertFinalizedBlockIsPresentWhenStored() {
final BlockHeader finalizedHeader = finalizedBlockHeader();
final Blockchain mockChain = mock(Blockchain.class);
when(mockChain.getFinalized()).thenReturn(Optional.of(finalizedHeader.getHash()));
when(mockChain.getBlockHeader(finalizedHeader.getHash())).thenReturn(Optional.of(finalizedHeader));
MergeContext mergeContext = besuControllerBuilder.createConsensusContext(mockChain, mock(WorldStateArchive.class), this.besuControllerBuilder.createProtocolSchedule());
assertThat(mergeContext).isNotNull();
assertThat(mergeContext.getFinalized().get()).isEqualTo(finalizedHeader);
}
use of org.hyperledger.besu.consensus.merge.MergeContext in project besu by hyperledger.
the class MergeBesuControllerBuilderTest method assertNoFinalizedBlockWhenNotStored.
@Test
public void assertNoFinalizedBlockWhenNotStored() {
Blockchain mockChain = mock(Blockchain.class);
when(mockChain.getFinalized()).thenReturn(Optional.empty());
MergeContext mergeContext = besuControllerBuilder.createConsensusContext(mockChain, mock(WorldStateArchive.class), this.besuControllerBuilder.createProtocolSchedule());
assertThat(mergeContext).isNotNull();
assertThat(mergeContext.getFinalized()).isEmpty();
}
Aggregations