use of com.radixdlt.api.core.openapitools.model.NetworkIdentifier 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());
});
}
use of com.radixdlt.api.core.openapitools.model.NetworkIdentifier in project radixdlt by radixdlt.
the class ConstructionFinalizeTest method finalizing_a_transaction_with_signature_should_return_back_signed_tranaction.
@Test
public void finalizing_a_transaction_with_signature_should_return_back_signed_tranaction() 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 os = new ByteArrayOutputStream();
var asn1OutputStream = ASN1OutputStream.create(os);
asn1OutputStream.writeObject(new DLSequence(new ASN1Encodable[] { new ASN1Integer(sig.getR()), new ASN1Integer(sig.getS()) }));
var derSignature = os.toByteArray();
var request = new ConstructionFinalizeRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).unsignedTransaction(Bytes.toHexString(unsignedTxn.blob())).signature(new Signature().bytes(Bytes.toHexString(derSignature)).publicKey(coreModelMapper.publicKey(self)));
var response = handleRequestWithExpectedResponse(sut, request, ConstructionFinalizeResponse.class);
// Assert
var bytes = Bytes.fromHexString(response.getSignedTransaction());
assertThat(bytes).isNotNull();
}
use of com.radixdlt.api.core.openapitools.model.NetworkIdentifier in project radixdlt by radixdlt.
the class ConstructionHashHandlerTest method handling_construction_hash_should_return_hash.
@Test
public void handling_construction_hash_should_return_hash() throws Exception {
// Arrange
start();
// Act
var txn = Txn.create(Bytes.fromHexString("deadbeef"));
var request = new ConstructionHashRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).signedTransaction("deadbeef");
var response = handleRequestWithExpectedResponse(sut, request, ConstructionHashResponse.class);
// Assert
assertThat(response.getTransactionIdentifier()).isEqualTo(coreModelMapper.transactionIdentifier(txn.getId()));
}
use of com.radixdlt.api.core.openapitools.model.NetworkIdentifier in project radixdlt by radixdlt.
the class EngineStatusHandlerTest method engine_configuration_should_return_correct_data.
@Test
public void engine_configuration_should_return_correct_data() throws Exception {
// Arrange
start();
// Act
var request = new EngineStatusRequest().networkIdentifier(new NetworkIdentifier().network("localnet"));
var response = handleRequestWithExpectedResponse(sut, request, EngineStatusResponse.class);
// Assert
assertThat(response.getValidatorSet()).containsExactly(new Validator().validatorAddress(addressing.forValidators().of(selfKey())).stake(getStakeAmount().toSubunits().toString()));
}
use of com.radixdlt.api.core.openapitools.model.NetworkIdentifier 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();
}
Aggregations