Search in sources :

Example 1 with ExecutionContext

use of suite.ExecutionContext in project tessera by ConsenSys.

the class ConfigGenerator method main.

public static void main(String[] args) throws Exception {
    System.setProperty("jakarta.xml.bind.JAXBContextFactory", "org.eclipse.persistence.jaxb.JAXBContextFactory");
    System.setProperty("jakarta.xml.bind.context.factory", "org.eclipse.persistence.jaxb.JAXBContextFactory");
    ExecutionContext executionContext = ExecutionContext.Builder.create().with(CommunicationType.REST).with(DBType.H2).with(SocketType.UNIX).with(EnclaveType.LOCAL).prefix("p2p").build();
    Path path = ConfigGenerator.calculatePath(executionContext);
    List<Config> configs = new ConfigGenerator().createConfigs(executionContext);
    for (int i = 1; i <= configs.size(); i++) {
        String filename = String.format("config%d.json", i);
        Path outputFile = path.resolve(filename);
        System.out.println(outputFile);
    }
}
Also used : Path(java.nio.file.Path) ExecutionContext(suite.ExecutionContext)

Example 2 with ExecutionContext

use of suite.ExecutionContext in project tessera by ConsenSys.

the class SendRawIT method sendUnknownPublicKey.

/**
 * Quorum sends transaction with unknown public key
 */
@Test
public void sendUnknownPublicKey() {
    ExecutionContext executionContext = ExecutionContext.currentContext();
    final String unknownkey = generateValidButUnknownPublicKey(executionContext.getEncryptorType()).encodeToBase64();
    final Response response = client.target(sender.getQ2TUri()).path(SEND_PATH).request().header(SENDER, sender.getPublicKey()).header(RECIPIENTS, unknownkey).post(Entity.entity(TXN_DATA, MediaType.APPLICATION_OCTET_STREAM));
    assertThat(response).isNotNull();
    assertThat(response.getStatus()).isEqualTo(404);
}
Also used : Response(jakarta.ws.rs.core.Response) ReceiveResponse(com.quorum.tessera.api.ReceiveResponse) ExecutionContext(suite.ExecutionContext) Test(org.junit.Test)

Example 3 with ExecutionContext

use of suite.ExecutionContext in project tessera by ConsenSys.

the class SendIT method sendToUnknownPublicKey.

/**
 * Quorum sends transaction to unknown public key
 */
@Test
public void sendToUnknownPublicKey() {
    Party sendingParty = partyHelper.getParties().findAny().get();
    byte[] transactionData = utils.createTransactionData();
    final SendRequest sendRequest = new SendRequest();
    sendRequest.setFrom(sendingParty.getPublicKey());
    ExecutionContext executionContext = ExecutionContext.currentContext();
    final String unknownkey = generateValidButUnknownPublicKey(executionContext.getEncryptorType()).encodeToBase64();
    sendRequest.setTo(unknownkey);
    sendRequest.setPayload(transactionData);
    final Response response = sendingParty.getRestClient().target(sendingParty.getQ2TUri()).path(SEND_PATH).request().post(Entity.entity(sendRequest, MIME_TYPE_JSON_2_1));
    assertThat(response).isNotNull();
    assertThat(response.getStatus()).isEqualTo(404);
}
Also used : SendResponse(com.quorum.tessera.api.SendResponse) Response(jakarta.ws.rs.core.Response) ReceiveResponse(com.quorum.tessera.api.ReceiveResponse) Party(com.quorum.tessera.test.Party) SendRequest(com.quorum.tessera.api.SendRequest) ExecutionContext(suite.ExecutionContext) Test(org.junit.Test)

Example 4 with ExecutionContext

use of suite.ExecutionContext in project tessera by ConsenSys.

the class ConfigBuilder method main.

public static void main(String... args) throws Exception {
    System.setProperty("jakarta.xml.bind.JAXBContextFactory", "org.eclipse.persistence.jaxb.JAXBContextFactory");
    System.setProperty("jakarta.xml.bind.context.factory", "org.eclipse.persistence.jaxb.JAXBContextFactory");
    ExecutionContext executionContext = ExecutionContext.Builder.create().with(CommunicationType.REST).with(DBType.H2).with(SocketType.UNIX).with(EnclaveType.REMOTE).build();
    Config config = new ConfigBuilder().withExecutionContext(executionContext).withNodeId("mynode").withNodeNumber(1).withPeer("http://localhost:999").withKeys("/+UuD63zItL1EbjxkKUljMgG8Z1w0AJ8pNOR4iq2yQc=", "yAWAJjwPqUtNVlqGjSrBmr1/iIkghuOh1803Yzx9jLM=").withQt2Port(999).withP2pPort(888).withEnclavePort(989).build();
    JaxbUtil.marshalWithNoValidation(config, System.out);
}
Also used : ExecutionContext(suite.ExecutionContext)

Example 5 with ExecutionContext

use of suite.ExecutionContext in project tessera by ConsenSys.

the class SendIT method sendUnknownPublicKey.

/**
 * Quorum sends transaction with unknown public key
 */
@Test
public void sendUnknownPublicKey() {
    Party sendingParty = partyHelper.getParties().findAny().get();
    byte[] transactionData = utils.createTransactionData();
    final SendRequest sendRequest = new SendRequest();
    sendRequest.setFrom(sendingParty.getPublicKey());
    ExecutionContext executionContext = ExecutionContext.currentContext();
    final String unknownkey = generateValidButUnknownPublicKey(executionContext.getEncryptorType()).encodeToBase64();
    sendRequest.setTo(unknownkey);
    sendRequest.setPayload(transactionData);
    final Response response = sendingParty.getRestClient().target(sendingParty.getQ2TUri()).path(SEND_PATH).request().post(Entity.entity(sendRequest, MediaType.APPLICATION_JSON));
    assertThat(response).isNotNull();
    assertThat(response.getStatus()).isEqualTo(404);
}
Also used : SendResponse(com.quorum.tessera.api.SendResponse) Response(jakarta.ws.rs.core.Response) ReceiveResponse(com.quorum.tessera.api.ReceiveResponse) Party(com.quorum.tessera.test.Party) SendRequest(com.quorum.tessera.api.SendRequest) ExecutionContext(suite.ExecutionContext) Test(org.junit.Test)

Aggregations

ExecutionContext (suite.ExecutionContext)7 ReceiveResponse (com.quorum.tessera.api.ReceiveResponse)3 Response (jakarta.ws.rs.core.Response)3 Path (java.nio.file.Path)3 Test (org.junit.Test)3 SendRequest (com.quorum.tessera.api.SendRequest)2 SendResponse (com.quorum.tessera.api.SendResponse)2 Party (com.quorum.tessera.test.Party)2 HashMap (java.util.HashMap)2 AppType (com.quorum.tessera.config.AppType)1 EncryptorType (com.quorum.tessera.config.EncryptorType)1 DBType (com.quorum.tessera.test.DBType)1 ConfigDescriptor (config.ConfigDescriptor)1 URL (java.net.URL)1 Paths (java.nio.file.Paths)1 List (java.util.List)1 Map (java.util.Map)1 java.util.concurrent (java.util.concurrent)1 Collectors (java.util.stream.Collectors)1 Logger (org.slf4j.Logger)1