use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterRepository in project besu by hyperledger.
the class AbstractJsonRpcHttpServiceTest method getRpcMethods.
protected Map<String, JsonRpcMethod> getRpcMethods(final JsonRpcConfiguration config, final BlockchainSetupUtil blockchainSetupUtil) {
final ProtocolContext protocolContext = mock(ProtocolContext.class);
final Synchronizer synchronizerMock = mock(Synchronizer.class);
final P2PNetwork peerDiscoveryMock = mock(P2PNetwork.class);
final TransactionPool transactionPoolMock = mock(TransactionPool.class);
final PoWMiningCoordinator miningCoordinatorMock = mock(PoWMiningCoordinator.class);
when(transactionPoolMock.addLocalTransaction(any(Transaction.class))).thenReturn(ValidationResult.valid());
// nonce too low tests uses a tx with nonce=16
when(transactionPoolMock.addLocalTransaction(argThat(tx -> tx.getNonce() == 16))).thenReturn(ValidationResult.invalid(TransactionInvalidReason.NONCE_TOO_LOW));
final GasPricePendingTransactionsSorter pendingTransactionsMock = mock(GasPricePendingTransactionsSorter.class);
when(transactionPoolMock.getPendingTransactions()).thenReturn(pendingTransactionsMock);
final PrivacyParameters privacyParameters = mock(PrivacyParameters.class);
final BlockchainQueries blockchainQueries = new BlockchainQueries(blockchainSetupUtil.getBlockchain(), blockchainSetupUtil.getWorldArchive());
final FilterIdGenerator filterIdGenerator = mock(FilterIdGenerator.class);
final FilterRepository filterRepository = new FilterRepository();
when(filterIdGenerator.nextId()).thenReturn("0x1");
filterManager = new FilterManagerBuilder().blockchainQueries(blockchainQueries).transactionPool(transactionPoolMock).filterIdGenerator(filterIdGenerator).filterRepository(filterRepository).build();
final Set<Capability> supportedCapabilities = new HashSet<>();
supportedCapabilities.add(EthProtocol.ETH62);
supportedCapabilities.add(EthProtocol.ETH63);
final NatService natService = new NatService(Optional.empty());
return new JsonRpcMethodsFactory().methods(CLIENT_VERSION, NETWORK_ID, new StubGenesisConfigOptions(), peerDiscoveryMock, blockchainQueries, synchronizerMock, blockchainSetupUtil.getProtocolSchedule(), protocolContext, filterManager, transactionPoolMock, miningCoordinatorMock, new NoOpMetricsSystem(), supportedCapabilities, Optional.empty(), Optional.empty(), JSON_RPC_APIS, privacyParameters, config, mock(WebSocketConfiguration.class), mock(MetricsConfiguration.class), natService, new HashMap<>(), folder.getRoot().toPath(), mock(EthPeers.class));
}
Aggregations