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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations