use of com.quorum.tessera.api.SendRequest in project tessera by ConsenSys.
the class SendIT method sendToSingleRecipient.
/**
* Quorum sends transaction with single public recipient key
*/
@Test
public void sendToSingleRecipient() {
Party firstParty = partyHelper.findByAlias(NodeAlias.A);
Party secondParty = partyHelper.findByAlias(NodeAlias.B);
byte[] transactionData = utils.createTransactionData();
final SendRequest sendRequest = new SendRequest();
sendRequest.setFrom(firstParty.getPublicKey());
sendRequest.setTo(secondParty.getPublicKey());
sendRequest.setPayload(transactionData);
final Response response = firstParty.getRestClient().target(firstParty.getQ2TUri()).path(SEND_PATH).request().post(Entity.entity(sendRequest, MIME_TYPE_JSON_2_1));
// validate result
final SendResponse result = response.readEntity(SendResponse.class);
assertThat(result.getKey()).isNotNull().isNotBlank();
assertThat(result.getManagedParties()).containsExactlyInAnyOrder(firstParty.getPublicKey());
assertThat(result.getSenderKey()).isEqualTo(firstParty.getPublicKey());
assertThat(response).isNotNull();
assertThat(response.getStatus()).isEqualTo(201);
URI location = response.getLocation();
final Response checkPersistedTxnResponse = secondParty.getRestClient().target(location).request().get();
assertThat(checkPersistedTxnResponse.getStatus()).isEqualTo(200);
ReceiveResponse receiveResponse = checkPersistedTxnResponse.readEntity(ReceiveResponse.class);
assertThat(receiveResponse.getPayload()).describedAs("The response payload should be equal to the sent txn data").isEqualTo(transactionData);
utils.findTransaction(result.getKey(), partyHelper.findByAlias("A"), partyHelper.findByAlias("B")).forEach(r -> assertThat(r.getStatus()).isEqualTo(200));
utils.findTransaction(result.getKey(), partyHelper.findByAlias("D")).forEach(r -> assertThat(r.getStatus()).isEqualTo(404));
}
use of com.quorum.tessera.api.SendRequest in project tessera by ConsenSys.
the class PrivacyIT method updateExistingContractByParticipant.
@Test
public void updateExistingContractByParticipant() {
final String originalHash = sendContractCreationTransaction(PrivacyMode.PARTY_PROTECTION);
Party sender = partyHelper.findByAlias(NodeAlias.B);
SendRequest sendRequest = new SendRequest();
sendRequest.setPayload(new RestUtils().createTransactionData());
sendRequest.setFrom(sender.getPublicKey());
List<String> recipientList = List.of(partyHelper.findByAlias(NodeAlias.A).getPublicKey());
sendRequest.setTo(recipientList.toArray(new String[recipientList.size()]));
sendRequest.setPrivacyFlag(PrivacyMode.PARTY_PROTECTION.getPrivacyFlag());
sendRequest.setAffectedContractTransactions(originalHash);
Response response = sender.getRestClientWebTarget().path("send").request().post(Entity.entity(sendRequest, MediaType.APPLICATION_JSON));
assertThat(response.getStatus()).isEqualTo(201);
}
use of com.quorum.tessera.api.SendRequest in project tessera by ConsenSys.
the class PrivacyIT method enhancedPrivacyTransactionsNotEnabled.
@Test
public void enhancedPrivacyTransactionsNotEnabled() {
Party legacySender = partyHelper.findByAlias(NodeAlias.D);
SendRequest sendRequest = new SendRequest();
sendRequest.setPayload(new RestUtils().createTransactionData());
sendRequest.setFrom(legacySender.getPublicKey());
List<String> recipientList = List.of(partyHelper.findByAlias(NodeAlias.A).getPublicKey());
sendRequest.setTo(recipientList.toArray(new String[recipientList.size()]));
sendRequest.setPrivacyFlag(PrivacyMode.PARTY_PROTECTION.getPrivacyFlag());
sendRequest.setAffectedContractTransactions(new String[0]);
Response response = legacySender.getRestClientWebTarget().path("send").request().post(Entity.entity(sendRequest, MediaType.APPLICATION_JSON));
assertThat(response.getStatus()).isEqualTo(403);
}
use of com.quorum.tessera.api.SendRequest in project tessera by ConsenSys.
the class PrivacyIT method updateExistingContractByNonParticipant.
@Test
public void updateExistingContractByNonParticipant() {
final String originalHash = sendContractCreationTransaction(PrivacyMode.PARTY_PROTECTION);
Party sender = partyHelper.findByAlias(NodeAlias.C);
SendRequest sendRequest = new SendRequest();
sendRequest.setPayload(new RestUtils().createTransactionData());
sendRequest.setFrom(sender.getPublicKey());
List<String> recipientList = List.of(partyHelper.findByAlias(NodeAlias.B).getPublicKey());
sendRequest.setTo(recipientList.toArray(new String[recipientList.size()]));
sendRequest.setPrivacyFlag(PrivacyMode.PARTY_PROTECTION.getPrivacyFlag());
sendRequest.setAffectedContractTransactions(originalHash);
Response response = sender.getRestClientWebTarget().path("send").request().post(Entity.entity(sendRequest, MediaType.APPLICATION_JSON));
assertThat(response.getStatus()).isEqualTo(403);
}
use of com.quorum.tessera.api.SendRequest in project tessera by ConsenSys.
the class PrivacyIT method targetedNodeDoesNotHaveEnhancedPrivacyEnabled.
@Test
public void targetedNodeDoesNotHaveEnhancedPrivacyEnabled() {
Party sender = partyHelper.findByAlias(NodeAlias.A);
SendRequest sendRequest = new SendRequest();
sendRequest.setPayload(new RestUtils().createTransactionData());
sendRequest.setFrom(sender.getPublicKey());
List<String> recipientList = List.of(partyHelper.findByAlias(NodeAlias.D).getPublicKey());
sendRequest.setTo(recipientList.toArray(new String[recipientList.size()]));
sendRequest.setPrivacyFlag(PrivacyMode.PARTY_PROTECTION.getPrivacyFlag());
sendRequest.setAffectedContractTransactions(new String[0]);
Response response = sender.getRestClientWebTarget().path("send").request().post(Entity.entity(sendRequest, MediaType.APPLICATION_JSON));
assertThat(response.getStatus()).isEqualTo(500);
}
Aggregations