Search in sources :

Example 1 with Discovery

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);
}
Also used : Config(com.quorum.tessera.config.Config) Discovery(com.quorum.tessera.discovery.Discovery) ClientFactory(com.quorum.tessera.jaxrs.client.ClientFactory) Client(jakarta.ws.rs.client.Client)

Example 2 with Discovery

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);
}
Also used : Config(com.quorum.tessera.config.Config) Discovery(com.quorum.tessera.discovery.Discovery) ClientFactory(com.quorum.tessera.jaxrs.client.ClientFactory) Client(jakarta.ws.rs.client.Client)

Example 3 with Discovery

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();
}
Also used : ServerConfig(com.quorum.tessera.config.ServerConfig) Config(com.quorum.tessera.config.Config) ServerConfig(com.quorum.tessera.config.ServerConfig) Discovery(com.quorum.tessera.discovery.Discovery) PrivacyGroupPublisher(com.quorum.tessera.privacygroup.publish.PrivacyGroupPublisher) ConfigFactory(com.quorum.tessera.config.ConfigFactory) Test(org.junit.Test)

Example 4 with Discovery

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;
}
Also used : Discovery(com.quorum.tessera.discovery.Discovery) NetworkStore(com.quorum.tessera.discovery.NetworkStore) NodeUri(com.quorum.tessera.discovery.NodeUri) RuntimeContext(com.quorum.tessera.context.RuntimeContext)

Example 5 with 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);
}
Also used : Discovery(com.quorum.tessera.discovery.Discovery) Test(org.junit.Test)

Aggregations

Discovery (com.quorum.tessera.discovery.Discovery)20 Test (org.junit.Test)9 Enclave (com.quorum.tessera.enclave.Enclave)8 RuntimeContext (com.quorum.tessera.context.RuntimeContext)6 Config (com.quorum.tessera.config.Config)5 TransactionManager (com.quorum.tessera.transaction.TransactionManager)5 NodeUri (com.quorum.tessera.discovery.NodeUri)3 ResendBatchPublisher (com.quorum.tessera.recovery.resend.ResendBatchPublisher)3 LegacyResendManager (com.quorum.tessera.recovery.workflow.LegacyResendManager)3 PayloadPublisher (com.quorum.tessera.transaction.publish.PayloadPublisher)3 Objects (java.util.Objects)3 ConfigFactory (com.quorum.tessera.config.ConfigFactory)2 ServerConfig (com.quorum.tessera.config.ServerConfig)2 EncryptedTransactionDAO (com.quorum.tessera.data.EncryptedTransactionDAO)2 StagingEntityDAO (com.quorum.tessera.data.staging.StagingEntityDAO)2 ClientFactory (com.quorum.tessera.jaxrs.client.ClientFactory)2 PartyStore (com.quorum.tessera.p2p.partyinfo.PartyStore)2 PrivacyGroupManager (com.quorum.tessera.privacygroup.PrivacyGroupManager)2 BatchTransactionRequester (com.quorum.tessera.recovery.resend.BatchTransactionRequester)2 BatchResendManager (com.quorum.tessera.recovery.workflow.BatchResendManager)2