Search in sources :

Example 21 with NetworkIdentifier

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

the class KeySignHandlerTest method sign_given_an_unsupported_public_key_should_fail.

@Test
public void sign_given_an_unsupported_public_key_should_fail() throws Exception {
    // Arrange
    start();
    // Act
    var from = REAddr.ofPubKeyAccount(selfKey());
    var other = PrivateKeys.ofNumeric(2);
    var to = REAddr.ofPubKeyAccount(other.getPublicKey());
    var unsignedTxn = buildUnsignedTxn(from, to);
    var request = new KeySignRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).publicKey(mapper.publicKey(other.getPublicKey())).unsignedTransaction(Bytes.toHexString(unsignedTxn));
    var response = handleRequestWithExpectedResponse(sut, request, UnexpectedError.class);
    // Assert
    assertThat(response.getDetails()).isInstanceOf(PublicKeyNotSupportedError.class);
}
Also used : NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) KeySignRequest(com.radixdlt.api.core.openapitools.model.KeySignRequest) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Example 22 with NetworkIdentifier

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

the class MempoolTransactionHandlerTest method retrieving_transaction_not_in_mempool_should_throw.

@Test
public void retrieving_transaction_not_in_mempool_should_throw() throws Exception {
    // Arrange
    start();
    var accountAddress = REAddr.ofPubKeyAccount(self);
    var otherAddress = REAddr.ofPubKeyAccount(PrivateKeys.ofNumeric(2).getPublicKey());
    var signedTxn = buildSignedTxn(accountAddress, otherAddress);
    // Act
    var request = new MempoolTransactionRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).transactionIdentifier(coreModelMapper.transactionIdentifier(signedTxn.getId()));
    var response = handleRequestWithExpectedResponse(sut, request, UnexpectedError.class);
    // Assert
    assertThat(response.getDetails()).isInstanceOf(TransactionNotFoundError.class);
}
Also used : MempoolTransactionRequest(com.radixdlt.api.core.openapitools.model.MempoolTransactionRequest) NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Example 23 with NetworkIdentifier

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

the class NetworkStatusHandlerTest method unknown_network_should_return_error.

@Test
public void unknown_network_should_return_error() throws Exception {
    // Arrange
    start();
    // Act
    var request = new NetworkStatusRequest().networkIdentifier(new NetworkIdentifier().network("unknown_network"));
    var response = handleRequestWithExpectedResponse(sut, request, UnexpectedError.class);
    // Assert
    assertThat(response.getDetails()).isInstanceOf(NetworkNotSupportedError.class);
}
Also used : NetworkStatusRequest(com.radixdlt.api.core.openapitools.model.NetworkStatusRequest) NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Example 24 with NetworkIdentifier

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

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

the class ConstructionFinalizeTest method finalizing_a_transaction_with_invalid_signature_should_throw.

@Test
public void finalizing_a_transaction_with_invalid_signature_should_throw() throws Exception {
    // Arrange
    start();
    // Act
    var accountAddress = REAddr.ofPubKeyAccount(self);
    var otherAddress = REAddr.ofPubKeyAccount(PrivateKeys.ofNumeric(2).getPublicKey());
    var unsignedTxn = buildUnsignedTransferTxn(accountAddress, otherAddress);
    var sig = hashSigner.sign(unsignedTxn.hashToSign());
    var invalidSignature = // This is an invalid signature since it must be DER encoded
    sig.toHexString();
    var request = new ConstructionFinalizeRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).unsignedTransaction(Bytes.toHexString(unsignedTxn.blob())).signature(new Signature().bytes(invalidSignature).publicKey(coreModelMapper.publicKey(self)));
    var response = handleRequestWithExpectedResponse(sut, request, UnexpectedError.class);
    // Assert
    assertThat(response.getDetails()).isInstanceOf(InvalidSignatureError.class);
}
Also used : ConstructionFinalizeRequest(com.radixdlt.api.core.openapitools.model.ConstructionFinalizeRequest) Signature(com.radixdlt.api.core.openapitools.model.Signature) 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