use of com.quorum.tessera.partyinfo.node.NodeInfo in project tessera by ConsenSys.
the class DisabledAutoDiscoveryTest method onUpdateFromKnownPeer.
@Test
public void onUpdateFromKnownPeer() {
NodeInfo nodeInfo = NodeInfo.Builder.create().withUrl(knownPeers.iterator().next().asString()).build();
discovery.onUpdate(nodeInfo);
verify(networkStore).store(any(ActiveNode.class));
}
use of com.quorum.tessera.partyinfo.node.NodeInfo 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.partyinfo.node.NodeInfo in project tessera by ConsenSys.
the class DiscoveryHelperTest method getCurrentWithNoKeys.
@Test
public void getCurrentWithNoKeys() {
final URI uri = URI.create("http://somedomain.com");
when(runtimeContext.getP2pServerUri()).thenReturn(uri);
final List<PublicKey> keys = List.of();
final ActiveNode activeNode = ActiveNode.Builder.create().withUri(NodeUri.create(uri)).withKeys(keys).build();
when(networkStore.getActiveNodes()).thenReturn(Stream.of(activeNode));
NodeInfo result = discoveryHelper.buildCurrent();
assertThat(result).isNotNull();
verify(runtimeContext).getP2pServerUri();
assertThat(result.getUrl()).isEqualTo("http://somedomain.com/");
verify(networkStore).getActiveNodes();
assertThat(result.getRecipients()).isEmpty();
mockedRuntimeContext.verify(RuntimeContext::getInstance);
}
use of com.quorum.tessera.partyinfo.node.NodeInfo in project tessera by ConsenSys.
the class FindRecipientFromPartyInfoTest method executeKeyNotFound.
@Test
public void executeKeyNotFound() {
BatchWorkflowContext batchWorkflowContext = new BatchWorkflowContext();
PublicKey publicKey = mock(PublicKey.class);
batchWorkflowContext.setRecipientKey(publicKey);
NodeInfo nodeInfo = mock(NodeInfo.class);
Recipient recipient = mock(Recipient.class);
when(recipient.getKey()).thenReturn(mock(PublicKey.class));
when(nodeInfo.getRecipients()).thenReturn(Set.of(recipient));
when(discovery.getCurrent()).thenReturn(nodeInfo);
try {
findRecipientFromPartyInfo.execute(batchWorkflowContext);
failBecauseExceptionWasNotThrown(KeyNotFoundException.class);
} catch (KeyNotFoundException ex) {
verify(discovery).getCurrent();
assertThat(batchWorkflowContext.getRecipient()).isNull();
assertThat(batchWorkflowContext.getRecipientKey()).isSameAs(publicKey);
}
}
use of com.quorum.tessera.partyinfo.node.NodeInfo in project tessera by ConsenSys.
the class PartyInfoServiceUtilTest method validateEmptyRecipientListsAsValid.
@Test
public void validateEmptyRecipientListsAsValid() {
final String url = "http://somedomain.com";
final Set<Recipient> newRecipients = Set.of();
final NodeInfo existingPartyInfo = NodeInfo.Builder.create().withRecipients(newRecipients).withUrl(url).build();
final NodeInfo newPartyInfo = NodeInfo.Builder.create().withUrl(url).withRecipients(newRecipients).build();
assertThat(PartyInfoServiceUtil.validateKeysToUrls(existingPartyInfo, newPartyInfo)).isTrue();
}
Aggregations