Search in sources :

Example 1 with CommittedTransactionsRequest

use of com.radixdlt.api.core.openapitools.model.CommittedTransactionsRequest in project radixdlt by radixdlt.

the class TransactionsHandlerTest method retrieving_illegal_state_version_should_throw_exception.

@Test
public void retrieving_illegal_state_version_should_throw_exception() throws Exception {
    // Arrange
    start();
    // Act
    var request = new CommittedTransactionsRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).limit(1L).stateIdentifier(new PartialStateIdentifier().stateVersion(-1L));
    var response = handleRequestWithExpectedResponse(sut, request, UnexpectedError.class);
    // Assert
    assertThat(response.getDetails()).isInstanceOf(InvalidPartialStateIdentifierError.class);
}
Also used : PartialStateIdentifier(com.radixdlt.api.core.openapitools.model.PartialStateIdentifier) NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) CommittedTransactionsRequest(com.radixdlt.api.core.openapitools.model.CommittedTransactionsRequest) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Example 2 with CommittedTransactionsRequest

use of com.radixdlt.api.core.openapitools.model.CommittedTransactionsRequest in project radixdlt by radixdlt.

the class TransactionsHandlerTest method retrieve_last_state_version.

@Test
public void retrieve_last_state_version() throws Exception {
    // Arrange
    start();
    // Act
    var request = new CommittedTransactionsRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).limit(1L).stateIdentifier(new PartialStateIdentifier().stateVersion(1L));
    var response = handleRequestWithExpectedResponse(sut, request, CommittedTransactionsResponse.class);
    // Assert
    assertThat(response.getTransactions()).isEmpty();
    var stateAccumulator = response.getStateIdentifier().getTransactionAccumulator();
    var genesisAccumulator = genesis.getProof().getAccumulatorState().getAccumulatorHash().asBytes();
    assertThat(stateAccumulator).isEqualTo(Bytes.toHexString(genesisAccumulator));
}
Also used : PartialStateIdentifier(com.radixdlt.api.core.openapitools.model.PartialStateIdentifier) NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) CommittedTransactionsRequest(com.radixdlt.api.core.openapitools.model.CommittedTransactionsRequest) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Example 3 with CommittedTransactionsRequest

use of com.radixdlt.api.core.openapitools.model.CommittedTransactionsRequest in project radixdlt by radixdlt.

the class TransactionsHandlerTest method retrieve_genesis_in_transaction_stream.

@Test
public void retrieve_genesis_in_transaction_stream() throws Exception {
    // Arrange
    start();
    // Act
    var request = new CommittedTransactionsRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).limit(1L).stateIdentifier(new PartialStateIdentifier().stateVersion(0L));
    var response = handleRequestWithExpectedResponse(sut, request, CommittedTransactionsResponse.class);
    // Assert
    assertThat(response.getTransactions()).hasSize(1);
    var hex = response.getTransactions().get(0).getMetadata().getHex();
    assertThat(hex).isEqualTo(Bytes.toHexString(genesis.getTxns().get(0).getPayload()));
}
Also used : PartialStateIdentifier(com.radixdlt.api.core.openapitools.model.PartialStateIdentifier) NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) CommittedTransactionsRequest(com.radixdlt.api.core.openapitools.model.CommittedTransactionsRequest) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Example 4 with CommittedTransactionsRequest

use of com.radixdlt.api.core.openapitools.model.CommittedTransactionsRequest in project radixdlt by radixdlt.

the class TransactionsHandlerTest method retrieving_past_last_state_version_should_throw_exception.

@Test
public void retrieving_past_last_state_version_should_throw_exception() throws Exception {
    // Arrange
    start();
    // Act
    var request = new CommittedTransactionsRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).limit(1L).stateIdentifier(new PartialStateIdentifier().stateVersion(2L));
    var response = handleRequestWithExpectedResponse(sut, request, UnexpectedError.class);
    // Assert
    assertThat(response.getDetails()).isInstanceOf(StateIdentifierNotFoundError.class);
}
Also used : PartialStateIdentifier(com.radixdlt.api.core.openapitools.model.PartialStateIdentifier) NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) CommittedTransactionsRequest(com.radixdlt.api.core.openapitools.model.CommittedTransactionsRequest) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Aggregations

ApiTest (com.radixdlt.api.ApiTest)4 CommittedTransactionsRequest (com.radixdlt.api.core.openapitools.model.CommittedTransactionsRequest)4 NetworkIdentifier (com.radixdlt.api.core.openapitools.model.NetworkIdentifier)4 PartialStateIdentifier (com.radixdlt.api.core.openapitools.model.PartialStateIdentifier)4 Test (org.junit.Test)4