use of org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration in project besu by hyperledger.
the class AccountPermissioningControllerFactoryTest method createLocalConfigOnlyControllerShouldReturnExpectedController.
@Test
public void createLocalConfigOnlyControllerShouldReturnExpectedController() {
LocalPermissioningConfiguration localConfig = localConfig();
assertThat(localConfig.isAccountAllowlistEnabled()).isTrue();
PermissioningConfiguration permissioningConfiguration = new PermissioningConfiguration(Optional.of(localConfig), Optional.empty(), Optional.empty());
Optional<AccountPermissioningController> controller = AccountPermissioningControllerFactory.create(permissioningConfiguration, transactionSimulator, metricsSystem, blockchain);
Assertions.assertThat(controller).isNotEmpty();
assertThat(controller.get().getAccountLocalConfigPermissioningController()).isNotEmpty();
assertThat(controller.get().getTransactionSmartContractPermissioningController()).isEmpty();
}
use of org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration in project besu by hyperledger.
the class AccountPermissioningControllerFactoryTest method createLocalConfigWithAccountPermissioningDisabledShouldReturnEmpty.
@Test
public void createLocalConfigWithAccountPermissioningDisabledShouldReturnEmpty() {
LocalPermissioningConfiguration localConfig = LocalPermissioningConfiguration.createDefault();
assertThat(localConfig.isAccountAllowlistEnabled()).isFalse();
PermissioningConfiguration permissioningConfiguration = new PermissioningConfiguration(Optional.of(localConfig), Optional.empty(), Optional.empty());
Optional<AccountPermissioningController> controller = AccountPermissioningControllerFactory.create(permissioningConfiguration, transactionSimulator, metricsSystem, blockchain);
Assertions.assertThat(controller).isEmpty();
}
use of org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration 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();
}
use of org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration in project besu by hyperledger.
the class LocalPermissioningConfigurationValidatorTest method nodeAllowlistCheckShouldIgnoreDiscoveryPortParam.
@Test
public void nodeAllowlistCheckShouldIgnoreDiscoveryPortParam() throws Exception {
final URL configFile = this.getClass().getResource(PERMISSIONING_CONFIG);
final Path toml = Files.createTempFile("toml", "");
toml.toFile().deleteOnExit();
Files.write(toml, Resources.toByteArray(configFile));
final LocalPermissioningConfiguration permissioningConfiguration = PermissioningConfigurationBuilder.permissioningConfiguration(true, EnodeDnsConfiguration.DEFAULT_CONFIG, toml.toAbsolutePath().toString(), true, toml.toAbsolutePath().toString());
// This node is defined in the PERMISSIONING_CONFIG file without the discovery port
final EnodeURL enodeURL = EnodeURLImpl.fromString("enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@192.168.0.9:4567?discport=30303");
// In an URI comparison the URLs should not match
boolean isInAllowlist = permissioningConfiguration.getNodeAllowlist().contains(enodeURL);
assertThat(isInAllowlist).isFalse();
// error
try {
PermissioningConfigurationValidator.areAllNodesAreInAllowlist(Lists.newArrayList(enodeURL), permissioningConfiguration);
} catch (Exception e) {
fail("Exception not expected. Validation of nodes in allowlist should ignore the optional discovery port param.");
}
}
use of org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration in project besu by hyperledger.
the class LocalPermissioningConfigurationValidatorTest method nodesAllowlistOptionWhichDoesNotIncludeBootnodesMustError.
@Test
public void nodesAllowlistOptionWhichDoesNotIncludeBootnodesMustError() throws Exception {
EthNetworkConfig ethNetworkConfig = EthNetworkConfig.getNetworkConfig(NetworkName.ROPSTEN);
final URL configFile = this.getClass().getResource(PERMISSIONING_CONFIG);
final Path toml = Files.createTempFile("toml", "");
toml.toFile().deleteOnExit();
Files.write(toml, Resources.toByteArray(configFile));
LocalPermissioningConfiguration permissioningConfiguration = PermissioningConfigurationBuilder.permissioningConfiguration(true, EnodeDnsConfiguration.DEFAULT_CONFIG, toml.toAbsolutePath().toString(), true, toml.toAbsolutePath().toString());
try {
final List<EnodeURL> enodeURIs = ethNetworkConfig.getBootNodes();
PermissioningConfigurationValidator.areAllNodesAreInAllowlist(enodeURIs, permissioningConfiguration);
fail("expected exception because ropsten bootnodes are not in node-allowlist");
} catch (Exception e) {
assertThat(e.getMessage()).startsWith("Specified node(s) not in nodes-allowlist");
assertThat(e.getMessage()).contains("enode://6332792c4a00e3e4ee0926ed89e0d27ef985424d97b6a45bf0f23e51f0dcb5e66b875777506458aea7af6f9e4ffb69f43f3778ee73c81ed9d34c51c4b16b0b0f@52.232.243.152:30303");
assertThat(e.getMessage()).contains("enode://94c15d1b9e2fe7ce56e458b9a3b672ef11894ddedd0c6f247e0f1d3487f52b66208fb4aeb8179fce6e3a749ea93ed147c37976d67af557508d199d9594c35f09@192.81.208.223:30303");
}
}
Aggregations