use of com.quorum.tessera.encryption.PublicKey in project tessera by ConsenSys.
the class ActiveNodeTest method createWithEverything.
@Test
public void createWithEverything() {
final NodeUri nodeUri = NodeUri.create(URI);
final PublicKey publicKey = mock(PublicKey.class);
final List<String> supportedVersions = List.of("One", "Two");
final List<PublicKey> keys = List.of(publicKey);
final ActiveNode activeNode = ActiveNode.Builder.create().withUri(nodeUri).withKeys(keys).withSupportedVersions(supportedVersions).build();
assertThat(activeNode).isNotNull();
assertThat(activeNode.getKeys()).containsExactly(publicKey);
assertThat(activeNode.getSupportedVersions()).containsExactlyInAnyOrderElementsOf(supportedVersions);
assertThat(activeNode.getUri()).isSameAs(nodeUri);
}
use of com.quorum.tessera.encryption.PublicKey in project tessera by ConsenSys.
the class ActiveNodeTest method createOnlyWithKeys.
@Test
public void createOnlyWithKeys() {
final NodeUri nodeUri = NodeUri.create(URI);
final PublicKey publicKey = mock(PublicKey.class);
final List<PublicKey> keys = List.of(publicKey);
final ActiveNode activeNode = ActiveNode.Builder.create().withUri(nodeUri).withKeys(keys).build();
assertThat(activeNode).isNotNull();
assertThat(activeNode.getKeys()).containsExactly(publicKey);
assertThat(activeNode.getSupportedVersions()).isEmpty();
assertThat(activeNode.getUri()).isSameAs(nodeUri);
}
use of com.quorum.tessera.encryption.PublicKey in project tessera by ConsenSys.
the class DiscoveryTest method getRemoteNodeInfo.
@Test
public void getRemoteNodeInfo() {
PublicKey publicKey = mock(PublicKey.class);
discovery.getRemoteNodeInfo(publicKey);
verify(discoveryHelper).buildRemoteNodeInfo(publicKey);
mockedStaticDiscoveryHelper.verify(DiscoveryHelper::create);
}
use of com.quorum.tessera.encryption.PublicKey in project tessera by ConsenSys.
the class AutoDiscoveryTest method onUpdateSendHasTwoKeys.
@Test
public void onUpdateSendHasTwoKeys() {
String uri = "http://mynode.com";
PublicKey key = mock(PublicKey.class);
Recipient recipient = Recipient.of(key, uri);
PublicKey otherKey = mock(PublicKey.class);
Recipient other = Recipient.of(otherKey, uri);
List<Recipient> recipients = List.of(recipient, other);
NodeInfo nodeInfo = NodeInfo.Builder.create().withUrl(uri).withRecipients(recipients).build();
List<ActiveNode> storedNodes = new ArrayList<>();
doAnswer(invocation -> {
storedNodes.add(invocation.getArgument(0));
return null;
}).when(networkStore).store(any(ActiveNode.class));
discovery.onUpdate(nodeInfo);
assertThat(storedNodes).hasSize(1);
ActiveNode result = storedNodes.iterator().next();
assertThat(result.getUri()).isEqualTo(NodeUri.create(uri));
assertThat(result.getKeys()).containsExactlyInAnyOrder(key, otherKey);
verify(networkStore).store(any(ActiveNode.class));
}
use of com.quorum.tessera.encryption.PublicKey in project tessera by ConsenSys.
the class DisabledAutoDiscoveryTest method onUpdateIgnoreKeysNotOwnedBySender.
@Test
public void onUpdateIgnoreKeysNotOwnedBySender() {
String uri = "http://renoraynes.com";
PublicKey key = mock(PublicKey.class);
PublicKey key2 = mock(PublicKey.class);
Recipient recipient = Recipient.of(key, uri);
Recipient other = Recipient.of(key2, "http://othernode.com");
List<Recipient> recipients = List.of(recipient, other);
NodeInfo nodeInfo = NodeInfo.Builder.create().withUrl(uri).withRecipients(recipients).withSupportedApiVersions(List.of("Two", "Fifty")).build();
List<ActiveNode> storedNodes = new ArrayList<>();
doAnswer(invocation -> {
storedNodes.add(invocation.getArgument(0));
return null;
}).when(networkStore).store(any(ActiveNode.class));
discovery.onUpdate(nodeInfo);
assertThat(storedNodes).hasSize(1);
ActiveNode result = storedNodes.iterator().next();
assertThat(result.getUri()).isEqualTo(NodeUri.create(uri));
assertThat(result.getKeys()).containsExactly(key);
assertThat(result.getSupportedVersions()).containsExactlyInAnyOrder("Two", "Fifty");
verify(networkStore).store(any(ActiveNode.class));
}
Aggregations