Add suport for --plugins option in acceptance tests (#7713)

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
pull/7732/head
Fabio Di Fabio 2 months ago committed by GitHub
parent 9310e1031d
commit 94099d18f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java
  2. 5
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java
  3. 15
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java
  4. 7
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java
  5. 8
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java
  6. 1
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java

@ -128,6 +128,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
private boolean useWsForJsonRpc = false; private boolean useWsForJsonRpc = false;
private String token = null; private String token = null;
private final List<String> plugins = new ArrayList<>(); private final List<String> plugins = new ArrayList<>();
private final List<String> requestedPlugins;
private final List<String> extraCLIOptions; private final List<String> extraCLIOptions;
private final List<String> staticNodes; private final List<String> staticNodes;
private boolean isDnsEnabled = false; private boolean isDnsEnabled = false;
@ -163,6 +164,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
final boolean secp256k1Native, final boolean secp256k1Native,
final boolean altbn128Native, final boolean altbn128Native,
final List<String> plugins, final List<String> plugins,
final List<String> requestedPlugins,
final List<String> extraCLIOptions, final List<String> extraCLIOptions,
final List<String> staticNodes, final List<String> staticNodes,
final boolean isDnsEnabled, final boolean isDnsEnabled,
@ -224,6 +226,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
LOG.error("Could not find plugin \"{}\" in resources", pluginName); LOG.error("Could not find plugin \"{}\" in resources", pluginName);
} }
}); });
this.requestedPlugins = requestedPlugins;
engineRpcConfiguration.ifPresent( engineRpcConfiguration.ifPresent(
config -> MergeConfigOptions.setMergeEnabled(config.isEnabled())); config -> MergeConfigOptions.setMergeEnabled(config.isEnabled()));
this.extraCLIOptions = extraCLIOptions; this.extraCLIOptions = extraCLIOptions;
@ -738,6 +741,10 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
return plugins; return plugins;
} }
public List<String> getRequestedPlugins() {
return requestedPlugins;
}
@Override @Override
public List<String> getExtraCLIOptions() { public List<String> getExtraCLIOptions() {
return extraCLIOptions; return extraCLIOptions;

@ -451,6 +451,11 @@ public class ProcessBesuNodeRunner implements BesuNodeRunner {
params.add("--logging=" + level); params.add("--logging=" + level);
} }
if (!node.getRequestedPlugins().isEmpty()) {
params.add(
"--plugins=" + node.getRequestedPlugins().stream().collect(Collectors.joining(",")));
}
params.addAll(node.getRunCommand()); params.addAll(node.getRunCommand());
return params; return params;
} }

@ -39,6 +39,7 @@ import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration; import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration;
import org.hyperledger.besu.ethereum.core.plugins.PluginInfo;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.BlobCacheModule; import org.hyperledger.besu.ethereum.eth.transactions.BlobCacheModule;
@ -302,6 +303,12 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
return toProvide.getExtraCLIOptions(); return toProvide.getExtraCLIOptions();
} }
@Provides
@Named("RequestedPlugins")
public List<String> provideRequestedPlugins() {
return toProvide.getRequestedPlugins();
}
@Provides @Provides
Path provideDataDir() { Path provideDataDir() {
return toProvide.homeDirectory(); return toProvide.homeDirectory();
@ -469,7 +476,8 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
final RpcEndpointServiceImpl rpcEndpointServiceImpl, final RpcEndpointServiceImpl rpcEndpointServiceImpl,
final BesuConfiguration commonPluginConfiguration, final BesuConfiguration commonPluginConfiguration,
final PermissioningServiceImpl permissioningService, final PermissioningServiceImpl permissioningService,
final @Named("ExtraCLIOptions") List<String> extraCLIOptions) { final @Named("ExtraCLIOptions") List<String> extraCLIOptions,
final @Named("RequestedPlugins") List<String> requestedPlugins) {
final CommandLine commandLine = new CommandLine(CommandSpec.create()); final CommandLine commandLine = new CommandLine(CommandSpec.create());
final BesuPluginContextImpl besuPluginContext = new BesuPluginContextImpl(); final BesuPluginContextImpl besuPluginContext = new BesuPluginContextImpl();
besuPluginContext.addService(StorageService.class, storageService); besuPluginContext.addService(StorageService.class, storageService);
@ -504,7 +512,10 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
besuPluginContext.addService(PrivacyPluginService.class, new PrivacyPluginServiceImpl()); besuPluginContext.addService(PrivacyPluginService.class, new PrivacyPluginServiceImpl());
besuPluginContext.initialize( besuPluginContext.initialize(
new PluginConfiguration.Builder().pluginsDir(pluginsPath).build()); new PluginConfiguration.Builder()
.pluginsDir(pluginsPath)
.requestedPlugins(requestedPlugins.stream().map(PluginInfo::new).toList())
.build());
besuPluginContext.registerPlugins(); besuPluginContext.registerPlugins();
commandLine.parseArgs(extraCLIOptions.toArray(new String[0])); commandLine.parseArgs(extraCLIOptions.toArray(new String[0]));

@ -64,6 +64,7 @@ public class BesuNodeConfiguration {
private final boolean secp256k1Native; private final boolean secp256k1Native;
private final boolean altbn128Native; private final boolean altbn128Native;
private final List<String> plugins; private final List<String> plugins;
private final List<String> requestedPlugins;
private final List<String> extraCLIOptions; private final List<String> extraCLIOptions;
private final List<String> staticNodes; private final List<String> staticNodes;
private final boolean isDnsEnabled; private final boolean isDnsEnabled;
@ -102,6 +103,7 @@ public class BesuNodeConfiguration {
final boolean secp256k1Native, final boolean secp256k1Native,
final boolean altbn128Native, final boolean altbn128Native,
final List<String> plugins, final List<String> plugins,
final List<String> requestedPlugins,
final List<String> extraCLIOptions, final List<String> extraCLIOptions,
final List<String> staticNodes, final List<String> staticNodes,
final boolean isDnsEnabled, final boolean isDnsEnabled,
@ -137,6 +139,7 @@ public class BesuNodeConfiguration {
this.secp256k1Native = secp256k1Native; this.secp256k1Native = secp256k1Native;
this.altbn128Native = altbn128Native; this.altbn128Native = altbn128Native;
this.plugins = plugins; this.plugins = plugins;
this.requestedPlugins = requestedPlugins;
this.extraCLIOptions = extraCLIOptions; this.extraCLIOptions = extraCLIOptions;
this.staticNodes = staticNodes; this.staticNodes = staticNodes;
this.isDnsEnabled = isDnsEnabled; this.isDnsEnabled = isDnsEnabled;
@ -239,6 +242,10 @@ public class BesuNodeConfiguration {
return plugins; return plugins;
} }
public List<String> getRequestedPlugins() {
return requestedPlugins;
}
public List<String> getExtraCLIOptions() { public List<String> getExtraCLIOptions() {
return extraCLIOptions; return extraCLIOptions;
} }

@ -93,6 +93,7 @@ public class BesuNodeConfigurationBuilder {
private boolean secp256K1Native = true; private boolean secp256K1Native = true;
private boolean altbn128Native = true; private boolean altbn128Native = true;
private final List<String> plugins = new ArrayList<>(); private final List<String> plugins = new ArrayList<>();
private final List<String> requestedPlugins = new ArrayList<>();
private final List<String> extraCLIOptions = new ArrayList<>(); private final List<String> extraCLIOptions = new ArrayList<>();
private List<String> staticNodes = new ArrayList<>(); private List<String> staticNodes = new ArrayList<>();
private boolean isDnsEnabled = false; private boolean isDnsEnabled = false;
@ -448,6 +449,12 @@ public class BesuNodeConfigurationBuilder {
return this; return this;
} }
public BesuNodeConfigurationBuilder requestedPlugins(final List<String> requestedPlugins) {
this.requestedPlugins.clear();
this.requestedPlugins.addAll(requestedPlugins);
return this;
}
public BesuNodeConfigurationBuilder extraCLIOptions(final List<String> extraCLIOptions) { public BesuNodeConfigurationBuilder extraCLIOptions(final List<String> extraCLIOptions) {
this.extraCLIOptions.clear(); this.extraCLIOptions.clear();
this.extraCLIOptions.addAll(extraCLIOptions); this.extraCLIOptions.addAll(extraCLIOptions);
@ -545,6 +552,7 @@ public class BesuNodeConfigurationBuilder {
secp256K1Native, secp256K1Native,
altbn128Native, altbn128Native,
plugins, plugins,
requestedPlugins,
extraCLIOptions, extraCLIOptions,
staticNodes, staticNodes,
isDnsEnabled, isDnsEnabled,

@ -77,6 +77,7 @@ public class BesuNodeFactory {
config.isSecp256k1Native(), config.isSecp256k1Native(),
config.isAltbn128Native(), config.isAltbn128Native(),
config.getPlugins(), config.getPlugins(),
config.getRequestedPlugins(),
config.getExtraCLIOptions(), config.getExtraCLIOptions(),
config.getStaticNodes(), config.getStaticNodes(),
config.isDnsEnabled(), config.isDnsEnabled(),

Loading…
Cancel
Save