Search in sources :

Example 21 with RuntimeContext

use of com.quorum.tessera.context.RuntimeContext in project tessera by ConsenSys.

the class DiscoveryProviderTest method provideAutoDiscovery.

@Test
public void provideAutoDiscovery() {
    when(runtimeContext.isDisablePeerDiscovery()).thenReturn(false);
    Discovery discovery = DiscoveryProvider.provider();
    assertThat(discovery).isNotNull().isExactlyInstanceOf(AutoDiscovery.class);
    verify(discoveryHolder).get();
    verify(discoveryHolder).set(discovery);
    discoveryHolderMockedStatic.verify(DiscoveryHolder::create);
    verify(runtimeContext).isDisablePeerDiscovery();
    mockedRuntimeContext.verify(RuntimeContext::getInstance);
}
Also used : Discovery(com.quorum.tessera.discovery.Discovery) RuntimeContext(com.quorum.tessera.context.RuntimeContext) Test(org.junit.Test)

Example 22 with RuntimeContext

use of com.quorum.tessera.context.RuntimeContext in project tessera by ConsenSys.

the class DiscoveryProviderTest method provideDisabledAutoDiscovery.

@Test
public void provideDisabledAutoDiscovery() {
    when(runtimeContext.isDisablePeerDiscovery()).thenReturn(true);
    Discovery discovery = DiscoveryProvider.provider();
    assertThat(discovery).isNotNull().isExactlyInstanceOf(DisabledAutoDiscovery.class);
    verify(discoveryHolder).get();
    verify(discoveryHolder).set(discovery);
    discoveryHolderMockedStatic.verify(DiscoveryHolder::create);
    verify(runtimeContext).isDisablePeerDiscovery();
    verify(runtimeContext).getPeers();
    mockedRuntimeContext.verify(RuntimeContext::getInstance);
}
Also used : Discovery(com.quorum.tessera.discovery.Discovery) RuntimeContext(com.quorum.tessera.context.RuntimeContext) Test(org.junit.Test)

Example 23 with RuntimeContext

use of com.quorum.tessera.context.RuntimeContext in project tessera by ConsenSys.

the class EnclaveKeySynchroniserTest method syncWithKeysWithoutAnyActiveNodes.

@Test
public void syncWithKeysWithoutAnyActiveNodes() {
    final URI uri = URI.create("http://somedomain.com/");
    when(runtimeContext.getP2pServerUri()).thenReturn(uri);
    when(networkStore.getActiveNodes()).thenReturn(Stream.of());
    enclaveKeySynchroniser.syncKeys();
    verify(runtimeContext).getP2pServerUri();
    verify(networkStore).getActiveNodes();
    mockedStaticRuntimeContext.verify(RuntimeContext::getInstance);
}
Also used : RuntimeContext(com.quorum.tessera.context.RuntimeContext) URI(java.net.URI) Test(org.junit.Test)

Example 24 with RuntimeContext

use of com.quorum.tessera.context.RuntimeContext in project tessera by ConsenSys.

the class EnclaveKeySynchroniserTest method syncWithChanges.

@Test
public void syncWithChanges() {
    URI uri = URI.create("http://somedomain.com/");
    when(runtimeContext.getP2pServerUri()).thenReturn(uri);
    NodeUri nodeUri = NodeUri.create(uri);
    Set<PublicKey> newKeys = Set.of(mock(PublicKey.class));
    ActiveNode activeNode = mock(ActiveNode.class);
    when(activeNode.getUri()).thenReturn(nodeUri);
    when(activeNode.getKeys()).thenReturn(newKeys);
    when(networkStore.getActiveNodes()).thenReturn(Stream.of(activeNode));
    when(enclave.getPublicKeys()).thenReturn(Set.of(mock(PublicKey.class)));
    enclaveKeySynchroniser.syncKeys();
    verify(runtimeContext).getP2pServerUri();
    verify(networkStore).getActiveNodes();
    verify(enclave).getPublicKeys();
    verify(networkStore).store(any(ActiveNode.class));
    mockedStaticRuntimeContext.verify(RuntimeContext::getInstance);
}
Also used : PublicKey(com.quorum.tessera.encryption.PublicKey) NodeUri(com.quorum.tessera.discovery.NodeUri) ActiveNode(com.quorum.tessera.discovery.ActiveNode) RuntimeContext(com.quorum.tessera.context.RuntimeContext) URI(java.net.URI) Test(org.junit.Test)

Example 25 with RuntimeContext

use of com.quorum.tessera.context.RuntimeContext in project tessera by ConsenSys.

the class EnclaveKeySynchroniserTest method syncKeysNoChanges.

@Test
public void syncKeysNoChanges() {
    URI uri = URI.create("http://somedomain.com/");
    when(runtimeContext.getP2pServerUri()).thenReturn(uri);
    NodeUri nodeUri = NodeUri.create(uri);
    Set<PublicKey> keys = Set.of(mock(PublicKey.class));
    ActiveNode activeNode = mock(ActiveNode.class);
    when(activeNode.getKeys()).thenReturn(keys);
    when(activeNode.getUri()).thenReturn(nodeUri);
    when(networkStore.getActiveNodes()).thenReturn(Stream.of(activeNode));
    when(enclave.getPublicKeys()).thenReturn(keys);
    enclaveKeySynchroniser.syncKeys();
    verify(runtimeContext).getP2pServerUri();
    verify(networkStore).getActiveNodes();
    verify(enclave).getPublicKeys();
    mockedStaticRuntimeContext.verify(RuntimeContext::getInstance);
}
Also used : PublicKey(com.quorum.tessera.encryption.PublicKey) NodeUri(com.quorum.tessera.discovery.NodeUri) ActiveNode(com.quorum.tessera.discovery.ActiveNode) RuntimeContext(com.quorum.tessera.context.RuntimeContext) URI(java.net.URI) Test(org.junit.Test)

Aggregations

RuntimeContext (com.quorum.tessera.context.RuntimeContext)33 Test (org.junit.Test)20 URI (java.net.URI)14 PublicKey (com.quorum.tessera.encryption.PublicKey)11 ActiveNode (com.quorum.tessera.discovery.ActiveNode)9 NodeUri (com.quorum.tessera.discovery.NodeUri)9 Enclave (com.quorum.tessera.enclave.Enclave)9 Discovery (com.quorum.tessera.discovery.Discovery)6 Set (java.util.Set)6 Stream (java.util.stream.Stream)6 NetworkStore (com.quorum.tessera.discovery.NetworkStore)5 NodeInfo (com.quorum.tessera.partyinfo.node.NodeInfo)5 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 Before (org.junit.Before)5 Response (jakarta.ws.rs.core.Response)4 TransactionManager (com.quorum.tessera.transaction.TransactionManager)3 Client (jakarta.ws.rs.client.Client)3 ConfigKeyPair (com.quorum.tessera.config.keypairs.ConfigKeyPair)2 KeyEncryptor (com.quorum.tessera.config.keys.KeyEncryptor)2