From 68bf62dd1dfc182cc8b0b6e3c8f64a92e81bf488 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Fri, 9 Oct 2020 13:28:13 +1000 Subject: [PATCH] added --privacy-flexible-groups-enabled alternative name (#1437) * added --privacy-flexible-groups-enabled as an alias for --privacy-onchain-groups-enabled Signed-off-by: Sally MacFarlane --- CHANGELOG.md | 1 + .../org/hyperledger/besu/cli/BesuCommand.java | 8 +++---- .../hyperledger/besu/cli/BesuCommandTest.java | 23 +++++++++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d8b65d832..51cfd10122 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ Hyperledger Besu is moving its versioning scheme to [CalVer](https://calver.org/ * Added `--start-block` and `--end-block` to the `blocks import` subcommand [\#1399](https://github.com/hyperledger/besu/pull/1399) * Added support for multi-tenancy when using the early access feature of [onchain privacy group management](https://besu.hyperledger.org/en/stable/Concepts/Privacy/Onchain-PrivacyGroups/) * Fixed memory leak in eth/65 subprotocol behavior. It is now enabled by default. [\#1420](https://github.com/hyperledger/besu/pull/1420), [#1348](https://github.com/hyperledger/besu/pull/1348), [#1321](https://github.com/hyperledger/besu/pull/1321) +* Added `--privacy-flexible-groups-enabled` as an alternative for `--privacy-onchain-groups-enabled` CLI option ### Bug Fixes diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java index 2629d081ea..c8e0f99a16 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -888,9 +888,9 @@ public class BesuCommand implements DefaultCommandValues, Runnable { private final Boolean migratePrivateDatabase = false; @Option( - names = {"--privacy-onchain-groups-enabled"}, - description = "Enable onchain privacy groups (default: ${DEFAULT-VALUE})") - private final Boolean isOnchainPrivacyGroupEnabled = false; + names = {"--privacy-flexible-groups-enabled", "--privacy-onchain-groups-enabled"}, + description = "Enable flexible (onchain) privacy groups (default: ${DEFAULT-VALUE})") + private final Boolean isFlexiblePrivacyGroupsEnabled = false; @Option( names = {"--target-gas-limit"}, @@ -1840,7 +1840,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { privacyParametersBuilder.setEnabled(true); privacyParametersBuilder.setEnclaveUrl(privacyUrl); privacyParametersBuilder.setMultiTenancyEnabled(isPrivacyMultiTenancyEnabled); - privacyParametersBuilder.setOnchainPrivacyGroupsEnabled(isOnchainPrivacyGroupEnabled); + privacyParametersBuilder.setOnchainPrivacyGroupsEnabled(isFlexiblePrivacyGroupsEnabled); final boolean hasPrivacyPublicKey = privacyPublicKeyFile != null; if (hasPrivacyPublicKey && !isPrivacyMultiTenancyEnabled) { diff --git a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java index d00937e485..f1ef10b169 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -3129,6 +3129,29 @@ public class BesuCommandTest extends CommandTestAbstract { assertThat(privacyParameters.isOnchainPrivacyGroupsEnabled()).isEqualTo(true); } + @Test + public void flexiblePrivacyGroupEnabledFlagValueIsSet() { + parseCommand( + "--privacy-enabled", + "--privacy-public-key-file", + ENCLAVE_PUBLIC_KEY_PATH, + "--privacy-flexible-groups-enabled", + "--min-gas-price", + "0"); + + final ArgumentCaptor privacyParametersArgumentCaptor = + ArgumentCaptor.forClass(PrivacyParameters.class); + + verify(mockControllerBuilder).privacyParameters(privacyParametersArgumentCaptor.capture()); + verify(mockControllerBuilder).build(); + + assertThat(commandOutput.toString()).isEmpty(); + assertThat(commandErrorOutput.toString()).isEmpty(); + + final PrivacyParameters privacyParameters = privacyParametersArgumentCaptor.getValue(); + assertThat(privacyParameters.isOnchainPrivacyGroupsEnabled()).isEqualTo(true); + } + @Test public void privacyMarkerTransactionSigningKeyFileRequiredIfMinGasPriceNonZero() { parseCommand("--privacy-enabled", "--privacy-public-key-file", ENCLAVE_PUBLIC_KEY_PATH);