From 10d835fc96cd92875996c11e6b6db0e47bb302cd Mon Sep 17 00:00:00 2001 From: Adrian Sutton Date: Tue, 16 Apr 2019 09:00:46 +1000 Subject: [PATCH] Fix running ATs with in-process node runner (#1285) Supplies an EthereumWireProtocolConfiguration when creating PantheonController. --- .../dsl/node/ThreadPantheonNodeRunner.java | 2 ++ .../pantheon/cli/PantheonControllerBuilder.java | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java index 0afa7f6ea7..15614a71b4 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java @@ -20,6 +20,7 @@ import tech.pegasys.pantheon.cli.PantheonControllerBuilder; import tech.pegasys.pantheon.controller.KeyPairUtil; import tech.pegasys.pantheon.controller.PantheonController; +import tech.pegasys.pantheon.ethereum.eth.EthereumWireProtocolConfiguration; import tech.pegasys.pantheon.ethereum.eth.sync.SynchronizerConfiguration; import tech.pegasys.pantheon.ethereum.eth.transactions.PendingTransactions; import tech.pegasys.pantheon.metrics.MetricsSystem; @@ -76,6 +77,7 @@ public void startNode(final PantheonNode node) { .metricsSystem(noOpMetricsSystem) .maxPendingTransactions(PendingTransactions.MAX_PENDING_TRANSACTIONS) .rocksDbConfiguration(new RocksDbConfiguration.Builder().databaseDir(tempDir).build()) + .ethereumWireProtocolConfiguration(EthereumWireProtocolConfiguration.defaultConfig()) .build(); } catch (final IOException e) { throw new RuntimeException("Error building PantheonController", e); diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonControllerBuilder.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonControllerBuilder.java index 116492adac..8d4b84f885 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonControllerBuilder.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonControllerBuilder.java @@ -12,6 +12,7 @@ */ package tech.pegasys.pantheon.cli; +import static com.google.common.base.Preconditions.checkNotNull; import static tech.pegasys.pantheon.controller.KeyPairUtil.loadKeyPair; import tech.pegasys.pantheon.config.GenesisConfigFile; @@ -105,6 +106,16 @@ public PantheonControllerBuilder privacyParameters(final PrivacyParameters priva } public PantheonController build() throws IOException { + checkNotNull(nodePrivateKeyFile, "Missing node private key file"); + checkNotNull(synchronizerConfiguration, "Missing synchronizer configuration"); + checkNotNull(rocksDbConfiguration, "Missing rocksdb configuration"); + checkNotNull(homePath, "Missing home path"); + checkNotNull(ethNetworkConfig, "Missing Ethereum network config"); + checkNotNull(miningParameters, "Missing mining parameters"); + checkNotNull(metricsSystem, "Missing metrics system"); + checkNotNull(privacyParameters, "Missing privacy parameters"); + checkNotNull(ethereumWireProtocolConfiguration, "Missing Ethereum wire protocol config"); + // instantiate a controller with mainnet config if no genesis file is defined // otherwise use the indicated genesis file final KeyPair nodeKeys = loadKeyPair(nodePrivateKeyFile); @@ -120,7 +131,7 @@ public PantheonController build() throws IOException { final String genesisConfig = ethNetworkConfig.getGenesisConfig(); genesisConfigFile = GenesisConfigFile.fromConfig(genesisConfig); } - Clock clock = Clock.systemUTC(); + final Clock clock = Clock.systemUTC(); return PantheonController.fromConfig( genesisConfigFile, synchronizerConfiguration,