use of com.quorum.tessera.enclave.PrivacyMode in project tessera by ConsenSys.
the class RestPayloadPublisherTest method publishEnhancedTransactionsToNodesThatDoNotSupport.
@Test
public void publishEnhancedTransactionsToNodesThatDoNotSupport() {
Map<PrivacyMode, Set<String>> privacyModeAndVersions = new HashMap<>();
privacyModeAndVersions.put(PrivacyMode.PARTY_PROTECTION, Set.of("v1"));
privacyModeAndVersions.put(PrivacyMode.PRIVATE_STATE_VALIDATION, Set.of("v1"));
for (Map.Entry<PrivacyMode, Set<String>> pair : privacyModeAndVersions.entrySet()) {
String targetUrl = "http://someplace.com";
EncodedPayload encodedPayload = mock(EncodedPayload.class);
when(encodedPayload.getPrivacyMode()).thenReturn(pair.getKey());
byte[] payloadData = "Some Data".getBytes();
when(payloadEncoder.encode(encodedPayload)).thenReturn(payloadData);
PublicKey recipientKey = mock(PublicKey.class);
NodeInfo nodeInfo = mock(NodeInfo.class);
when(nodeInfo.supportedApiVersions()).thenReturn(pair.getValue());
Recipient recipient = mock(Recipient.class);
when(recipient.getKey()).thenReturn(recipientKey);
when(recipient.getUrl()).thenReturn(targetUrl);
when(nodeInfo.getRecipients()).thenReturn(Set.of(recipient));
when(discovery.getRemoteNodeInfo(recipientKey)).thenReturn(nodeInfo);
EnhancedPrivacyNotSupportedException exception = catchThrowableOfType(() -> payloadPublisher.publishPayload(encodedPayload, recipientKey), EnhancedPrivacyNotSupportedException.class);
assertThat(exception).hasMessageContaining("Transactions with enhanced privacy is not currently supported");
verify(discovery).getRemoteNodeInfo(eq(recipientKey));
}
payloadEncoderFactoryFunction.verify(times(2), () -> PayloadEncoder.create(any(EncodedPayloadCodec.class)));
}
Aggregations