Search in sources :

Example 6 with EntityRequest

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

the class EntityHandlerTest method retrieve_native_token_on_genesis.

@Test
public void retrieve_native_token_on_genesis() throws Exception {
    // Arrange
    start();
    // Act
    var request = new EntityRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).entityIdentifier(coreModelMapper.entityIdentifier(REAddr.ofNativeToken(), "xrd"));
    var response = handleRequestWithExpectedResponse(sut, request, EntityResponse.class);
    // Assert
    var stateAccumulator = response.getStateIdentifier().getTransactionAccumulator();
    var genesisAccumulator = genesis.getProof().getAccumulatorState().getAccumulatorHash().asBytes();
    assertThat(stateAccumulator).isEqualTo(Bytes.toHexString(genesisAccumulator));
    assertThat(response.getBalances()).isEmpty();
    assertThat(response.getDataObjects()).hasAtLeastOneElementOfType(TokenData.class);
    assertThat(response.getDataObjects()).hasAtLeastOneElementOfType(TokenMetadata.class);
}
Also used : EntityRequest(com.radixdlt.api.core.openapitools.model.EntityRequest) NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Example 7 with EntityRequest

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

the class EntityHandlerTest method retrieve_prepared_stake_entity_on_genesis.

@Test
public void retrieve_prepared_stake_entity_on_genesis() throws Exception {
    // Arrange
    start();
    // Act
    var address = REAddr.ofPubKeyAccount(selfKey());
    var request = new EntityRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).entityIdentifier(coreModelMapper.entityIdentifierPreparedStake(address, selfKey()));
    var response = handleRequestWithExpectedResponse(sut, request, EntityResponse.class);
    // Assert
    var stateAccumulator = response.getStateIdentifier().getTransactionAccumulator();
    var genesisAccumulator = genesis.getProof().getAccumulatorState().getAccumulatorHash().asBytes();
    assertThat(stateAccumulator).isEqualTo(Bytes.toHexString(genesisAccumulator));
    assertThat(response.getDataObjects()).isEmpty();
    assertThat(response.getBalances()).isEmpty();
}
Also used : EntityRequest(com.radixdlt.api.core.openapitools.model.EntityRequest) NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Example 8 with EntityRequest

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

the class EntityHandlerTest method retrieve_invalid_sub_entity_should_throw.

@Test
public void retrieve_invalid_sub_entity_should_throw() throws Exception {
    // Arrange
    start();
    // Act
    var address = REAddr.ofPubKeyAccount(selfKey());
    var invalidSubEntity = coreModelMapper.entityIdentifier(address).subEntity(new SubEntity().address("prepared_stakes"));
    var request = new EntityRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).entityIdentifier(invalidSubEntity);
    var response = handleRequestWithExpectedResponse(sut, request, UnexpectedError.class);
    // Assert
    assertThat(response.getDetails()).isInstanceOf(InvalidSubEntityError.class);
}
Also used : EntityRequest(com.radixdlt.api.core.openapitools.model.EntityRequest) NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) SubEntity(com.radixdlt.api.core.openapitools.model.SubEntity) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Example 9 with EntityRequest

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

the class EntityHandlerTest method retrieve_exiting_stake_entity_on_genesis.

@Test
public void retrieve_exiting_stake_entity_on_genesis() throws Exception {
    // Arrange
    start();
    // Act
    var address = REAddr.ofPubKeyAccount(selfKey());
    var request = new EntityRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).entityIdentifier(coreModelMapper.entityIdentifierExitingStake(address, selfKey(), 1));
    var response = handleRequestWithExpectedResponse(sut, request, EntityResponse.class);
    // Assert
    var stateAccumulator = response.getStateIdentifier().getTransactionAccumulator();
    var genesisAccumulator = genesis.getProof().getAccumulatorState().getAccumulatorHash().asBytes();
    assertThat(stateAccumulator).isEqualTo(Bytes.toHexString(genesisAccumulator));
    assertThat(response.getDataObjects()).isEmpty();
    assertThat(response.getBalances()).isEmpty();
}
Also used : EntityRequest(com.radixdlt.api.core.openapitools.model.EntityRequest) NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Example 10 with EntityRequest

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

the class EntityHandlerTest method retrieve_invalid_entity_should_throw.

@Test
public void retrieve_invalid_entity_should_throw() throws Exception {
    // Arrange
    start();
    // Act
    // Assert
    var request = new EntityRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).entityIdentifier(new EntityIdentifier().address("some_garbage_address"));
    var response = handleRequestWithExpectedResponse(sut, request, UnexpectedError.class);
    assertThat(response.getDetails()).isInstanceOf(InvalidAddressError.class);
}
Also used : EntityRequest(com.radixdlt.api.core.openapitools.model.EntityRequest) NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) EntityIdentifier(com.radixdlt.api.core.openapitools.model.EntityIdentifier) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Aggregations

EntityRequest (com.radixdlt.api.core.openapitools.model.EntityRequest)12 NetworkIdentifier (com.radixdlt.api.core.openapitools.model.NetworkIdentifier)11 ApiTest (com.radixdlt.api.ApiTest)10 Test (org.junit.Test)10 CoreApiException (com.radixdlt.api.core.model.CoreApiException)2 EntityIdentifier (com.radixdlt.api.core.openapitools.model.EntityIdentifier)2 Inject (com.google.inject.Inject)1 CoreJsonRpcHandler (com.radixdlt.api.core.CoreJsonRpcHandler)1 CoreModelMapper (com.radixdlt.api.core.model.CoreModelMapper)1 EngineStatusRequest (com.radixdlt.api.core.openapitools.model.EngineStatusRequest)1 EntityResponse (com.radixdlt.api.core.openapitools.model.EntityResponse)1 SubEntity (com.radixdlt.api.core.openapitools.model.SubEntity)1 UnclaimedRadixEngineAddress (com.radixdlt.api.core.openapitools.model.UnclaimedRadixEngineAddress)1 ResourceInBucket (com.radixdlt.application.tokens.ResourceInBucket)1 TokenResourceMetadata (com.radixdlt.application.tokens.state.TokenResourceMetadata)1 SubstateTypeId (com.radixdlt.atom.SubstateTypeId)1 SystemMapKey (com.radixdlt.constraintmachine.SystemMapKey)1 RadixEngine (com.radixdlt.engine.RadixEngine)1 REAddr (com.radixdlt.identifiers.REAddr)1 LedgerAndBFTProof (com.radixdlt.statecomputer.LedgerAndBFTProof)1