Fix permissioning plugin test (#6737)

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
pull/6744/head
Gabriel-Trintinalia 8 months ago committed by GitHub
parent 22daf346ee
commit 9881e201df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 17
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java
  2. 27
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/PermissioningPluginTest.java

@ -106,7 +106,8 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
final TransactionPoolValidatorServiceImpl transactionPoolValidatorServiceImpl,
final BlockchainServiceImpl blockchainServiceImpl,
final RpcEndpointServiceImpl rpcEndpointServiceImpl,
final BesuConfiguration commonPluginConfiguration) {
final BesuConfiguration commonPluginConfiguration,
final PermissioningServiceImpl permissioningService) {
final CommandLine commandLine = new CommandLine(CommandSpec.create());
final BesuPluginContextImpl besuPluginContext = new BesuPluginContextImpl();
besuPluginContext.addService(StorageService.class, storageService);
@ -137,7 +138,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
}
besuPluginContext.addService(BesuConfiguration.class, commonPluginConfiguration);
besuPluginContext.addService(PermissioningService.class, new PermissioningServiceImpl());
besuPluginContext.addService(PermissioningService.class, permissioningService);
besuPluginContext.addService(PrivacyPluginService.class, new PrivacyPluginServiceImpl());
besuPluginContext.registerPlugins(pluginsPath);
@ -172,6 +173,8 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
final RpcEndpointServiceImpl rpcEndpointServiceImpl = new RpcEndpointServiceImpl();
final Path dataDir = node.homeDirectory();
final BesuConfigurationImpl commonPluginConfiguration = new BesuConfigurationImpl();
final PermissioningServiceImpl permissioningService = new PermissioningServiceImpl();
final var miningParameters =
ImmutableMiningParameters.builder()
.from(node.getMiningParameters())
@ -195,7 +198,8 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
transactionPoolValidatorServiceImpl,
blockchainServiceImpl,
rpcEndpointServiceImpl,
commonPluginConfiguration));
commonPluginConfiguration,
permissioningService));
GlobalOpenTelemetry.resetForTest();
final ObservableMetricsSystem metricsSystem =
@ -283,7 +287,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
.jsonRpcIpcConfiguration(node.jsonRpcIpcConfiguration())
.dataDir(node.homeDirectory())
.metricsSystem(metricsSystem)
.permissioningService(new PermissioningServiceImpl())
.permissioningService(permissioningService)
.metricsConfiguration(node.getMetricsConfiguration())
.p2pEnabled(node.isP2pEnabled())
.p2pTLSConfiguration(node.getTLSConfiguration())
@ -292,15 +296,14 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
node.getStaticNodes().stream()
.map(EnodeURLImpl::fromString)
.collect(Collectors.toList()))
.besuPluginContext(new BesuPluginContextImpl())
.besuPluginContext(besuPluginContext)
.autoLogBloomCaching(false)
.storageProvider(storageProvider)
.rpcEndpointService(rpcEndpointServiceImpl);
node.engineRpcConfiguration().ifPresent(runnerBuilder::engineJsonRpcConfiguration);
final Runner runner = runnerBuilder.build();
besuPluginContext.beforeExternalServices();
final Runner runner = runnerBuilder.build();
runner.startExternalServices();

@ -37,22 +37,13 @@ public class PermissioningPluginTest extends AcceptanceTestBaseJunit5 {
@BeforeEach
public void setUp() throws Exception {
final BesuNodeConfigurationBuilder builder =
new BesuNodeConfigurationBuilder()
.miningEnabled(false)
.plugins(List.of("testPlugins"))
.extraCLIOptions(List.of("--plugin-permissioning-test-enabled=true"))
.jsonRpcEnabled()
.jsonRpcTxPool()
.jsonRpcAdmin();
minerNode = besu.create(createNodeBuilder().name("miner").build());
minerNode = besu.create(builder.name("miner").build());
aliceNode = besu.create(createNodeBuilder().name("alice").keyFilePath("key").build());
aliceNode = besu.create(builder.name("alice").keyFilePath("key").build());
bobNode = besu.create(createNodeBuilder().name("bob").keyFilePath("key1").build());
bobNode = besu.create(builder.name("bob").keyFilePath("key1").build());
charlieNode = besu.create(builder.name("charlie").keyFilePath("key2").build());
charlieNode = besu.create(createNodeBuilder().name("charlie").keyFilePath("key2").build());
cluster.start(minerNode, charlieNode);
@ -63,6 +54,16 @@ public class PermissioningPluginTest extends AcceptanceTestBaseJunit5 {
bobNode.awaitPeerDiscovery(net.awaitPeerCount(2));
}
private BesuNodeConfigurationBuilder createNodeBuilder() {
return new BesuNodeConfigurationBuilder()
.miningEnabled(false)
.plugins(List.of("testPlugins"))
.extraCLIOptions(List.of("--plugin-permissioning-test-enabled=true"))
.jsonRpcEnabled()
.jsonRpcTxPool()
.jsonRpcAdmin();
}
@Test
public void blockedConnectionNodeCanOnlyConnectToTransactionNode() {
minerNode.verify(admin.hasPeer(aliceNode));

Loading…
Cancel
Save