use of com.quorum.tessera.enclave.EnclaveClient in project tessera by ConsenSys.
the class EnclaveClientProviderTest method provider.
@Test
public void provider() {
try (var configFactoryMockedStatic = mockStatic(ConfigFactory.class)) {
configFactoryMockedStatic.when(ConfigFactory::create).thenReturn(configFactory);
if (appType == AppType.ENCLAVE) {
EnclaveClient enclaveClient = EnclaveClientProvider.provider();
assertThat(enclaveClient).isNotNull();
} else {
Throwable ex = catchThrowable(() -> EnclaveClientProvider.provider());
assertThat(ex).isExactlyInstanceOf(NoSuchElementException.class);
}
configFactoryMockedStatic.verify(ConfigFactory::create);
configFactoryMockedStatic.verifyNoMoreInteractions();
}
verify(configFactory).getConfig();
}
use of com.quorum.tessera.enclave.EnclaveClient in project tessera by ConsenSys.
the class EnclaveClientProvider method provider.
public static EnclaveClient provider() {
Config config = ConfigFactory.create().getConfig();
LOGGER.debug("Creating RestfulEnclaveClient with {}", config);
Optional<ServerConfig> enclaveServerConfig = config.getServerConfigs().stream().filter(sc -> sc.getApp() == AppType.ENCLAVE).findAny();
final ClientFactory clientFactory = new ClientFactory();
LOGGER.debug("Creating server context from config");
ServerConfig serverConfig = enclaveServerConfig.get();
LOGGER.debug("Created server context from config");
Client client = clientFactory.buildFrom(serverConfig);
LOGGER.info("Creating remoted enclave for {}", serverConfig.getServerUri());
return new RestfulEnclaveClient(client, serverConfig.getServerUri());
}
Aggregations