private static JsonRpcHttpService createJsonRpcHttpService(final JsonRpcConfiguration config) throws Exception { return new JsonRpcHttpService( vertx, folder.newFolder().toPath(), config, new NoOpMetricsSystem(), rpcMethods); }
private JsonRpcHttpService createJsonRpcHttpService() throws Exception { return new JsonRpcHttpService( vertx, folder.newFolder().toPath(), jsonRpcConfig, new NoOpMetricsSystem(), rpcMethods); }
private StorageProvider createKeyValueStorageProvider(final Path dbAhead) throws IOException { return RocksDbStorageProvider.create(dbAhead, new NoOpMetricsSystem()); }
private static JsonRpcHttpService createJsonRpcHttpService() throws Exception { return new JsonRpcHttpService( vertx, folder.newFolder().toPath(), createJsonRpcConfig(), new NoOpMetricsSystem(), rpcMethods); }
private DefaultMutableBlockchain createBlockchain( final KeyValueStorage kvStore, final Block genesisBlock) { return new DefaultMutableBlockchain( genesisBlock, new KeyValueStoragePrefixedKeyBlockchainStorage( kvStore, MainnetBlockHashFunction::createHash), new NoOpMetricsSystem()); } }
@Override protected KeyValueStorage createStore() throws Exception { return RocksDbKeyValueStorage.create(folder.newFolder().toPath(), new NoOpMetricsSystem()); } }
private JsonRpcHttpService createJsonRpcHttpServiceWithAllowedDomains( final String... corsAllowedDomains) throws Exception { final JsonRpcConfiguration config = JsonRpcConfiguration.createDefault(); config.setPort(0); if (corsAllowedDomains != null) { config.setCorsAllowedDomains(Lists.newArrayList(corsAllowedDomains)); } final JsonRpcHttpService jsonRpcHttpService = new JsonRpcHttpService( vertx, folder.newFolder().toPath(), config, new NoOpMetricsSystem(), new HashMap<>()); jsonRpcHttpService.start().join(); return jsonRpcHttpService; } }
private JsonRpcHttpService createJsonRpcHttpServiceWithRpcApis(final JsonRpcConfiguration config) throws Exception { final Set<Capability> supportedCapabilities = new HashSet<>(); supportedCapabilities.add(EthProtocol.ETH62); supportedCapabilities.add(EthProtocol.ETH63); final Map<String, JsonRpcMethod> rpcMethods = spy( new JsonRpcMethodsFactory() .methods( CLIENT_VERSION, mock(P2PNetwork.class), blockchainQueries, mock(Synchronizer.class), MainnetProtocolSchedule.create(), mock(FilterManager.class), mock(TransactionPool.class), mock(EthHashMiningCoordinator.class), new NoOpMetricsSystem(), supportedCapabilities, mock(AccountWhitelistController.class), config.getRpcApis(), mock(PrivateTransactionHandler.class))); final JsonRpcHttpService jsonRpcHttpService = new JsonRpcHttpService( vertx, folder.newFolder().toPath(), config, new NoOpMetricsSystem(), rpcMethods); jsonRpcHttpService.start().join(); baseUrl = jsonRpcHttpService.url(); return jsonRpcHttpService; }
mock(TransactionPool.class), mock(EthHashMiningCoordinator.class), new NoOpMetricsSystem(), supportedCapabilities, mock(AccountWhitelistController.class),
mock(TransactionPool.class), mock(EthHashMiningCoordinator.class), new NoOpMetricsSystem(), supportedCapabilities, mock(AccountWhitelistController.class),
@Test(expected = IllegalArgumentException.class) public void createPeerDiscoveryAgent_NullKeyPair() throws IOException { try (final P2PNetwork broken = new NettyP2PNetwork( vertx, null, configWithRandomPorts(), emptyList(), () -> true, new PeerBlacklist(), new NoOpMetricsSystem(), new NodeWhitelistController(PermissioningConfiguration.createDefault()))) { Assertions.fail("Expected Exception"); } }
@Test public void createPeerDiscoveryAgent_NoActivePeers() { final SECP256K1.KeyPair keyPair = SECP256K1.KeyPair.generate(); try (final NettyP2PNetwork agent = new NettyP2PNetwork( vertx, keyPair, configWithRandomPorts(), emptyList(), () -> true, new PeerBlacklist(), new NoOpMetricsSystem(), new NodeWhitelistController(PermissioningConfiguration.createDefault()))) { assertTrue(agent.getDiscoveryPeers().isEmpty()); assertEquals(0, agent.getPeers().size()); } } }
transactionPoolMock, miningCoordinatorMock, new NoOpMetricsSystem(), supportedCapabilities, accountWhitelistController, service = new JsonRpcHttpService( vertx, folder.newFolder().toPath(), config, new NoOpMetricsSystem(), methods); service.start().join();
new MiningParametersTestBuilder().enabled(false).build(), KeyPair.generate(), new NoOpMetricsSystem(), PrivacyParameters.noPrivacy()); final BlockImporter.ImportResult result = blockImporter.importBlockchain(source, controller);
@Test public void startDiscoveryAgentBackToBack() { final SECP256K1.KeyPair keyPair = SECP256K1.KeyPair.generate(); try (final NettyP2PNetwork service1 = new NettyP2PNetwork( vertx, keyPair, configWithRandomPorts(), emptyList(), () -> true, new PeerBlacklist(), new NoOpMetricsSystem(), new NodeWhitelistController(PermissioningConfiguration.createDefault())); final NettyP2PNetwork service2 = new NettyP2PNetwork( vertx, keyPair, configWithRandomPorts(), emptyList(), () -> true, new PeerBlacklist(), new NoOpMetricsSystem(), new NodeWhitelistController(PermissioningConfiguration.createDefault()))) { service1.run(); service1.stop(); service2.run(); service2.stop(); } }
@Test public void createPeerDiscoveryAgent() { final SECP256K1.KeyPair keyPair = SECP256K1.KeyPair.generate(); try (final NettyP2PNetwork service = new NettyP2PNetwork( vertx, keyPair, configWithRandomPorts(), emptyList(), () -> true, new PeerBlacklist(), new NoOpMetricsSystem(), new NodeWhitelistController(PermissioningConfiguration.createDefault()))) { service.run(); final int port = service.getDiscoverySocketAddress().getPort(); assertEquals( (NetworkUtility.isIPv6Available() ? "/0:0:0:0:0:0:0:0:" : "/0.0.0.0:") + port, service.getDiscoverySocketAddress().toString()); assertThat(service.getDiscoveryPeers()).hasSize(0); } }
@Test public void startStopPeerDiscoveryAgent() { final SECP256K1.KeyPair keyPair = SECP256K1.KeyPair.generate(); try (final NettyP2PNetwork service = new NettyP2PNetwork( vertx, keyPair, configWithRandomPorts(), emptyList(), () -> true, new PeerBlacklist(), new NoOpMetricsSystem(), new NodeWhitelistController(PermissioningConfiguration.createDefault()))) { service.run(); service.stop(); service.run(); } }
() -> true, new PeerBlacklist(), new NoOpMetricsSystem(), new NodeWhitelistController(PermissioningConfiguration.createDefault()))) { service1.run(); () -> true, new PeerBlacklist(), new NoOpMetricsSystem(), new NodeWhitelistController(PermissioningConfiguration.createDefault()))) { try {
@Test(expected = IllegalArgumentException.class) public void createPeerDiscoveryAgent_NullHost() throws IOException { final SECP256K1.KeyPair keyPair = SECP256K1.KeyPair.generate(); final NetworkingConfiguration config = NetworkingConfiguration.create() .setDiscovery(DiscoveryConfiguration.create().setBindHost(null)); try (final P2PNetwork broken = new NettyP2PNetwork( vertx, keyPair, config, emptyList(), () -> true, new PeerBlacklist(), new NoOpMetricsSystem(), new NodeWhitelistController(PermissioningConfiguration.createDefault()))) { Assertions.fail("Expected Exception"); } }
@Test public void blockImport() throws IOException { final Path source = folder.newFile().toPath(); BlockTestUtil.write1000Blocks(source); final PantheonController<?> targetController = PantheonController.fromConfig( GenesisConfigFile.mainnet(), SynchronizerConfiguration.builder().build(), new InMemoryStorageProvider(), false, 1, new MiningParametersTestBuilder().enabled(false).build(), KeyPair.generate(), new NoOpMetricsSystem(), PrivacyParameters.noPrivacy()); final BlockImporter.ImportResult result = blockImporter.importBlockchain(source, targetController); // Don't count the Genesis block assertThat(result.count).isEqualTo(999); assertThat(result.td).isEqualTo(UInt256.of(21991996248790L)); }