Use send rest call for setup logic to address flakey test.
package com.quorum.tessera.test.rest;
-import static com.quorum.tessera.test.Fixtures.*;
+import com.quorum.tessera.api.model.SendResponse;
import org.junit.Test;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.UnsupportedEncodingException;
-import java.net.URI;
import java.net.URLEncoder;
import java.util.Base64;
-
+import com.quorum.tessera.test.*;
import static java.nio.charset.StandardCharsets.UTF_8;
+import java.util.Collections;
import static org.assertj.core.api.Assertions.assertThat;
public class DeleteIT {
- private static final URI SERVER_URI = NODE1_URI;
-
- private static final Client client = ClientBuilder.newClient();
+ private final PartyHelper partyHelper = new RestPartyHelper();
@Test
public void deleteTransactionThatExists() throws UnsupportedEncodingException {
//setup (sending in a tx)
- final String hash = client.target(SERVER_URI)
- .path("/sendraw")
- .request()
- .header("c11n-from", PTY1_KEY)
- .header("c11n-to", PTY2_KEY)
- .post(Entity.entity(TXN_DATA, MediaType.APPLICATION_OCTET_STREAM))
- .readEntity(String.class);
- final String encodedHash = URLEncoder.encode(hash, UTF_8.toString());
+ Party sender = partyHelper.getParties().findAny().get();
+
+ Party recipient = partyHelper.getParties()
+ .filter(p -> !p.getPublicKey().equals(sender.getPublicKey())).findAny().get();
+
+ RestUtils utils = new RestUtils();
+ byte[] txnData = utils.createTransactionData();
+ Response response = utils.send(sender, txnData, Collections.singleton(recipient));
+ assertThat(response.getStatus()).isEqualTo(201);
+
+ final SendResponse sendResponse = response.readEntity(SendResponse.class);
+
+ final String encodedHash = URLEncoder.encode(sendResponse.getKey(), UTF_8.toString());
+
+ Client client = ClientBuilder.newClient();
//delete it
- final Response resp = client.target(SERVER_URI)
+ final Response resp = client.target(sender.getUri())
.path("transaction")
.path(encodedHash)
.request()
@@ -53,7 +56,11 @@ public class DeleteIT {
final String madeupHash = Base64.getUrlEncoder().encodeToString("madeup".getBytes());
- final Response response = client.target(SERVER_URI)
+ Client client = ClientBuilder.newClient();
+
+ Party party = partyHelper.getParties().findAny().get();
+
+ final Response response = client.target(party.getUri())
.path("transaction")
.path(madeupHash)
.request()
