use of com.radixdlt.api.core.openapitools.model.EntityRequest in project radixdlt by radixdlt.
the class EntityHandlerTest method retrieve_prepared_unstake_entity_on_genesis.
@Test
public void retrieve_prepared_unstake_entity_on_genesis() throws Exception {
// Arrange
start();
// Act
var address = REAddr.ofPubKeyAccount(selfKey());
var request = new EntityRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).entityIdentifier(coreModelMapper.entityIdentifierPreparedUnstake(address));
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();
}
use of com.radixdlt.api.core.openapitools.model.EntityRequest in project radixdlt by radixdlt.
the class EntityHandlerTest method retrieve_validator_system_entity_on_genesis.
@Test
public void retrieve_validator_system_entity_on_genesis() throws Exception {
// Arrange
start();
// Act
var request = new EntityRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).entityIdentifier(coreModelMapper.entityIdentifierValidatorSystem(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(ValidatorBFTData.class, ValidatorData.class);
assertThat(response.getBalances()).containsExactly(coreModelMapper.nativeTokenAmount(getStakeAmount().toSubunits()));
}
use of com.radixdlt.api.core.openapitools.model.EntityRequest 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;
}
use of com.radixdlt.api.core.openapitools.model.EntityRequest 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();
}
use of com.radixdlt.api.core.openapitools.model.EntityRequest 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();
}
Aggregations