Search in sources :

Example 6 with ConstructionDeriveRequest

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

the class ConstructionDeriveHandlerTest method derive_prepared_stakes_with_invalid_validator_should_return_error.

@Test
public void derive_prepared_stakes_with_invalid_validator_should_return_error() {
    // Arrange
    var publicKey = PrivateKeys.ofNumeric(2).getPublicKey();
    var validatorKey = PrivateKeys.ofNumeric(3).getPublicKey();
    start();
    // Act
    // Assert
    var request = new ConstructionDeriveRequest().networkIdentifier(networkIdentifier()).publicKey(coreModelMapper.publicKey(publicKey)).metadata(new ConstructionDeriveRequestMetadataPreparedStakes().validator(coreModelMapper.entityIdentifier(REAddr.ofPubKeyAccount(validatorKey))).type("PreparedStakes"));
    assertThatThrownBy(() -> sut.handleRequest(request)).isInstanceOfSatisfying(CoreApiException.class, e -> {
        assertThat(e.toError().getDetails()).isInstanceOf(NotValidatorEntityError.class);
    });
}
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 7 with ConstructionDeriveRequest

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

the class ConstructionDeriveHandlerTest method derive_token_request_should_return_token_entity_identifier.

@Test
public void derive_token_request_should_return_token_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 ConstructionDeriveRequestMetadataToken().symbol("test").type("Token"));
    var response = sut.handleRequest(request);
    // Assert
    assertThat(response.getEntityIdentifier()).isEqualTo(coreModelMapper.entityIdentifier(REAddr.ofHashedKey(publicKey, "test"), "test"));
}
Also used : 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)

Example 8 with ConstructionDeriveRequest

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

the class ConstructionDeriveHandlerTest method derive_account_request_should_return_account_entity_identifier.

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

Example 9 with ConstructionDeriveRequest

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

the class ConstructionDeriveHandlerTest method derive_validator_system_should_return_entity_identifier.

@Test
public void derive_validator_system_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 ConstructionDeriveRequestMetadataValidatorSystem().type("ValidatorSystem"));
    var response = sut.handleRequest(request);
    // Assert
    assertThat(response.getEntityIdentifier()).isEqualTo(coreModelMapper.entityIdentifierValidatorSystem(publicKey));
}
Also used : ConstructionDeriveRequestMetadataValidatorSystem(com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequestMetadataValidatorSystem) ConstructionDeriveRequest(com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequest) 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