use of com.quorum.tessera.discovery.NetworkStore in project tessera by ConsenSys.
the class DiscoveryHelperTest method buildAllNodeInfosFilteredOutOwn.
@Test
public void buildAllNodeInfosFilteredOutOwn() {
when(runtimeContext.getP2pServerUri()).thenReturn(URI.create("http://node1.com"));
final ActiveNode node1 = ActiveNode.Builder.create().withUri(NodeUri.create("http://node1.com")).withKeys(List.of(PublicKey.from("key1".getBytes()))).withSupportedVersions(List.of("v1")).build();
final ActiveNode node2 = ActiveNode.Builder.create().withUri(NodeUri.create("http://node2.com")).withKeys(List.of(PublicKey.from("key2".getBytes()))).withSupportedVersions(List.of("v2")).build();
when(networkStore.getActiveNodes()).thenReturn(Stream.of(node1, node2));
final Set<NodeInfo> nodeInfos = discoveryHelper.buildRemoteNodeInfos();
assertThat(nodeInfos).hasSize(1);
Set<ActiveNode> activeNodes = nodeInfos.stream().map(nodeInfo -> ActiveNode.Builder.create().withUri(NodeUri.create(nodeInfo.getUrl())).withKeys(nodeInfo.getRecipients().stream().map(Recipient::getKey).collect(Collectors.toSet())).withSupportedVersions(nodeInfo.supportedApiVersions()).build()).collect(Collectors.toSet());
assertThat(activeNodes).containsExactlyInAnyOrder(node2);
verify(networkStore).getActiveNodes();
verify(runtimeContext).getP2pServerUri();
mockedRuntimeContext.verify(RuntimeContext::getInstance);
}
use of com.quorum.tessera.discovery.NetworkStore in project tessera by ConsenSys.
the class DiscoveryHelperProvider method provider.
public static DiscoveryHelper provider() {
LOGGER.debug("Creating network store");
final NetworkStore networkStore = NetworkStore.getInstance();
LOGGER.debug("Created network store {}", networkStore);
LOGGER.debug("Creating enclave");
Enclave enclave = Enclave.create();
LOGGER.debug("Created enclave {}", enclave);
return new DiscoveryHelperImpl(networkStore, enclave);
}
use of com.quorum.tessera.discovery.NetworkStore in project tessera by ConsenSys.
the class EnclaveKeySynchroniserProvider method provider.
public static EnclaveKeySynchroniser provider() {
LOGGER.debug("Creating Enclave");
Enclave enclave = Enclave.create();
LOGGER.debug("Created Enclave {}", enclave);
LOGGER.debug("Creating NetworkStore");
NetworkStore networkStore = NetworkStore.getInstance();
LOGGER.debug("Created NetworkStore");
return new EnclaveKeySynchroniserImpl(enclave, networkStore);
}
Aggregations