Search in sources :

Example 11 with NetworkIdentifier

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

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

the class NodeApiClient method getUnstakes.

public List<ResourceAmount> getUnstakes(REAddr addr, ECPublicKey validatorKey) {
    var networkIdentifier = new NetworkIdentifier().network("localnet");
    var unstakingDelayEpochLength = unstakingDelayEpochLength();
    var unstakes = new ArrayList<ResourceAmount>();
    try {
        var statusResponse = engineStatusHandler.handleRequest(new EngineStatusRequest().networkIdentifier(networkIdentifier));
        var curEpoch = statusResponse.getEngineStateIdentifier().getEpoch();
        var maxEpoch = curEpoch + unstakingDelayEpochLength + 1;
        for (long epochUnstake = curEpoch; epochUnstake <= maxEpoch; epochUnstake++) {
            var response = entityHandler.handleRequest(new EntityRequest().networkIdentifier(networkIdentifier).entityIdentifier(coreModelMapper.entityIdentifierExitingStake(addr, validatorKey, epochUnstake)));
            unstakes.addAll(response.getBalances());
        }
    } catch (CoreApiException e) {
        throw new IllegalStateException(e);
    }
    return unstakes;
}
Also used : EntityRequest(com.radixdlt.api.core.openapitools.model.EntityRequest) CoreApiException(com.radixdlt.api.core.model.CoreApiException) EngineStatusRequest(com.radixdlt.api.core.openapitools.model.EngineStatusRequest) NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) ArrayList(java.util.ArrayList)

Example 13 with NetworkIdentifier

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

the class EntityHandlerTest method retrieve_validator_entity_on_genesis.

@Test
public void retrieve_validator_entity_on_genesis() throws Exception {
    // Arrange
    start();
    // Act
    var request = new EntityRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).entityIdentifier(coreModelMapper.entityIdentifier(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()).hasOnlyElementsOfTypes(ValidatorAllowDelegation.class, ValidatorMetadata.class, ValidatorSystemMetadata.class, PreparedValidatorOwner.class, PreparedValidatorFee.class, PreparedValidatorRegistered.class);
    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 14 with NetworkIdentifier

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

the class EntityHandlerTest method retrieve_system_entity_on_genesis.

@Test
public void retrieve_system_entity_on_genesis() throws Exception {
    // Arrange
    start();
    // Act
    var request = new EntityRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).entityIdentifier(new EntityIdentifier().address("system"));
    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()).isNotEmpty();
}
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 15 with NetworkIdentifier

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

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