use of com.quorum.tessera.encryption.PublicKey in project tessera by ConsenSys.
the class SendRequestTest method buildWithInvalidExecHash.
@Test(expected = RuntimeException.class)
public void buildWithInvalidExecHash() {
byte[] payload = "Payload".getBytes();
PublicKey sender = mock(PublicKey.class);
SendRequest.Builder.create().withPayload(payload).withSender(sender).withRecipients(Collections.emptyList()).withAffectedContractTransactions(Collections.emptySet()).withPrivacyMode(PrivacyMode.PRIVATE_STATE_VALIDATION).withExecHash(new byte[0]).build();
}
use of com.quorum.tessera.encryption.PublicKey in project tessera by ConsenSys.
the class SendRequestTest method buildWithMandatoryRecipients.
@Test
public void buildWithMandatoryRecipients() {
byte[] payload = "Payload".getBytes();
PublicKey sender = mock(PublicKey.class);
PrivacyGroup.Id groupId = mock(PrivacyGroup.Id.class);
List<PublicKey> recipients = List.of(mock(PublicKey.class));
MessageHash affectedTransaction = mock(MessageHash.class);
SendRequest sendRequest = SendRequest.Builder.create().withPayload(payload).withSender(sender).withRecipients(recipients).withPrivacyMode(PrivacyMode.MANDATORY_RECIPIENTS).withMandatoryRecipients(Set.of(PublicKey.from("key".getBytes()))).withAffectedContractTransactions(Set.of(affectedTransaction)).withPrivacyGroupId(groupId).build();
assertThat(sendRequest).isNotNull();
assertThat(sendRequest.getSender()).isSameAs(sender);
assertThat(sendRequest.getPayload()).containsExactly(payload);
assertThat(sendRequest.getRecipients()).containsAll(recipients);
assertThat(sendRequest.getPrivacyMode()).isEqualTo(PrivacyMode.MANDATORY_RECIPIENTS);
assertThat(sendRequest.getAffectedContractTransactions()).containsExactly(affectedTransaction);
assertThat(sendRequest.getMandatoryRecipients()).containsExactly(PublicKey.from("key".getBytes()));
assertThat(sendRequest.getPrivacyGroupId()).isPresent().get().isSameAs(groupId);
}
use of com.quorum.tessera.encryption.PublicKey in project tessera by ConsenSys.
the class SendRequestTest method buildWithNoMandatoryRecipientsData.
@Test(expected = RuntimeException.class)
public void buildWithNoMandatoryRecipientsData() {
byte[] payload = "Payload".getBytes();
PublicKey sender = mock(PublicKey.class);
List<PublicKey> recipients = List.of(mock(PublicKey.class));
SendRequest.Builder.create().withPayload(payload).withSender(sender).withRecipients(recipients).withPrivacyMode(PrivacyMode.MANDATORY_RECIPIENTS).build();
}
use of com.quorum.tessera.encryption.PublicKey in project tessera by ConsenSys.
the class SendRequestTest method buildWithMandatoryRecipientsInvalid.
@Test(expected = RuntimeException.class)
public void buildWithMandatoryRecipientsInvalid() {
byte[] payload = "Payload".getBytes();
PublicKey sender = mock(PublicKey.class);
List<PublicKey> recipients = List.of(mock(PublicKey.class));
SendRequest.Builder.create().withPayload(payload).withSender(sender).withRecipients(recipients).withPrivacyMode(PrivacyMode.PARTY_PROTECTION).withMandatoryRecipients(Set.of(PublicKey.from("key".getBytes()))).build();
}
use of com.quorum.tessera.encryption.PublicKey in project tessera by ConsenSys.
the class SendRequestTest method buildWithEverything.
@Test
public void buildWithEverything() {
byte[] payload = "Payload".getBytes();
PublicKey sender = mock(PublicKey.class);
PrivacyGroup.Id groupId = mock(PrivacyGroup.Id.class);
List<PublicKey> recipients = List.of(mock(PublicKey.class));
MessageHash affectedTransaction = mock(MessageHash.class);
final byte[] execHash = "ExecHash".getBytes();
SendRequest sendRequest = SendRequest.Builder.create().withPayload(payload).withSender(sender).withRecipients(recipients).withPrivacyMode(PrivacyMode.PRIVATE_STATE_VALIDATION).withExecHash(execHash).withAffectedContractTransactions(Set.of(affectedTransaction)).withPrivacyGroupId(groupId).build();
assertThat(sendRequest).isNotNull();
assertThat(sendRequest.getSender()).isSameAs(sender);
assertThat(sendRequest.getPayload()).containsExactly(payload);
assertThat(sendRequest.getRecipients()).containsAll(recipients);
assertThat(sendRequest.getPrivacyMode()).isEqualTo(PrivacyMode.PRIVATE_STATE_VALIDATION);
assertThat(sendRequest.getExecHash()).containsExactly(execHash);
assertThat(sendRequest.getAffectedContractTransactions()).containsExactly(affectedTransaction);
assertThat(sendRequest.getPrivacyGroupId()).isPresent().get().isSameAs(groupId);
}
Aggregations