Search in sources :

Example 1 with BlockBroadcaster

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);
}
Also used : InMemoryKeyValueStorage(org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage) Optional(java.util.Optional) SyncState(org.hyperledger.besu.ethereum.eth.sync.state.SyncState) TransactionPoolConfiguration(org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration) ImmutableTransactionPoolConfiguration(org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) BlockBroadcaster(org.hyperledger.besu.ethereum.eth.sync.BlockBroadcaster) MainnetBlockHeaderFunctions(org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions) KeyValueStoragePrefixedKeyBlockchainStorage(org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStoragePrefixedKeyBlockchainStorage) Before(org.junit.Before)

Aggregations

Optional (java.util.Optional)1 BlockBroadcaster (org.hyperledger.besu.ethereum.eth.sync.BlockBroadcaster)1 SyncState (org.hyperledger.besu.ethereum.eth.sync.state.SyncState)1 ImmutableTransactionPoolConfiguration (org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration)1 TransactionPoolConfiguration (org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration)1 MainnetBlockHeaderFunctions (org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions)1 KeyValueStoragePrefixedKeyBlockchainStorage (org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStoragePrefixedKeyBlockchainStorage)1 NoOpMetricsSystem (org.hyperledger.besu.metrics.noop.NoOpMetricsSystem)1 InMemoryKeyValueStorage (org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage)1 Before (org.junit.Before)1