Search in sources :

Example 1 with StoreRawRequest

use of com.quorum.tessera.api.StoreRawRequest in project tessera by ConsenSys.

the class RawTransactionResourceTest method store.

@Test
public void store() {
    com.quorum.tessera.transaction.StoreRawResponse response = mock(com.quorum.tessera.transaction.StoreRawResponse.class);
    MessageHash transactionHash = mock(MessageHash.class);
    when(transactionHash.getHashBytes()).thenReturn("TXN".getBytes());
    when(response.getHash()).thenReturn(transactionHash);
    when(transactionManager.store(any())).thenReturn(response);
    final StoreRawRequest storeRawRequest = new StoreRawRequest();
    storeRawRequest.setPayload("PAYLOAD".getBytes());
    storeRawRequest.setFrom("Sender".getBytes());
    final Response result = transactionResource.store(storeRawRequest);
    assertThat(result.getStatus()).isEqualTo(200);
    verify(transactionManager).store(any());
}
Also used : Response(jakarta.ws.rs.core.Response) StoreRawRequest(com.quorum.tessera.api.StoreRawRequest) MessageHash(com.quorum.tessera.data.MessageHash) Test(org.junit.Test)

Example 2 with StoreRawRequest

use of com.quorum.tessera.api.StoreRawRequest in project tessera by ConsenSys.

the class RawTransactionResourceTest method storeVersion21.

@Test
public void storeVersion21() {
    com.quorum.tessera.transaction.StoreRawResponse response = mock(com.quorum.tessera.transaction.StoreRawResponse.class);
    MessageHash transactionHash = mock(MessageHash.class);
    when(transactionHash.getHashBytes()).thenReturn("TXN".getBytes());
    when(response.getHash()).thenReturn(transactionHash);
    when(transactionManager.store(any())).thenReturn(response);
    final StoreRawRequest storeRawRequest = new StoreRawRequest();
    storeRawRequest.setPayload("PAYLOAD".getBytes());
    storeRawRequest.setFrom("Sender".getBytes());
    final Response result = transactionResource.storeVersion21(storeRawRequest);
    assertThat(result.getStatus()).isEqualTo(200);
    verify(transactionManager).store(any());
}
Also used : Response(jakarta.ws.rs.core.Response) StoreRawRequest(com.quorum.tessera.api.StoreRawRequest) MessageHash(com.quorum.tessera.data.MessageHash) Test(org.junit.Test)

Example 3 with StoreRawRequest

use of com.quorum.tessera.api.StoreRawRequest in project tessera by ConsenSys.

the class RawTransactionResourceTest method storeUsingDefaultKeyVersion21.

@Test
public void storeUsingDefaultKeyVersion21() {
    com.quorum.tessera.transaction.StoreRawResponse response = mock(com.quorum.tessera.transaction.StoreRawResponse.class);
    MessageHash transactionHash = mock(MessageHash.class);
    when(transactionHash.getHashBytes()).thenReturn("TXN".getBytes());
    when(response.getHash()).thenReturn(transactionHash);
    when(transactionManager.store(any())).thenReturn(response);
    when(transactionManager.defaultPublicKey()).thenReturn(PublicKey.from("SENDER".getBytes()));
    final StoreRawRequest storeRawRequest = new StoreRawRequest();
    storeRawRequest.setPayload("PAYLOAD".getBytes());
    final Response result = transactionResource.storeVersion21(storeRawRequest);
    assertThat(result.getStatus()).isEqualTo(200);
    verify(transactionManager).store(any());
    verify(transactionManager).defaultPublicKey();
}
Also used : Response(jakarta.ws.rs.core.Response) StoreRawRequest(com.quorum.tessera.api.StoreRawRequest) MessageHash(com.quorum.tessera.data.MessageHash) Test(org.junit.Test)

Example 4 with StoreRawRequest

use of com.quorum.tessera.api.StoreRawRequest in project tessera by ConsenSys.

the class RawTransactionResourceTest method storeUsingDefaultKey.

@Test
public void storeUsingDefaultKey() {
    com.quorum.tessera.transaction.StoreRawResponse response = mock(com.quorum.tessera.transaction.StoreRawResponse.class);
    MessageHash transactionHash = mock(MessageHash.class);
    when(transactionHash.getHashBytes()).thenReturn("TXN".getBytes());
    when(response.getHash()).thenReturn(transactionHash);
    when(transactionManager.store(any())).thenReturn(response);
    when(transactionManager.defaultPublicKey()).thenReturn(PublicKey.from("SENDER".getBytes()));
    final StoreRawRequest storeRawRequest = new StoreRawRequest();
    storeRawRequest.setPayload("PAYLOAD".getBytes());
    final Response result = transactionResource.store(storeRawRequest);
    assertThat(result.getStatus()).isEqualTo(200);
    verify(transactionManager).store(any());
    verify(transactionManager).defaultPublicKey();
}
Also used : Response(jakarta.ws.rs.core.Response) StoreRawRequest(com.quorum.tessera.api.StoreRawRequest) MessageHash(com.quorum.tessera.data.MessageHash) Test(org.junit.Test)

Aggregations

StoreRawRequest (com.quorum.tessera.api.StoreRawRequest)4 MessageHash (com.quorum.tessera.data.MessageHash)4 Response (jakarta.ws.rs.core.Response)4 Test (org.junit.Test)4