Search in sources :

Example 1 with SmartContractPermissioningConfiguration

use of org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration in project besu by hyperledger.

the class AccountPermissioningControllerFactoryTest method createOnchainConfigOnlyControllerShouldReturnExpectedController.

@Test
public void createOnchainConfigOnlyControllerShouldReturnExpectedController() {
    SmartContractPermissioningConfiguration onchainConfig = onchainConfig();
    assertThat(onchainConfig.isSmartContractAccountAllowlistEnabled()).isTrue();
    PermissioningConfiguration permissioningConfiguration = new PermissioningConfiguration(Optional.empty(), Optional.of(onchainConfig), Optional.empty());
    Optional<AccountPermissioningController> controller = AccountPermissioningControllerFactory.create(permissioningConfiguration, transactionSimulator, metricsSystem, blockchain);
    Assertions.assertThat(controller).isNotEmpty();
    assertThat(controller.get().getAccountLocalConfigPermissioningController()).isEmpty();
    assertThat(controller.get().getTransactionSmartContractPermissioningController()).isNotEmpty();
}
Also used : PermissioningConfiguration(org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration) SmartContractPermissioningConfiguration(org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration) LocalPermissioningConfiguration(org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration) SmartContractPermissioningConfiguration(org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration) Test(org.junit.Test)

Example 2 with SmartContractPermissioningConfiguration

use of org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration in project besu by hyperledger.

the class AccountPermissioningControllerFactoryTest method createLocalAndOnchainControllerShouldReturnExpectedControllers.

@Test
public void createLocalAndOnchainControllerShouldReturnExpectedControllers() {
    LocalPermissioningConfiguration localConfig = localConfig();
    assertThat(localConfig.isAccountAllowlistEnabled()).isTrue();
    SmartContractPermissioningConfiguration onchainConfig = onchainConfig();
    assertThat(onchainConfig.isSmartContractAccountAllowlistEnabled()).isTrue();
    PermissioningConfiguration permissioningConfiguration = new PermissioningConfiguration(Optional.of(localConfig), Optional.of(onchainConfig), Optional.empty());
    Optional<AccountPermissioningController> controller = AccountPermissioningControllerFactory.create(permissioningConfiguration, transactionSimulator, metricsSystem, blockchain);
    Assertions.assertThat(controller).isNotEmpty();
    assertThat(controller.get().getAccountLocalConfigPermissioningController()).isNotEmpty();
    assertThat(controller.get().getTransactionSmartContractPermissioningController()).isNotEmpty();
}
Also used : LocalPermissioningConfiguration(org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration) PermissioningConfiguration(org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration) SmartContractPermissioningConfiguration(org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration) LocalPermissioningConfiguration(org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration) SmartContractPermissioningConfiguration(org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration) Test(org.junit.Test)

Example 3 with SmartContractPermissioningConfiguration

use of org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration in project besu by hyperledger.

the class NodePermissioningControllerFactoryTest method createOnchainShouldFailIfValidationFails.

@Test
public void createOnchainShouldFailIfValidationFails() {
    smartContractPermissioningConfiguration = new SmartContractPermissioningConfiguration();
    smartContractPermissioningConfiguration.setNodeSmartContractAddress(Address.fromHexString("0x0000000000000000000000000000000000001234"));
    smartContractPermissioningConfiguration.setSmartContractNodeAllowlistEnabled(true);
    config = new PermissioningConfiguration(Optional.empty(), Optional.of(smartContractPermissioningConfiguration), Optional.empty());
    when(transactionSimulator.processAtHead(any())).thenThrow(new RuntimeException());
    final Throwable thrown = catchThrowable(() -> new NodePermissioningControllerFactory().create(config, synchronizer, bootnodes, selfEnode.getNodeId(), transactionSimulator, new NoOpMetricsSystem(), blockchain, Collections.emptyList()));
    assertThat(thrown).isInstanceOf(IllegalStateException.class).hasMessage("Error: node permissioning contract at address 0x0000000000000000000000000000000000001234 does not match the expected interface version 1.");
}
Also used : PermissioningConfiguration(org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration) SmartContractPermissioningConfiguration(org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration) LocalPermissioningConfiguration(org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) Assertions.catchThrowable(org.assertj.core.api.Assertions.catchThrowable) SmartContractPermissioningConfiguration(org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration) NodePermissioningControllerFactory(org.hyperledger.besu.ethereum.permissioning.NodePermissioningControllerFactory) Test(org.junit.Test)

Example 4 with SmartContractPermissioningConfiguration

use of org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration in project besu by hyperledger.

the class NodePermissioningControllerFactoryTest method testCreateWithLocalNodeAndSmartContractPermissioningEnabled.

@Test
public void testCreateWithLocalNodeAndSmartContractPermissioningEnabled() {
    localPermissioningConfig = LocalPermissioningConfiguration.createDefault();
    localPermissioningConfig.setNodeAllowlist(Collections.emptyList());
    localPermissioningConfig.setNodePermissioningConfigFilePath("fake-file-path");
    smartContractPermissioningConfiguration = new SmartContractPermissioningConfiguration();
    smartContractPermissioningConfiguration.setNodeSmartContractAddress(Address.fromHexString("0x0000000000000000000000000000000000001234"));
    smartContractPermissioningConfiguration.setSmartContractNodeAllowlistEnabled(true);
    config = new PermissioningConfiguration(Optional.of(localPermissioningConfig), Optional.of(smartContractPermissioningConfiguration), Optional.empty());
    NodePermissioningControllerFactory factory = new NodePermissioningControllerFactory();
    NodePermissioningController controller = factory.create(config, synchronizer, bootnodes, selfEnode.getNodeId(), transactionSimulator, new NoOpMetricsSystem(), blockchain, Collections.emptyList());
    List<NodeConnectionPermissioningProvider> providers = controller.getProviders();
    assertThat(providers.size()).isEqualTo(2);
    NodeConnectionPermissioningProvider p1 = providers.get(0);
    NodeConnectionPermissioningProvider p2 = providers.get(1);
    if (p1.getClass() == NodeLocalConfigPermissioningController.class) {
        assertThat(p2).isInstanceOf(NodeSmartContractPermissioningController.class);
    } else {
        assertThat(p2).isInstanceOf(NodeLocalConfigPermissioningController.class);
        assertThat(p1).isInstanceOf(NodeSmartContractPermissioningController.class);
    }
    assertThat(controller.getSyncStatusNodePermissioningProvider()).isEmpty();
}
Also used : PermissioningConfiguration(org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration) SmartContractPermissioningConfiguration(org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration) LocalPermissioningConfiguration(org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) SmartContractPermissioningConfiguration(org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration) NodePermissioningControllerFactory(org.hyperledger.besu.ethereum.permissioning.NodePermissioningControllerFactory) NodeConnectionPermissioningProvider(org.hyperledger.besu.plugin.services.permissioning.NodeConnectionPermissioningProvider) Test(org.junit.Test)

Example 5 with SmartContractPermissioningConfiguration

use of org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration in project besu by hyperledger.

the class NodePermissioningControllerFactoryTest method testCreateWithSmartContractNodePermissioningEnabledOnlyAndBootnode.

@Test
public void testCreateWithSmartContractNodePermissioningEnabledOnlyAndBootnode() {
    final Collection<EnodeURL> fixedNodes = Collections.singleton(selfEnode);
    smartContractPermissioningConfiguration = new SmartContractPermissioningConfiguration();
    smartContractPermissioningConfiguration.setNodeSmartContractAddress(Address.fromHexString("0x0000000000000000000000000000000000001234"));
    smartContractPermissioningConfiguration.setSmartContractNodeAllowlistEnabled(true);
    config = new PermissioningConfiguration(Optional.empty(), Optional.of(smartContractPermissioningConfiguration), Optional.empty());
    NodePermissioningControllerFactory factory = new NodePermissioningControllerFactory();
    NodePermissioningController controller = factory.create(config, synchronizer, fixedNodes, selfEnode.getNodeId(), transactionSimulator, new NoOpMetricsSystem(), blockchain, Collections.emptyList());
    assertThat(controller.getSyncStatusNodePermissioningProvider()).isPresent();
}
Also used : EnodeURL(org.hyperledger.besu.plugin.data.EnodeURL) PermissioningConfiguration(org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration) SmartContractPermissioningConfiguration(org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration) LocalPermissioningConfiguration(org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) SmartContractPermissioningConfiguration(org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration) NodePermissioningControllerFactory(org.hyperledger.besu.ethereum.permissioning.NodePermissioningControllerFactory) Test(org.junit.Test)

Aggregations

SmartContractPermissioningConfiguration (org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration)19 PermissioningConfiguration (org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration)16 LocalPermissioningConfiguration (org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration)15 Test (org.junit.Test)14 NodePermissioningControllerFactory (org.hyperledger.besu.ethereum.permissioning.NodePermissioningControllerFactory)5 NoOpMetricsSystem (org.hyperledger.besu.metrics.noop.NoOpMetricsSystem)5 NodeConnectionPermissioningProvider (org.hyperledger.besu.plugin.services.permissioning.NodeConnectionPermissioningProvider)3 EnodeURL (org.hyperledger.besu.plugin.data.EnodeURL)2 IOException (java.io.IOException)1 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)1 ThrowableAssert.catchThrowable (org.assertj.core.api.ThrowableAssert.catchThrowable)1 Address (org.hyperledger.besu.datatypes.Address)1 GoQuorumPermissioningConfiguration (org.hyperledger.besu.ethereum.permissioning.GoQuorumPermissioningConfiguration)1 TransactionSmartContractPermissioningController (org.hyperledger.besu.ethereum.permissioning.TransactionSmartContractPermissioningController)1 BesuNode (org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode)1 BesuNodeConfigurationBuilder (org.hyperledger.besu.tests.acceptance.dsl.node.configuration.BesuNodeConfigurationBuilder)1 BesuNodeFactory (org.hyperledger.besu.tests.acceptance.dsl.node.configuration.BesuNodeFactory)1 ParameterException (picocli.CommandLine.ParameterException)1