Search in sources :

Example 1 with EngineStatusRequest

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

the class EngineStatusHandlerTest method engine_configuration_should_return_correct_data.

@Test
public void engine_configuration_should_return_correct_data() throws Exception {
    // Arrange
    start();
    // Act
    var request = new EngineStatusRequest().networkIdentifier(new NetworkIdentifier().network("localnet"));
    var response = handleRequestWithExpectedResponse(sut, request, EngineStatusResponse.class);
    // Assert
    assertThat(response.getValidatorSet()).containsExactly(new Validator().validatorAddress(addressing.forValidators().of(selfKey())).stake(getStakeAmount().toSubunits().toString()));
}
Also used : EngineStatusRequest(com.radixdlt.api.core.openapitools.model.EngineStatusRequest) NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) Validator(com.radixdlt.api.core.openapitools.model.Validator) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Example 2 with EngineStatusRequest

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

Aggregations

EngineStatusRequest (com.radixdlt.api.core.openapitools.model.EngineStatusRequest)2 NetworkIdentifier (com.radixdlt.api.core.openapitools.model.NetworkIdentifier)2 ApiTest (com.radixdlt.api.ApiTest)1 CoreApiException (com.radixdlt.api.core.model.CoreApiException)1 EntityRequest (com.radixdlt.api.core.openapitools.model.EntityRequest)1 Validator (com.radixdlt.api.core.openapitools.model.Validator)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1