use of com.quorum.tessera.api.SendResponse in project tessera by ConsenSys.
the class ReceiveRawIT method beforeTest.
// Persist a single transaction that can be used later
@Before
public void beforeTest() {
this.partyOne = partyHelper.findByAlias(NodeAlias.A);
this.partyTwo = partyHelper.findByAlias(NodeAlias.B);
SendRequest sendRequest = new SendRequest();
sendRequest.setPayload(PAYLOAD);
sendRequest.setTo(partyTwo.getPublicKey());
sendRequest.setFrom(partyOne.getPublicKey());
final Response response = partyOne.getRestClient().target(partyOne.getQ2TUri()).path("/send").request().post(Entity.entity(sendRequest, MediaType.APPLICATION_JSON));
final SendResponse result = response.readEntity(SendResponse.class);
this.hash = result.getKey();
}
use of com.quorum.tessera.api.SendResponse in project tessera by ConsenSys.
the class SendIT method partyAlwaysSendsToPartyOne.
/**
* config3.json has party 1's key in always send to list
*/
@Test
public void partyAlwaysSendsToPartyOne() {
Party sender = partyHelper.findByAlias("C");
Party recipient = partyHelper.findByAlias("D");
byte[] transactionData = utils.createTransactionData();
final SendRequest sendRequest = new SendRequest();
sendRequest.setFrom(sender.getPublicKey());
sendRequest.setTo(recipient.getPublicKey());
sendRequest.setPayload(transactionData);
final Response response = sender.getRestClient().target(sender.getQ2TUri()).path(SEND_PATH).request().post(Entity.entity(sendRequest, MediaType.APPLICATION_JSON));
final SendResponse result = response.readEntity(SendResponse.class);
assertThat(result.getKey()).isNotNull().isNotBlank();
// Party one recieved by always send to
utils.findTransaction(result.getKey(), sender, recipient, partyHelper.findByAlias("A")).forEach(r -> {
assertThat(r.getStatus()).isEqualTo(200);
});
// Party 2 is out of the loop
utils.findTransaction(result.getKey(), partyHelper.findByAlias("B")).forEach(r -> {
assertThat(r.getStatus()).isEqualTo(404);
});
}
use of com.quorum.tessera.api.SendResponse in project tessera by ConsenSys.
the class SendIT method firstPartyForwardsToTwoOtherParties.
/**
* Quorum sends transaction with multiple public recipient keys
*/
@Test
public void firstPartyForwardsToTwoOtherParties() {
final Party sendingParty = partyHelper.findByAlias("A");
final Party secondParty = partyHelper.findByAlias("B");
final Party thirdParty = partyHelper.findByAlias("D");
final Party excludedParty = partyHelper.findByAlias("C");
final byte[] transactionData = utils.createTransactionData();
final SendRequest sendRequest = new SendRequest();
sendRequest.setFrom(sendingParty.getPublicKey());
sendRequest.setTo(secondParty.getPublicKey(), thirdParty.getPublicKey());
sendRequest.setPayload(transactionData);
final Response response = sendingParty.getRestClient().target(sendingParty.getQ2TUri()).path(SEND_PATH).request().post(Entity.entity(sendRequest, MediaType.APPLICATION_JSON));
//
final SendResponse result = response.readEntity(SendResponse.class);
assertThat(result.getKey()).isNotNull().isNotBlank();
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()).isEqualTo(transactionData);
utils.findTransaction(result.getKey(), sendingParty, secondParty, thirdParty).forEach(r -> {
assertThat(r.getStatus()).isEqualTo(200);
});
utils.findTransaction(result.getKey(), excludedParty).forEach(r -> {
assertThat(r.getStatus()).isEqualTo(404);
});
}
use of com.quorum.tessera.api.SendResponse in project tessera by ConsenSys.
the class SendIT method sendTransactionWithoutASender.
@Test
public void sendTransactionWithoutASender() {
Party recipient = partyHelper.getParties().findAny().get();
byte[] transactionData = utils.createTransactionData();
final SendRequest sendRequest = new SendRequest();
sendRequest.setTo(recipient.getPublicKey());
sendRequest.setPayload(transactionData);
final Response response = recipient.getRestClient().target(recipient.getQ2TUri()).path(SEND_PATH).request().post(Entity.entity(sendRequest, MediaType.APPLICATION_JSON));
final SendResponse result = response.readEntity(SendResponse.class);
assertThat(result.getKey()).isNotNull().isNotBlank();
assertThat(response).isNotNull();
assertThat(response.getStatus()).isEqualTo(201);
URI location = response.getLocation();
final Response checkPersistedTxnResponse = recipient.getRestClient().target(location).request().get();
assertThat(checkPersistedTxnResponse.getStatus()).isEqualTo(200);
ReceiveResponse receiveResponse = checkPersistedTxnResponse.readEntity(ReceiveResponse.class);
assertThat(receiveResponse.getPayload()).isEqualTo(transactionData);
}
use of com.quorum.tessera.api.SendResponse in project tessera by ConsenSys.
the class SendReceiveBesuIT method sendAndReceivePrivacyFor.
@Test
public void sendAndReceivePrivacyFor() throws InterruptedException {
final Party a = partyHelper.findByAlias("A");
final Party d = partyHelper.findByAlias("D");
byte[] transactionData = utils.createTransactionData();
final SendRequest sendRequest = new SendRequest();
sendRequest.setPayload(transactionData);
sendRequest.setTo(d.getPublicKey());
final Response response = client.target(a.getQ2TUri()).path("/send").request().post(Entity.entity(sendRequest, MediaType.APPLICATION_JSON));
assertThat(response).isNotNull();
assertThat(response.getStatus()).isEqualTo(200);
final SendResponse result = response.readEntity(SendResponse.class);
final String hash = result.getKey();
// Hash length = 32 bytes
assertThat(Base64.getDecoder().decode(hash)).hasSize(32);
String findOutput = privacyGroupTestUtil.find("A", "A", "D");
final JsonArray json = Json.createReader(new StringReader(findOutput)).readArray();
Optional<JsonObject> legacyGroup = json.getValuesAs(JsonObject.class).stream().filter(v -> v.getString("type").equals("LEGACY")).findAny();
// Legacy privacy group was created
assertThat(legacyGroup).isPresent();
final String groupId = legacyGroup.get().getString("privacyGroupId");
ReceiveRequest receiveRequest = new ReceiveRequest();
receiveRequest.setKey(hash);
final Response receiveResponse = client.target(a.getQ2TUri()).path("/receive").request().post(Entity.entity(receiveRequest, MediaType.APPLICATION_JSON));
// validate result
assertThat(receiveResponse).isNotNull();
assertThat(receiveResponse.getStatus()).isEqualTo(200);
final ReceiveResponse receiveResult = receiveResponse.readEntity(ReceiveResponse.class);
assertThat(receiveResult.getPayload()).isEqualTo(transactionData);
assertThat(receiveResult.getSenderKey()).isEqualTo(a.getPublicKey());
assertThat(receiveResult.getPrivacyGroupId()).isEqualTo(groupId);
final Response receiveResponseOnB = client.target(d.getQ2TUri()).path("/receive").request().post(Entity.entity(receiveRequest, MediaType.APPLICATION_JSON));
// validate result
assertThat(receiveResponseOnB).isNotNull();
assertThat(receiveResponseOnB.getStatus()).isEqualTo(200);
final ReceiveResponse receiveResultOnB = receiveResponseOnB.readEntity(ReceiveResponse.class);
assertThat(receiveResultOnB.getPayload()).isEqualTo(transactionData);
assertThat(receiveResultOnB.getSenderKey()).isEqualTo(a.getPublicKey());
assertThat(receiveResultOnB.getPrivacyGroupId()).isEqualTo(groupId);
}
Aggregations