Search in sources :

Example 1 with ConstructionDeriveRequest

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

the class ConstructionDeriveHandlerTest method derive_validator_request_should_return_validator_entity_identifier.

@Test
public void derive_validator_request_should_return_validator_entity_identifier() throws CoreApiException {
    // Arrange
    var publicKey = PrivateKeys.ofNumeric(2).getPublicKey();
    start();
    // Act
    var request = new ConstructionDeriveRequest().networkIdentifier(networkIdentifier()).publicKey(coreModelMapper.publicKey(publicKey)).metadata(new ConstructionDeriveRequestMetadataValidator().type("Validator"));
    var response = sut.handleRequest(request);
    // Assert
    assertThat(response.getEntityIdentifier()).isEqualTo(coreModelMapper.entityIdentifier(publicKey));
}
Also used : ConstructionDeriveRequestMetadataValidator(com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataValidator) ConstructionDeriveRequest(com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequest) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Example 2 with ConstructionDeriveRequest

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

the class ConstructionDeriveHandlerTest method derive_prepared_unstakes_should_return_entity_identifier.

@Test
public void derive_prepared_unstakes_should_return_entity_identifier() throws CoreApiException {
    // Arrange
    var publicKey = PrivateKeys.ofNumeric(2).getPublicKey();
    start();
    // Act
    var request = new ConstructionDeriveRequest().networkIdentifier(networkIdentifier()).publicKey(coreModelMapper.publicKey(publicKey)).metadata(new ConstructionDeriveRequestMetadataPreparedUnstakes().type("PreparedUnstakes"));
    var response = sut.handleRequest(request);
    // Assert
    assertThat(response.getEntityIdentifier()).isEqualTo(coreModelMapper.entityIdentifierPreparedUnstake(REAddr.ofPubKeyAccount(publicKey)));
}
Also used : ConstructionDeriveRequestMetadataPreparedUnstakes(com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataPreparedUnstakes) ConstructionDeriveRequest(com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequest) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Example 3 with ConstructionDeriveRequest

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

the class ConstructionDeriveHandlerTest method derive_prepared_stakes_should_return_entity_identifier.

@Test
public void derive_prepared_stakes_should_return_entity_identifier() throws CoreApiException {
    // Arrange
    var publicKey = PrivateKeys.ofNumeric(2).getPublicKey();
    var validatorKey = PrivateKeys.ofNumeric(3).getPublicKey();
    start();
    // Act
    var request = new ConstructionDeriveRequest().networkIdentifier(networkIdentifier()).publicKey(coreModelMapper.publicKey(publicKey)).metadata(new ConstructionDeriveRequestMetadataPreparedStakes().validator(coreModelMapper.entityIdentifier(validatorKey)).type("PreparedStakes"));
    var response = sut.handleRequest(request);
    // Assert
    assertThat(response.getEntityIdentifier()).isEqualTo(coreModelMapper.entityIdentifierPreparedStake(REAddr.ofPubKeyAccount(publicKey), validatorKey));
}
Also used : ConstructionDeriveRequestMetadataPreparedStakes(com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataPreparedStakes) ConstructionDeriveRequest(com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequest) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Example 4 with ConstructionDeriveRequest

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

the class ConstructionDeriveHandlerTest method derive_exiting_unstakes_should_return_entity_identifier.

@Test
public void derive_exiting_unstakes_should_return_entity_identifier() throws CoreApiException {
    // Arrange
    var publicKey = PrivateKeys.ofNumeric(2).getPublicKey();
    var validatorKey = PrivateKeys.ofNumeric(3).getPublicKey();
    long epochUnlock = 236L;
    start();
    // Act
    var request = new ConstructionDeriveRequest().networkIdentifier(networkIdentifier()).publicKey(coreModelMapper.publicKey(publicKey)).metadata(new ConstructionDeriveRequestMetadataExitingUnstakes().validator(coreModelMapper.entityIdentifier(validatorKey)).epochUnlock(epochUnlock).type("ExitingUnstakes"));
    var response = sut.handleRequest(request);
    // Assert
    assertThat(response.getEntityIdentifier()).isEqualTo(coreModelMapper.entityIdentifierExitingStake(REAddr.ofPubKeyAccount(publicKey), validatorKey, epochUnlock));
}
Also used : ConstructionDeriveRequest(com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequest) ConstructionDeriveRequestMetadataExitingUnstakes(com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataExitingUnstakes) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Example 5 with ConstructionDeriveRequest

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

the class ConstructionDeriveHandlerTest method invalid_public_key_should_throw_exception.

@Test
public void invalid_public_key_should_throw_exception() {
    // Arrange
    start();
    // Act
    // Assert
    var request = new ConstructionDeriveRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).publicKey(new PublicKey().hex("deadbeaddeadbead")).metadata(new ConstructionDeriveRequestMetadataToken().symbol("test").type("Token"));
    assertThatThrownBy(() -> sut.handleRequest(request)).isInstanceOfSatisfying(CoreApiException.class, e -> {
        var error = e.toError();
        assertThat(error.getDetails()).isInstanceOf(InvalidPublicKeyError.class);
        assertThat(error.getCode()).isEqualTo(CoreApiErrorCode.BAD_REQUEST.getErrorCode());
    });
}
Also used : PublicKey(com.radixdlt.api.core.openapitools.model.PublicKey) NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) ConstructionDeriveRequest(com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequest) ConstructionDeriveRequestMetadataToken(com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataToken) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Aggregations

ApiTest (com.radixdlt.api.ApiTest)9 ConstructionDeriveRequest (com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequest)9 Test (org.junit.Test)9 ConstructionDeriveRequestMetadataPreparedStakes (com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataPreparedStakes)2 ConstructionDeriveRequestMetadataToken (com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataToken)2 NetworkIdentifier (com.radixdlt.api.core.openapitools.model.NetworkIdentifier)2 ConstructionDeriveRequestMetadataAccount (com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataAccount)1 ConstructionDeriveRequestMetadataExitingUnstakes (com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataExitingUnstakes)1 ConstructionDeriveRequestMetadataPreparedUnstakes (com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataPreparedUnstakes)1 ConstructionDeriveRequestMetadataValidator (com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataValidator)1 ConstructionDeriveRequestMetadataValidatorSystem (com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataValidatorSystem)1 PublicKey (com.radixdlt.api.core.openapitools.model.PublicKey)1