Search in sources :

Example 16 with NetworkIdentifier

use of com.radixdlt.api.core.openapitools.model.NetworkIdentifier 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 17 with NetworkIdentifier

use of com.radixdlt.api.core.openapitools.model.NetworkIdentifier 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 18 with NetworkIdentifier

use of com.radixdlt.api.core.openapitools.model.NetworkIdentifier 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 19 with NetworkIdentifier

use of com.radixdlt.api.core.openapitools.model.NetworkIdentifier 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)

Example 20 with NetworkIdentifier

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

the class EntityHandlerTest method retrieve_non_existent_token_on_genesis.

@Test
public void retrieve_non_existent_token_on_genesis() throws Exception {
    // Arrange
    start();
    // Act
    var tokenAddress = REAddr.ofHashedKey(selfKey(), "test");
    var request = new EntityRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).entityIdentifier(coreModelMapper.entityIdentifier(tokenAddress, "test"));
    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()).containsExactly(new UnclaimedRadixEngineAddress().type(SubstateTypeMapping.getName(SubstateTypeId.UNCLAIMED_READDR)));
}
Also used : EntityRequest(com.radixdlt.api.core.openapitools.model.EntityRequest) NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) UnclaimedRadixEngineAddress(com.radixdlt.api.core.openapitools.model.UnclaimedRadixEngineAddress) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Aggregations

NetworkIdentifier (com.radixdlt.api.core.openapitools.model.NetworkIdentifier)32 ApiTest (com.radixdlt.api.ApiTest)29 Test (org.junit.Test)29 EntityRequest (com.radixdlt.api.core.openapitools.model.EntityRequest)11 CommittedTransactionsRequest (com.radixdlt.api.core.openapitools.model.CommittedTransactionsRequest)4 PartialStateIdentifier (com.radixdlt.api.core.openapitools.model.PartialStateIdentifier)4 KeySignRequest (com.radixdlt.api.core.openapitools.model.KeySignRequest)3 Operation (com.radixdlt.api.core.openapitools.model.Operation)3 ConstructionBuildRequest (com.radixdlt.api.core.openapitools.model.ConstructionBuildRequest)2 ConstructionDeriveRequest (com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequest)2 ConstructionFinalizeRequest (com.radixdlt.api.core.openapitools.model.ConstructionFinalizeRequest)2 ConstructionHashRequest (com.radixdlt.api.core.openapitools.model.ConstructionHashRequest)2 ConstructionParseRequest (com.radixdlt.api.core.openapitools.model.ConstructionParseRequest)2 EngineStatusRequest (com.radixdlt.api.core.openapitools.model.EngineStatusRequest)2 EntityIdentifier (com.radixdlt.api.core.openapitools.model.EntityIdentifier)2 MempoolTransactionRequest (com.radixdlt.api.core.openapitools.model.MempoolTransactionRequest)2 OperationGroup (com.radixdlt.api.core.openapitools.model.OperationGroup)2 Signature (com.radixdlt.api.core.openapitools.model.Signature)2 Inject (com.google.inject.Inject)1 ConstructionParseHandler (com.radixdlt.api.core.handlers.ConstructionParseHandler)1