use of com.quorum.tessera.api.BesuReceiveResponse in project tessera by ConsenSys.
the class BesuTransactionResourceTest method receive.
@Test
public void receive() {
String key = Base64.getEncoder().encodeToString("KEY".getBytes());
ReceiveRequest receiveRequest = new ReceiveRequest();
receiveRequest.setKey(key);
String recipient = Base64.getEncoder().encodeToString("Bobby Sixkiller".getBytes());
receiveRequest.setTo(recipient);
ReceiveResponse receiveResponse = mock(ReceiveResponse.class);
when(receiveResponse.getAffectedTransactions()).thenReturn(Set.of());
when(receiveResponse.getUnencryptedTransactionData()).thenReturn("Result".getBytes());
when(receiveResponse.getPrivacyMode()).thenReturn(PrivacyMode.STANDARD_PRIVATE);
when(receiveResponse.sender()).thenReturn(PublicKey.from("sender".getBytes()));
when(receiveResponse.getPrivacyGroupId()).thenReturn(Optional.of(PrivacyGroup.Id.fromBytes("group".getBytes())));
when(transactionManager.receive(any(com.quorum.tessera.transaction.ReceiveRequest.class))).thenReturn(receiveResponse);
BesuTransactionResource resource = new BesuTransactionResource(transactionManager, privacyGroupManager);
final Response result = resource.receive(receiveRequest);
assertThat(result.getStatus()).isEqualTo(200);
BesuReceiveResponse resultResponse = (BesuReceiveResponse) result.getEntity();
assertThat(resultResponse.getPayload()).isEqualTo("Result".getBytes());
assertThat(resultResponse.getSenderKey()).isEqualTo(PublicKey.from("sender".getBytes()).encodeToBase64());
assertThat(resultResponse.getPrivacyGroupId()).isEqualTo(PublicKey.from("group".getBytes()).encodeToBase64());
verify(transactionManager).receive(any(com.quorum.tessera.transaction.ReceiveRequest.class));
}
use of com.quorum.tessera.api.BesuReceiveResponse in project tessera by ConsenSys.
the class BesuTransactionResourceTest method receiveWithRecipient.
@Test
public void receiveWithRecipient() {
String key = Base64.getEncoder().encodeToString("KEY".getBytes());
ReceiveRequest receiveRequest = new ReceiveRequest();
receiveRequest.setKey(key);
receiveRequest.setTo(Base64.getEncoder().encodeToString("Reno Raynes".getBytes()));
ReceiveResponse receiveResponse = mock(ReceiveResponse.class);
when(receiveResponse.getPrivacyMode()).thenReturn(PrivacyMode.STANDARD_PRIVATE);
when(transactionManager.receive(any())).thenReturn(receiveResponse);
when(receiveResponse.getUnencryptedTransactionData()).thenReturn("Result".getBytes());
when(receiveResponse.sender()).thenReturn(PublicKey.from("sender".getBytes()));
when(receiveResponse.getPrivacyGroupId()).thenReturn(Optional.of(PrivacyGroup.Id.fromBytes("group".getBytes())));
BesuTransactionResource resource = new BesuTransactionResource(transactionManager, privacyGroupManager);
final Response result = resource.receive(receiveRequest);
assertThat(result.getStatus()).isEqualTo(200);
BesuReceiveResponse resultResponse = (BesuReceiveResponse) result.getEntity();
assertThat(resultResponse.getPayload()).isEqualTo("Result".getBytes());
assertThat(resultResponse.getSenderKey()).isEqualTo(PublicKey.from("sender".getBytes()).encodeToBase64());
assertThat(resultResponse.getPrivacyGroupId()).isEqualTo(PublicKey.from("group".getBytes()).encodeToBase64());
verify(transactionManager).receive(any(com.quorum.tessera.transaction.ReceiveRequest.class));
}
Aggregations