Skip to content

Commit

Permalink
Fix permissioning plugin test (hyperledger#6737)
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
  • Loading branch information
Gabriel-Trintinalia authored Mar 15, 2024
1 parent 22daf34 commit 9881e20
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ private BesuPluginContextImpl buildPluginContext(
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);
Expand Down Expand Up @@ -137,7 +138,7 @@ private BesuPluginContextImpl buildPluginContext(
}

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);
Expand Down Expand Up @@ -172,6 +173,8 @@ public void startNode(final BesuNode node) {
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())
Expand All @@ -195,7 +198,8 @@ public void startNode(final BesuNode node) {
transactionPoolValidatorServiceImpl,
blockchainServiceImpl,
rpcEndpointServiceImpl,
commonPluginConfiguration));
commonPluginConfiguration,
permissioningService));

GlobalOpenTelemetry.resetForTest();
final ObservableMetricsSystem metricsSystem =
Expand Down Expand Up @@ -283,7 +287,7 @@ public void startNode(final BesuNode node) {
.jsonRpcIpcConfiguration(node.jsonRpcIpcConfiguration())
.dataDir(node.homeDirectory())
.metricsSystem(metricsSystem)
.permissioningService(new PermissioningServiceImpl())
.permissioningService(permissioningService)
.metricsConfiguration(node.getMetricsConfiguration())
.p2pEnabled(node.isP2pEnabled())
.p2pTLSConfiguration(node.getTLSConfiguration())
Expand All @@ -292,15 +296,14 @@ public void startNode(final BesuNode node) {
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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -63,6 +54,16 @@ public void setUp() throws Exception {
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));
Expand Down

0 comments on commit 9881e20

Please sign in to comment.