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);
}
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);
}
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);
}
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)));
}
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);
}
Aggregations