use of com.quorum.tessera.discovery.Discovery in project tessera by ConsenSys.
the class PayloadPublisherProvider method provider.
public static PayloadPublisher provider() {
Config config = ConfigFactory.create().getConfig();
Discovery partyInfoService = Discovery.create();
ClientFactory clientFactory = new ClientFactory();
Client client = clientFactory.buildFrom(config.getP2PServerConfig());
return new RestPayloadPublisher(client, partyInfoService);
}
use of com.quorum.tessera.discovery.Discovery in project tessera by ConsenSys.
the class PrivacyGroupPublisherProvider method provider.
public static PrivacyGroupPublisher provider() {
Discovery discovery = Discovery.create();
Config config = ConfigFactory.create().getConfig();
Client client = new ClientFactory().buildFrom(config.getP2PServerConfig());
return new RestPrivacyGroupPublisher(discovery, client);
}
use of com.quorum.tessera.discovery.Discovery in project tessera by ConsenSys.
the class PrivacyGroupPublisherProviderTest method provider.
@Test
public void provider() throws Exception {
Config config = mock(Config.class);
when(config.getP2PServerConfig()).thenReturn(mock(ServerConfig.class));
ConfigFactory configFactory = mock(ConfigFactory.class);
when(configFactory.getConfig()).thenReturn(config);
PrivacyGroupPublisher result;
try (var discoveryMockedStatic = mockStatic(Discovery.class);
var configFactoryMockedStatic = mockStatic(ConfigFactory.class)) {
discoveryMockedStatic.when(Discovery::create).thenReturn(mock(Discovery.class));
configFactoryMockedStatic.when(ConfigFactory::create).thenReturn(configFactory);
result = PrivacyGroupPublisherProvider.provider();
discoveryMockedStatic.verify(Discovery::create);
configFactoryMockedStatic.verify(ConfigFactory::create);
discoveryMockedStatic.verifyNoMoreInteractions();
configFactoryMockedStatic.verifyNoMoreInteractions();
}
assertThat(result).isNotNull();
}
use of com.quorum.tessera.discovery.Discovery in project tessera by ConsenSys.
the class DiscoveryProvider method provider.
/**
* @see java.util.ServiceLoader.Provider
*/
public static Discovery provider() {
final DiscoveryHolder discoveryHolder = DiscoveryHolder.create();
if (discoveryHolder.get().isPresent()) {
return discoveryHolder.get().get();
}
final NetworkStore networkStore = NetworkStore.getInstance();
final RuntimeContext runtimeContext = RuntimeContext.getInstance();
final Discovery discovery;
if (runtimeContext.isDisablePeerDiscovery()) {
final Set<NodeUri> knownNodes = runtimeContext.getPeers().stream().map(NodeUri::create).collect(Collectors.toUnmodifiableSet());
discovery = new DisabledAutoDiscovery(networkStore, knownNodes);
} else {
discovery = new AutoDiscovery(networkStore);
}
discoveryHolder.set(discovery);
return discovery;
}
use of com.quorum.tessera.discovery.Discovery in project tessera by ConsenSys.
the class DiscoveryHolderImplTest method getAndSet.
@Test
public void getAndSet() {
assertThat(discoveryHolder.get()).isEmpty();
Discovery discovery = mock(Discovery.class);
discoveryHolder.set(discovery);
assertThat(discoveryHolder.get()).containsSame(discovery);
}
Aggregations