From 3c5a2ba7a23e4adce984a4bfc96478fc367b0d23 Mon Sep 17 00:00:00 2001 From: Mark Terry Date: Tue, 21 May 2019 22:14:16 +1000 Subject: [PATCH 1/2] [PIE-1593] Fixed NodePermissioningControllerFactory empty fixed node configuraiton. Updated existing tests and added new test. --- .../NodePermissioningControllerFactory.java | 9 +++++--- ...odePermissioningControllerFactoryTest.java | 22 ++++++++++++++++++- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/NodePermissioningControllerFactory.java b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/NodePermissioningControllerFactory.java index edbbb48a6e..db48e7a7a0 100644 --- a/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/NodePermissioningControllerFactory.java +++ b/ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/NodePermissioningControllerFactory.java @@ -59,9 +59,12 @@ public NodePermissioningController create( providers.add(smartContractProvider); } - final SyncStatusNodePermissioningProvider syncStatusProvider = - new SyncStatusNodePermissioningProvider(synchronizer, fixedNodes); - syncStatusProviderOptional = Optional.of(syncStatusProvider); + if (fixedNodes.isEmpty()) { + syncStatusProviderOptional = Optional.empty(); + } else { + syncStatusProviderOptional = + Optional.of(new SyncStatusNodePermissioningProvider(synchronizer, fixedNodes)); + } } else { syncStatusProviderOptional = Optional.empty(); } diff --git a/ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/node/NodePermissioningControllerFactoryTest.java b/ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/node/NodePermissioningControllerFactoryTest.java index 0940245f08..053175aa57 100644 --- a/ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/node/NodePermissioningControllerFactoryTest.java +++ b/ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/node/NodePermissioningControllerFactoryTest.java @@ -82,7 +82,7 @@ public void testCreateWithSmartContractNodePermissioningEnabledOnly() { NodePermissioningProvider p1 = providers.get(0); assertThat(p1).isInstanceOf(NodeSmartContractPermissioningController.class); - assertThat(controller.getSyncStatusNodePermissioningProvider()).isPresent(); + assertThat(controller.getSyncStatusNodePermissioningProvider()).isEmpty(); } @Test @@ -137,6 +137,26 @@ public void testCreateWithLocalNodeAndSmartContractPermissioningEnabled() { assertThat(p2).isInstanceOf(NodeLocalConfigPermissioningController.class); assertThat(p1).isInstanceOf(NodeSmartContractPermissioningController.class); } + assertThat(controller.getSyncStatusNodePermissioningProvider()).isEmpty(); + } + + @Test + public void testCreateWithSmartContractNodePermissioningEnabledOnlyAndBootnode() { + final Collection fixedNodes = Collections.singleton(selfEnode); + + smartContractPermissioningConfiguration = new SmartContractPermissioningConfiguration(); + smartContractPermissioningConfiguration.setNodeSmartContractAddress( + Address.fromHexString("0x0000000000000000000000000000000000001234")); + smartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true); + config = + new PermissioningConfiguration( + Optional.empty(), Optional.of(smartContractPermissioningConfiguration)); + + NodePermissioningControllerFactory factory = new NodePermissioningControllerFactory(); + NodePermissioningController controller = + factory.create( + config, synchronizer, fixedNodes, selfEnode.getNodeId(), transactionSimulator); + assertThat(controller.getSyncStatusNodePermissioningProvider()).isPresent(); } } From a537742bde3ab755ecc48516b26787dc10742855 Mon Sep 17 00:00:00 2001 From: Mark Terry Date: Wed, 22 May 2019 09:06:57 +1000 Subject: [PATCH 2/2] [PIE-1593] Test renames. --- ...java => NodeSmartContractPermissioningAcceptanceTest.java} | 4 ++-- ... => NodeSmartContractPermissioningAcceptanceTestBase.java} | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/{NodeNodeSmartContractNodePermissioningAcceptanceTest.java => NodeSmartContractPermissioningAcceptanceTest.java} (96%) rename acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/{NodeSmartContractNodePermissioningAcceptanceTestBase.java => NodeSmartContractPermissioningAcceptanceTestBase.java} (96%) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeNodeSmartContractNodePermissioningAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTest.java similarity index 96% rename from acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeNodeSmartContractNodePermissioningAcceptanceTest.java rename to acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTest.java index bac4e14c2c..e901952f31 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeNodeSmartContractNodePermissioningAcceptanceTest.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTest.java @@ -17,8 +17,8 @@ import org.junit.Before; import org.junit.Test; -public class NodeNodeSmartContractNodePermissioningAcceptanceTest - extends NodeSmartContractNodePermissioningAcceptanceTestBase { +public class NodeSmartContractPermissioningAcceptanceTest + extends NodeSmartContractPermissioningAcceptanceTestBase { private Node bootnode; private Node permissionedNode; diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeSmartContractNodePermissioningAcceptanceTestBase.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTestBase.java similarity index 96% rename from acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeSmartContractNodePermissioningAcceptanceTestBase.java rename to acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTestBase.java index 5dd9ec59f0..50ae9a3166 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeSmartContractNodePermissioningAcceptanceTestBase.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTestBase.java @@ -25,7 +25,7 @@ import java.io.IOException; -class NodeSmartContractNodePermissioningAcceptanceTestBase extends AcceptanceTestBase { +class NodeSmartContractPermissioningAcceptanceTestBase extends AcceptanceTestBase { private final NodeSmartContractPermissioningTransactions smartContractNodePermissioning; private final NodeSmartContractPermissioningConditions nodeSmartContractPermissioningConditions; @@ -35,7 +35,7 @@ class NodeSmartContractNodePermissioningAcceptanceTestBase extends AcceptanceTes protected final Cluster permissionedCluster; - protected NodeSmartContractNodePermissioningAcceptanceTestBase() { + protected NodeSmartContractPermissioningAcceptanceTestBase() { super(); smartContractNodePermissioning = new NodeSmartContractPermissioningTransactions(accounts); nodeSmartContractPermissioningConditions =