use of com.quorum.tessera.test.Party 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.test.Party in project tessera by ConsenSys.
the class MultipleKeyNodeIT method thenTransactionHasBeenPersistedOnOtherNode.
@Test
public void thenTransactionHasBeenPersistedOnOtherNode() throws UnsupportedEncodingException {
final byte[] transactionData = RestUtils.generateTransactionData();
Party recipient = partyHelper.findByAlias(recipientAlias);
// retrieve the transaction
final Response retrieveResponse = recipient.getRestClient().target(recipient.getQ2TUri()).path("transaction").path(URLEncoder.encode(txHash, "UTF-8")).queryParam("to", recipient.getPublicKey()).request().get();
assertThat(retrieveResponse).isNotNull();
assertThat(retrieveResponse.getStatus()).describedAs("%s should be present on other node", txHash).isEqualTo(200);
final ReceiveResponse result = retrieveResponse.readEntity(ReceiveResponse.class);
assertThat(result).isNotNull();
}
use of com.quorum.tessera.test.Party in project tessera by ConsenSys.
the class MultipleKeyNodeIT method onSetUp.
@Before
public void onSetUp() {
Party sender = partyHelper.findByAlias(NodeAlias.A);
Party recipient = partyHelper.findByAlias(recipientAlias);
byte[] transactionData = restUtils.createTransactionData();
final SendResponse result = restUtils.sendRequestAssertSuccess(sender, transactionData, recipient);
assertThat(result.getKey()).isNotBlank();
this.txHash = result.getKey();
}
use of com.quorum.tessera.test.Party in project tessera by ConsenSys.
the class PrivacyGroupTestUtil method find.
public String find(String targetNode, String... aliases) {
JsonArrayBuilder members = Json.createArrayBuilder();
Stream.of(aliases).map(partyHelper::findByAlias).map(Party::getPublicKey).forEach(members::add);
JsonObject json = Json.createObjectBuilder().add("addresses", members).build();
Party node = partyHelper.findByAlias(targetNode);
final Response response = node.getRestClient().target(node.getQ2TUri()).path("/findPrivacyGroup").request().post(Entity.entity(json, MediaType.APPLICATION_JSON));
assertThat(response.getStatus()).isEqualTo(200);
return response.readEntity(String.class);
}
use of com.quorum.tessera.test.Party in project tessera by ConsenSys.
the class PrivacyGroupTestUtil method retrieve.
public String retrieve(String targetNode, String groupId) {
JsonObject reqJson = Json.createObjectBuilder().add("privacyGroupId", groupId).build();
Party node = partyHelper.findByAlias(targetNode);
final Response response = node.getRestClient().target(node.getQ2TUri()).path("/retrievePrivacyGroup").request().post(Entity.entity(reqJson, MediaType.APPLICATION_JSON));
assertThat(response.getStatus()).isEqualTo(200);
return response.readEntity(String.class);
}
Aggregations