From 7de1eaa52f48ac8a38c68b2ce72b082ad196fdf8 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Wed, 16 Jan 2019 12:07:04 +1000 Subject: [PATCH 01/13] typo --- .../pegasys/pantheon/ethereum/p2p/netty/NettyP2PNetwork.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/netty/NettyP2PNetwork.java b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/netty/NettyP2PNetwork.java index 95f5f36c35..0afe87e6ce 100644 --- a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/netty/NettyP2PNetwork.java +++ b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/netty/NettyP2PNetwork.java @@ -83,7 +83,7 @@ * distance from us is equal to the index of the bucket. The value x in the distance function * corresponds to our node ID (public key). * - *

Upper layers in the stack subscribe to events from the peer discocvery layer and initiate/drop + *

Upper layers in the stack subscribe to events from the peer discovery layer and initiate/drop * connections accordingly. * *

RLPx Wire Protocol

From 0e75ceff40ceb38824700321668eeb1255b6856d Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Wed, 16 Jan 2019 14:39:57 +1000 Subject: [PATCH 02/13] added test and DSL for node with --no-iscovery --- .../ClusterNoDiscoveryAcceptanceTest.java | 40 +++++++++++++++++++ .../acceptance/dsl/node/PantheonNode.java | 9 ++++- .../dsl/node/ProcessPantheonNodeRunner.java | 4 ++ .../factory/PantheonFactoryConfiguration.java | 9 ++++- .../PantheonFactoryConfigurationBuilder.java | 9 ++++- .../dsl/node/factory/PantheonNodeFactory.java | 7 +++- 6 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java new file mode 100644 index 0000000000..0b26641ecd --- /dev/null +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java @@ -0,0 +1,40 @@ +/* + * Copyright 2018 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package tech.pegasys.pantheon.tests.acceptance; + +import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; + +import org.junit.Before; +import org.junit.Test; + +public class ClusterNoDiscoveryAcceptanceTest extends AcceptanceTestBase { + + private Node fullNode; + private Node noDiscoveryNode; + + @Before + public void setUp() throws Exception { + noDiscoveryNode = pantheon.createNodeWithNoDiscovery("noDiscovery"); + fullNode = pantheon.createArchiveNode("node2"); + cluster.start(noDiscoveryNode, fullNode); + } + + @Test + public void shouldConnectToOtherPeer() { + // this doesn't work because we can't connect to the noDiscoveryNode + // anyway I think it would be 1 because of the bootnodes + // noDiscoveryNode.verify(net.awaitPeerCount(0)); + fullNode.verify(net.awaitPeerCount(1)); + } +} diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java index adcb466f4d..648d8e4e0d 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java @@ -74,6 +74,7 @@ public class PantheonNode implements Node, NodeConfiguration, RunnableNode, Auto private final PermissioningConfiguration permissioningConfiguration; private final GenesisConfigProvider genesisConfigProvider; private final boolean devMode; + private final boolean noDiscovery; private List bootnodes = new ArrayList<>(); private PantheonWeb3j pantheonWeb3j; @@ -88,7 +89,8 @@ public PantheonNode( final PermissioningConfiguration permissioningConfiguration, final boolean devMode, final GenesisConfigProvider genesisConfigProvider, - final int p2pPort) + final int p2pPort, + final boolean noDiscovery) throws IOException { this.homeDirectory = Files.createTempDirectory("acctest"); this.keyPair = KeyPairUtil.loadKeyPair(homeDirectory); @@ -101,6 +103,7 @@ public PantheonNode( this.permissioningConfiguration = permissioningConfiguration; this.genesisConfigProvider = genesisConfigProvider; this.devMode = devMode; + this.noDiscovery = noDiscovery; LOG.info("Created PantheonNode {}", this.toString()); } @@ -326,6 +329,10 @@ public boolean isDevMode() { return devMode; } + public boolean isNoDiscovery() { + return noDiscovery; + } + PermissioningConfiguration getPermissioningConfiguration() { return permissioningConfiguration; } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java index eb04b3d7db..10f7bf41eb 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java @@ -58,6 +58,10 @@ public void startNode(final PantheonNode node) { params.add("--dev-mode"); } + if (node.isNoDiscovery()) { + params.add("--no-discovery"); + } + params.add("--p2p-listen"); params.add(node.p2pListenAddress()); diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfiguration.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfiguration.java index f9ce4d2af2..97b66dbcf4 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfiguration.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfiguration.java @@ -28,6 +28,7 @@ class PantheonFactoryConfiguration { private final MetricsConfiguration metricsConfiguration; private final PermissioningConfiguration permissioningConfiguration; private final boolean devMode; + private final boolean noDiscovery; private final GenesisConfigProvider genesisConfigProvider; PantheonFactoryConfiguration( @@ -38,7 +39,8 @@ class PantheonFactoryConfiguration { final MetricsConfiguration metricsConfiguration, final PermissioningConfiguration permissioningConfiguration, final boolean devMode, - final GenesisConfigProvider genesisConfigProvider) { + final GenesisConfigProvider genesisConfigProvider, + final boolean noDiscovery) { this.name = name; this.miningParameters = miningParameters; this.jsonRpcConfiguration = jsonRpcConfiguration; @@ -47,6 +49,7 @@ class PantheonFactoryConfiguration { this.permissioningConfiguration = permissioningConfiguration; this.devMode = devMode; this.genesisConfigProvider = genesisConfigProvider; + this.noDiscovery = noDiscovery; } public String getName() { @@ -77,6 +80,10 @@ public boolean isDevMode() { return devMode; } + public boolean isNoDiscovery() { + return noDiscovery; + } + public GenesisConfigProvider getGenesisConfigProvider() { return genesisConfigProvider; } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfigurationBuilder.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfigurationBuilder.java index 470598c6bc..38e4cb0677 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfigurationBuilder.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfigurationBuilder.java @@ -35,6 +35,7 @@ public class PantheonFactoryConfigurationBuilder { private PermissioningConfiguration permissioningConfiguration = PermissioningConfiguration.createDefault(); private boolean devMode = true; + private boolean noDiscovery = false; private GenesisConfigProvider genesisConfigProvider = ignore -> Optional.empty(); public PantheonFactoryConfigurationBuilder setName(final String name) { @@ -107,6 +108,11 @@ public PantheonFactoryConfigurationBuilder setGenesisConfigProvider( return this; } + public PantheonFactoryConfigurationBuilder setNoDiscovery() { + this.noDiscovery = true; + return this; + } + public PantheonFactoryConfiguration build() { return new PantheonFactoryConfiguration( name, @@ -116,6 +122,7 @@ public PantheonFactoryConfiguration build() { metricsConfiguration, permissioningConfiguration, devMode, - genesisConfigProvider); + genesisConfigProvider, + noDiscovery); } } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonNodeFactory.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonNodeFactory.java index 05365db596..87eb955074 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonNodeFactory.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonNodeFactory.java @@ -57,7 +57,8 @@ private PantheonNode create(final PantheonFactoryConfiguration config) throws IO config.getPermissioningConfiguration(), config.isDevMode(), config.getGenesisConfigProvider(), - serverSocket.getLocalPort()); + serverSocket.getLocalPort(), + config.isNoDiscovery()); serverSocket.close(); return node; @@ -179,6 +180,10 @@ public PantheonNode createNodeWithNodesWhitelistAndPermRPC( .build()); } + public PantheonNode createNodeWithNoDiscovery(final String name) throws IOException { + return create(new PantheonFactoryConfigurationBuilder().setName(name).setNoDiscovery().build()); + } + public PantheonNode createCliqueNode(final String name) throws IOException { return create( new PantheonFactoryConfigurationBuilder() From 5733073cc232441ad7117badd9678ecf751cd993 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Wed, 16 Jan 2019 15:06:44 +1000 Subject: [PATCH 03/13] pass discovery flag through --- .../tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java | 2 +- 1 file changed, 1 insertion(+), 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 12113c2c6a..84f34d6c82 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 @@ -77,7 +77,7 @@ public void startNode(final PantheonNode node) { new RunnerBuilder() .vertx(Vertx.vertx()) .pantheonController(pantheonController) - .discovery(true) + .discovery(!node.isNoDiscovery()) .bootstrapPeers(node.bootnodes()) .discoveryHost(node.hostName()) .discoveryPort(node.p2pPort()) From 43e58705a16716d245e8ba0b75c6c47dee23cf90 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Thu, 17 Jan 2019 13:27:38 +1000 Subject: [PATCH 04/13] updated link --- .../tech/pegasys/pantheon/ethereum/p2p/wire/Capability.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/wire/Capability.java b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/wire/Capability.java index 3e67caba35..198d2d78df 100644 --- a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/wire/Capability.java +++ b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/wire/Capability.java @@ -25,7 +25,7 @@ * Represents a client capability. * * @see Capability wire + * "https://github.com/ethereum/devp2p/blob/master/devp2p.md">Capability wire * format */ public class Capability { From c999a69f376eafbabef2c286c3c86e76d22187ff Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Thu, 17 Jan 2019 13:28:05 +1000 Subject: [PATCH 05/13] removed comments --- .../tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java index 0b26641ecd..1e7a2666a7 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java @@ -33,8 +33,7 @@ public void setUp() throws Exception { @Test public void shouldConnectToOtherPeer() { // this doesn't work because we can't connect to the noDiscoveryNode - // anyway I think it would be 1 because of the bootnodes - // noDiscoveryNode.verify(net.awaitPeerCount(0)); + // noDiscoveryNode.verify(net.awaitPeerCount(1)); fullNode.verify(net.awaitPeerCount(1)); } } From 5ad861e19106d0e21f6d9b46b3321c3cde1c1eda Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Tue, 22 Jan 2019 11:04:50 +1000 Subject: [PATCH 06/13] zero nodes --- .../tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java index 1e7a2666a7..f24f78227b 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java @@ -32,8 +32,6 @@ public void setUp() throws Exception { @Test public void shouldConnectToOtherPeer() { - // this doesn't work because we can't connect to the noDiscoveryNode - // noDiscoveryNode.verify(net.awaitPeerCount(1)); - fullNode.verify(net.awaitPeerCount(1)); + fullNode.verify(net.awaitPeerCount(0)); } } From 8600c425d3631e1be3445181ccb5e2bb9057d0d2 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Tue, 22 Jan 2019 11:05:08 +1000 Subject: [PATCH 07/13] update link --- .../tech/pegasys/pantheon/ethereum/p2p/wire/Capability.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/wire/Capability.java b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/wire/Capability.java index 198d2d78df..baa627b6db 100644 --- a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/wire/Capability.java +++ b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/wire/Capability.java @@ -24,8 +24,7 @@ /** * Represents a client capability. * - * @see Capability wire + * @see Capability wire * format */ public class Capability { From 0c247ddceb04fa6bf52abd0fb1bd0e67c029a440 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Tue, 22 Jan 2019 11:30:39 +1000 Subject: [PATCH 08/13] don't await discovery --- .../acceptance/ClusterNoDiscoveryAcceptanceTest.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java index f24f78227b..458c7288ef 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java @@ -14,6 +14,9 @@ import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase; import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.cluster.Cluster; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.cluster.ClusterConfiguration; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.cluster.ClusterConfigurationBuilder; import org.junit.Before; import org.junit.Test; @@ -22,12 +25,16 @@ public class ClusterNoDiscoveryAcceptanceTest extends AcceptanceTestBase { private Node fullNode; private Node noDiscoveryNode; + private Cluster noDiscoveryCluster; @Before public void setUp() throws Exception { + final ClusterConfiguration clusterConfiguration = + new ClusterConfigurationBuilder().setAwaitPeerDiscovery(false).build(); + noDiscoveryCluster = new Cluster(clusterConfiguration, net); noDiscoveryNode = pantheon.createNodeWithNoDiscovery("noDiscovery"); fullNode = pantheon.createArchiveNode("node2"); - cluster.start(noDiscoveryNode, fullNode); + noDiscoveryCluster.start(noDiscoveryNode, fullNode); } @Test From f4c4eb9ef60b2337855a738801c35d769d1ef395 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Tue, 22 Jan 2019 11:40:58 +1000 Subject: [PATCH 09/13] tear down --- .../tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java index 458c7288ef..1f16a77d96 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java @@ -41,4 +41,10 @@ public void setUp() throws Exception { public void shouldConnectToOtherPeer() { fullNode.verify(net.awaitPeerCount(0)); } + + @Override + public void tearDownAcceptanceTestBase() { + noDiscoveryCluster.stop(); + super.tearDownAcceptanceTestBase(); + } } From 6b6aca12cc4aa02623cf73da7e2345acc62b32ee Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Wed, 23 Jan 2019 09:53:48 +1000 Subject: [PATCH 10/13] changed test name --- .../tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java index 1f16a77d96..11fbf391df 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterNoDiscoveryAcceptanceTest.java @@ -38,7 +38,7 @@ public void setUp() throws Exception { } @Test - public void shouldConnectToOtherPeer() { + public void shouldNotConnectToOtherPeer() { fullNode.verify(net.awaitPeerCount(0)); } From ccfe30fca0d5439d3f59552e74cb3de69bc7f919 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Wed, 23 Jan 2019 10:50:45 +1000 Subject: [PATCH 11/13] reversed boolean for discovery --- .../tests/acceptance/dsl/node/PantheonNode.java | 11 ++++++----- .../dsl/node/ProcessPantheonNodeRunner.java | 2 +- .../acceptance/dsl/node/ThreadPantheonNodeRunner.java | 2 +- .../node/factory/PantheonFactoryConfiguration.java | 10 +++++----- .../factory/PantheonFactoryConfigurationBuilder.java | 8 ++++---- .../dsl/node/factory/PantheonNodeFactory.java | 5 +++-- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java index 6a508e6fe9..9cd621ad7e 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java @@ -75,7 +75,7 @@ public class PantheonNode implements Node, NodeConfiguration, RunnableNode, Auto private final PermissioningConfiguration permissioningConfiguration; private final GenesisConfigProvider genesisConfigProvider; private final boolean devMode; - private final boolean noDiscovery; + private final boolean discovery; private List bootnodes = new ArrayList<>(); private PantheonWeb3j pantheonWeb3j; @@ -92,7 +92,7 @@ public PantheonNode( final GenesisConfigProvider genesisConfigProvider, final int p2pPort, final Boolean p2pEnabled, - final boolean noDiscovery) + final boolean discovery) throws IOException { this.homeDirectory = Files.createTempDirectory("acctest"); this.keyPair = KeyPairUtil.loadKeyPair(homeDirectory); @@ -106,7 +106,7 @@ public PantheonNode( this.genesisConfigProvider = genesisConfigProvider; this.devMode = devMode; this.p2pEnabled = p2pEnabled; - this.noDiscovery = noDiscovery; + this.discovery = discovery; LOG.info("Created PantheonNode {}", this.toString()); } @@ -336,8 +336,8 @@ public boolean isDevMode() { return devMode; } - public boolean isNoDiscovery() { - return noDiscovery; + public boolean isDiscovery() { + return discovery; } PermissioningConfiguration getPermissioningConfiguration() { @@ -352,6 +352,7 @@ public String toString() { .add("homeDirectory", homeDirectory) .add("keyPair", keyPair) .add("p2pEnabled", p2pEnabled) + .add("discovery", discovery) .toString(); } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java index 10f7bf41eb..241349c6a2 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java @@ -58,7 +58,7 @@ public void startNode(final PantheonNode node) { params.add("--dev-mode"); } - if (node.isNoDiscovery()) { + if (!node.isDiscovery()) { params.add("--no-discovery"); } 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 f152d0a0b1..9120496963 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 @@ -77,7 +77,7 @@ public void startNode(final PantheonNode node) { new RunnerBuilder() .vertx(Vertx.vertx()) .pantheonController(pantheonController) - .discovery(!node.isNoDiscovery()) + .discovery(node.isDiscovery()) .bootstrapPeers(node.bootnodes()) .discoveryHost(node.hostName()) .discoveryPort(node.p2pPort()) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfiguration.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfiguration.java index 1aea8f5940..d10f55208a 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfiguration.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfiguration.java @@ -28,7 +28,7 @@ class PantheonFactoryConfiguration { private final MetricsConfiguration metricsConfiguration; private final PermissioningConfiguration permissioningConfiguration; private final boolean devMode; - private final boolean noDiscovery; + private final boolean discovery; private final GenesisConfigProvider genesisConfigProvider; private final Boolean p2pEnabled; @@ -42,7 +42,7 @@ class PantheonFactoryConfiguration { final boolean devMode, final GenesisConfigProvider genesisConfigProvider, final Boolean p2pEnabled, - final boolean noDiscovery) { + final boolean discovery) { this.name = name; this.miningParameters = miningParameters; this.jsonRpcConfiguration = jsonRpcConfiguration; @@ -52,7 +52,7 @@ class PantheonFactoryConfiguration { this.devMode = devMode; this.genesisConfigProvider = genesisConfigProvider; this.p2pEnabled = p2pEnabled; - this.noDiscovery = noDiscovery; + this.discovery = discovery; } public String getName() { @@ -83,8 +83,8 @@ public boolean isDevMode() { return devMode; } - public boolean isNoDiscovery() { - return noDiscovery; + public boolean isDiscovery() { + return discovery; } public GenesisConfigProvider getGenesisConfigProvider() { diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfigurationBuilder.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfigurationBuilder.java index 96742b59ab..360aab0ca5 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfigurationBuilder.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfigurationBuilder.java @@ -35,7 +35,7 @@ public class PantheonFactoryConfigurationBuilder { private PermissioningConfiguration permissioningConfiguration = PermissioningConfiguration.createDefault(); private boolean devMode = true; - private boolean noDiscovery = false; + private boolean discovery = true; private GenesisConfigProvider genesisConfigProvider = ignore -> Optional.empty(); private Boolean p2pEnabled = true; @@ -109,8 +109,8 @@ public PantheonFactoryConfigurationBuilder setGenesisConfigProvider( return this; } - public PantheonFactoryConfigurationBuilder setNoDiscovery() { - this.noDiscovery = true; + public PantheonFactoryConfigurationBuilder setDiscovery(final boolean discovery) { + this.discovery = discovery; return this; } @@ -130,6 +130,6 @@ public PantheonFactoryConfiguration build() { devMode, genesisConfigProvider, p2pEnabled, - noDiscovery); + discovery); } } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonNodeFactory.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonNodeFactory.java index 4beb9927b9..079b3c3eab 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonNodeFactory.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonNodeFactory.java @@ -59,7 +59,7 @@ private PantheonNode create(final PantheonFactoryConfiguration config) throws IO config.getGenesisConfigProvider(), serverSocket.getLocalPort(), config.getP2pEnabled(), - config.isNoDiscovery()); + config.isDiscovery()); serverSocket.close(); return node; @@ -192,7 +192,8 @@ public PantheonNode createNodeWithNodesWhitelistAndPermRPC( } public PantheonNode createNodeWithNoDiscovery(final String name) throws IOException { - return create(new PantheonFactoryConfigurationBuilder().setName(name).setNoDiscovery().build()); + return create( + new PantheonFactoryConfigurationBuilder().setName(name).setDiscovery(false).build()); } public PantheonNode createCliqueNode(final String name) throws IOException { From e19925cf934c22675e1c5233f3167b0016150bdc Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Wed, 23 Jan 2019 12:13:28 +1000 Subject: [PATCH 12/13] changed to Boolean and arity = 1 --- .../dsl/node/ProcessPantheonNodeRunner.java | 1 + .../factory/PantheonFactoryConfiguration.java | 4 ++-- .../PantheonFactoryConfigurationBuilder.java | 4 ++-- .../pegasys/pantheon/cli/PantheonCommand.java | 3 ++- .../pantheon/cli/PantheonCommandTest.java | 16 ++++++++++++---- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java index 241349c6a2..00313fa7bc 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java @@ -60,6 +60,7 @@ public void startNode(final PantheonNode node) { if (!node.isDiscovery()) { params.add("--no-discovery"); + params.add("true"); } params.add("--p2p-listen"); diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfiguration.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfiguration.java index d10f55208a..730c6cc7da 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfiguration.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfiguration.java @@ -28,7 +28,7 @@ class PantheonFactoryConfiguration { private final MetricsConfiguration metricsConfiguration; private final PermissioningConfiguration permissioningConfiguration; private final boolean devMode; - private final boolean discovery; + private final Boolean discovery; private final GenesisConfigProvider genesisConfigProvider; private final Boolean p2pEnabled; @@ -83,7 +83,7 @@ public boolean isDevMode() { return devMode; } - public boolean isDiscovery() { + public Boolean isDiscovery() { return discovery; } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfigurationBuilder.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfigurationBuilder.java index 360aab0ca5..a166a34632 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfigurationBuilder.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfigurationBuilder.java @@ -35,7 +35,7 @@ public class PantheonFactoryConfigurationBuilder { private PermissioningConfiguration permissioningConfiguration = PermissioningConfiguration.createDefault(); private boolean devMode = true; - private boolean discovery = true; + private Boolean discovery = true; private GenesisConfigProvider genesisConfigProvider = ignore -> Optional.empty(); private Boolean p2pEnabled = true; @@ -109,7 +109,7 @@ public PantheonFactoryConfigurationBuilder setGenesisConfigProvider( return this; } - public PantheonFactoryConfigurationBuilder setDiscovery(final boolean discovery) { + public PantheonFactoryConfigurationBuilder setDiscovery(final Boolean discovery) { this.discovery = discovery; return this; } diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java index e48ecad7be..84c56f877c 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java @@ -166,7 +166,8 @@ public static class RpcApisConversionException extends Exception { // meaning that it's probably the right way to handle disabling options. @Option( names = {"--no-discovery"}, - description = "Disable p2p peer discovery (default: ${DEFAULT-VALUE})" + description = "Disable p2p peer discovery (default: ${DEFAULT-VALUE})", + arity = "1" ) private final Boolean noPeerDiscovery = false; diff --git a/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java b/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java index 0b46af7481..ea7170d122 100644 --- a/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java +++ b/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java @@ -523,17 +523,25 @@ public void p2pEnabledOptionFalseValueCannotAlsoHaveBootnodesSpecified() { } @Test - public void discoveryOptionMustBeUsed() { - parseCommand("--no-discovery"); + public void discoveryOptionValueTrueMustBeUsed() { + parseCommand("--no-discovery", "true"); // Discovery stored in runner is the negative of the option passed to CLI - // So as passing the option means noDiscovery will be true, then discovery is false in runner - verify(mockRunnerBuilder.discovery(eq(false))).build(); assertThat(commandOutput.toString()).isEmpty(); assertThat(commandErrorOutput.toString()).isEmpty(); } + @Test + public void discoveryOptionValueFalseMustBeUsed() { + parseCommand("--no-discovery", "false"); + // Discovery stored in runner is the negative of the option passed to CLI + verify(mockRunnerBuilder.discovery(eq(true))).build(); + + assertThat(commandOutput.toString()).isEmpty(); + assertThat(commandErrorOutput.toString()).isEmpty(); + } + @Ignore("NC-2015 - Temporarily enabling zero-arg --bootnodes to permit 'bootnode' configuration") @Test public void callingWithBootnodesOptionButNoValueMustDisplayErrorAndUsage() { From 784fdc4b79165e496cf6e8e1c5b51c18700e042a Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Wed, 23 Jan 2019 13:10:32 +1000 Subject: [PATCH 13/13] discovery -> discoveryEnabled --- .../tests/acceptance/dsl/node/PantheonNode.java | 10 +++++----- .../acceptance/dsl/node/ProcessPantheonNodeRunner.java | 2 +- .../acceptance/dsl/node/ThreadPantheonNodeRunner.java | 2 +- .../dsl/node/factory/PantheonFactoryConfiguration.java | 10 +++++----- .../factory/PantheonFactoryConfigurationBuilder.java | 8 ++++---- .../dsl/node/factory/PantheonNodeFactory.java | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java index 9cd621ad7e..7091374bd4 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/PantheonNode.java @@ -75,7 +75,7 @@ public class PantheonNode implements Node, NodeConfiguration, RunnableNode, Auto private final PermissioningConfiguration permissioningConfiguration; private final GenesisConfigProvider genesisConfigProvider; private final boolean devMode; - private final boolean discovery; + private final boolean discoveryEnabled; private List bootnodes = new ArrayList<>(); private PantheonWeb3j pantheonWeb3j; @@ -106,7 +106,7 @@ public PantheonNode( this.genesisConfigProvider = genesisConfigProvider; this.devMode = devMode; this.p2pEnabled = p2pEnabled; - this.discovery = discovery; + this.discoveryEnabled = discovery; LOG.info("Created PantheonNode {}", this.toString()); } @@ -336,8 +336,8 @@ public boolean isDevMode() { return devMode; } - public boolean isDiscovery() { - return discovery; + public boolean isDiscoveryEnabled() { + return discoveryEnabled; } PermissioningConfiguration getPermissioningConfiguration() { @@ -352,7 +352,7 @@ public String toString() { .add("homeDirectory", homeDirectory) .add("keyPair", keyPair) .add("p2pEnabled", p2pEnabled) - .add("discovery", discovery) + .add("discoveryEnabled", discoveryEnabled) .toString(); } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java index 00313fa7bc..b0ec5e4444 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ProcessPantheonNodeRunner.java @@ -58,7 +58,7 @@ public void startNode(final PantheonNode node) { params.add("--dev-mode"); } - if (!node.isDiscovery()) { + if (!node.isDiscoveryEnabled()) { params.add("--no-discovery"); params.add("true"); } 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 9120496963..15079ebe66 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 @@ -77,7 +77,7 @@ public void startNode(final PantheonNode node) { new RunnerBuilder() .vertx(Vertx.vertx()) .pantheonController(pantheonController) - .discovery(node.isDiscovery()) + .discovery(node.isDiscoveryEnabled()) .bootstrapPeers(node.bootnodes()) .discoveryHost(node.hostName()) .discoveryPort(node.p2pPort()) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfiguration.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfiguration.java index 730c6cc7da..876508f4a7 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfiguration.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfiguration.java @@ -28,7 +28,7 @@ class PantheonFactoryConfiguration { private final MetricsConfiguration metricsConfiguration; private final PermissioningConfiguration permissioningConfiguration; private final boolean devMode; - private final Boolean discovery; + private final Boolean discoveryEnabled; private final GenesisConfigProvider genesisConfigProvider; private final Boolean p2pEnabled; @@ -42,7 +42,7 @@ class PantheonFactoryConfiguration { final boolean devMode, final GenesisConfigProvider genesisConfigProvider, final Boolean p2pEnabled, - final boolean discovery) { + final Boolean discoveryEnabled) { this.name = name; this.miningParameters = miningParameters; this.jsonRpcConfiguration = jsonRpcConfiguration; @@ -52,7 +52,7 @@ class PantheonFactoryConfiguration { this.devMode = devMode; this.genesisConfigProvider = genesisConfigProvider; this.p2pEnabled = p2pEnabled; - this.discovery = discovery; + this.discoveryEnabled = discoveryEnabled; } public String getName() { @@ -83,8 +83,8 @@ public boolean isDevMode() { return devMode; } - public Boolean isDiscovery() { - return discovery; + public Boolean isDiscoveryEnabled() { + return discoveryEnabled; } public GenesisConfigProvider getGenesisConfigProvider() { diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfigurationBuilder.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfigurationBuilder.java index a166a34632..d9dcd3d79d 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfigurationBuilder.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonFactoryConfigurationBuilder.java @@ -35,7 +35,7 @@ public class PantheonFactoryConfigurationBuilder { private PermissioningConfiguration permissioningConfiguration = PermissioningConfiguration.createDefault(); private boolean devMode = true; - private Boolean discovery = true; + private Boolean discoveryEnabled = true; private GenesisConfigProvider genesisConfigProvider = ignore -> Optional.empty(); private Boolean p2pEnabled = true; @@ -109,8 +109,8 @@ public PantheonFactoryConfigurationBuilder setGenesisConfigProvider( return this; } - public PantheonFactoryConfigurationBuilder setDiscovery(final Boolean discovery) { - this.discovery = discovery; + public PantheonFactoryConfigurationBuilder setDiscoveryEnabled(final Boolean discoveryEnabled) { + this.discoveryEnabled = discoveryEnabled; return this; } @@ -130,6 +130,6 @@ public PantheonFactoryConfiguration build() { devMode, genesisConfigProvider, p2pEnabled, - discovery); + discoveryEnabled); } } diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonNodeFactory.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonNodeFactory.java index 079b3c3eab..18054fab0a 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonNodeFactory.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/factory/PantheonNodeFactory.java @@ -59,7 +59,7 @@ private PantheonNode create(final PantheonFactoryConfiguration config) throws IO config.getGenesisConfigProvider(), serverSocket.getLocalPort(), config.getP2pEnabled(), - config.isDiscovery()); + config.isDiscoveryEnabled()); serverSocket.close(); return node; @@ -193,7 +193,7 @@ public PantheonNode createNodeWithNodesWhitelistAndPermRPC( public PantheonNode createNodeWithNoDiscovery(final String name) throws IOException { return create( - new PantheonFactoryConfigurationBuilder().setName(name).setDiscovery(false).build()); + new PantheonFactoryConfigurationBuilder().setName(name).setDiscoveryEnabled(false).build()); } public PantheonNode createCliqueNode(final String name) throws IOException {