use of org.hyperledger.besu.ethereum.eth.sync.BlockBroadcaster in project besu by hyperledger.
the class BesuEventsImplTest method setUp.
@Before
public void setUp() {
blockchain = DefaultBlockchain.createMutable(gen.genesisBlock(), new KeyValueStoragePrefixedKeyBlockchainStorage(new InMemoryKeyValueStorage(), new MainnetBlockHeaderFunctions()), new NoOpMetricsSystem(), 0);
when(mockEthContext.getEthMessages()).thenReturn(mockEthMessages);
when(mockEthContext.getEthPeers()).thenReturn(mockEthPeers);
when(mockEthContext.getScheduler()).thenReturn(mockEthScheduler);
when(mockEthPeers.streamAvailablePeers()).thenAnswer(z -> Stream.empty());
when(mockProtocolContext.getBlockchain()).thenReturn(blockchain);
when(mockProtocolContext.getWorldStateArchive()).thenReturn(mockWorldStateArchive);
when(mockProtocolSchedule.getByBlockNumber(anyLong())).thenReturn(mockProtocolSpec);
when(mockProtocolSpec.getTransactionValidator()).thenReturn(mockTransactionValidator);
when(mockProtocolSpec.getFeeMarket()).thenReturn(FeeMarket.london(0L));
when(mockTransactionValidator.validate(any(), any(Optional.class), any())).thenReturn(ValidationResult.valid());
when(mockTransactionValidator.validateForSender(any(), any(), any())).thenReturn(ValidationResult.valid());
when(mockWorldStateArchive.getMutable(any(), any(), anyBoolean())).thenReturn(Optional.of(mockWorldState));
blockBroadcaster = new BlockBroadcaster(mockEthContext);
syncState = new SyncState(blockchain, mockEthPeers);
TransactionPoolConfiguration txPoolConfig = ImmutableTransactionPoolConfiguration.builder().txPoolMaxSize(1).build();
transactionPool = TransactionPoolFactory.createTransactionPool(mockProtocolSchedule, mockProtocolContext, mockEthContext, TestClock.fixed(), new NoOpMetricsSystem(), syncState, new MiningParameters.Builder().minTransactionGasPrice(Wei.ZERO).build(), txPoolConfig);
serviceImpl = new BesuEventsImpl(blockchain, blockBroadcaster, transactionPool, syncState);
}
Aggregations