use of io.nem.symbol.sdk.model.transaction.AggregateTransaction in project nem2-sdk-java by nemtech.
the class TransactionMapperOkHttpTest method shouldCreateAggregateAddressAliasTransaction.
@Test
void shouldCreateAggregateAddressAliasTransaction() {
TransactionInfoDTO aggregateTransferTransactionDTO = TestHelperOkHttp.loadTransactionInfoDTO("aggregateAddressAliasTransaction.json");
Transaction aggregateTransferTransaction = map(aggregateTransferTransactionDTO);
validateAggregateTransaction((AggregateTransaction) aggregateTransferTransaction, aggregateTransferTransactionDTO);
AddressAliasTransaction transaction = (AddressAliasTransaction) ((AggregateTransaction) aggregateTransferTransaction).getInnerTransactions().get(0);
Assertions.assertEquals("SDT4THYNVUQK2GM6XXYTWHZXSPE3AUA2GTDPM2Q", transaction.getAddress().plain());
Assertions.assertEquals(AliasAction.LINK, transaction.getAliasAction());
Assertions.assertEquals(new BigInteger("307262000798378"), transaction.getNamespaceId().getId());
}
use of io.nem.symbol.sdk.model.transaction.AggregateTransaction in project nem2-sdk-java by nemtech.
the class TransactionMapperOkHttpTest method shouldCreateAggregateMosaicMetadataTransaction.
@Test
void shouldCreateAggregateMosaicMetadataTransaction() {
TransactionInfoDTO aggregateTransferTransactionDTO = TestHelperOkHttp.loadTransactionInfoDTO("aggregateMosaicMetadataTransaction.json");
AggregateTransaction aggregateTransferTransaction = (AggregateTransaction) map(aggregateTransferTransactionDTO);
validateAggregateTransaction(aggregateTransferTransaction, aggregateTransferTransactionDTO);
MosaicMetadataTransaction transaction = (MosaicMetadataTransaction) aggregateTransferTransaction.getInnerTransactions().get(0);
Assertions.assertEquals("9103B60AAF27626883000000000000000000000000000000", transaction.getTargetAddress().encoded(transaction.getNetworkType()));
Assertions.assertEquals(1, transaction.getValueSizeDelta());
Assertions.assertEquals(new BigInteger("11529215046069664444"), transaction.getScopedMetadataKey());
Assertions.assertArrayEquals(StringEncoder.getBytes("This is the message for this account! 汉字89664"), transaction.getValue());
Assertions.assertEquals("0003070467832AAA", transaction.getTargetMosaicId().getIdAsHex());
}
use of io.nem.symbol.sdk.model.transaction.AggregateTransaction in project nem2-sdk-java by nemtech.
the class TransactionMapperOkHttpTest method shouldCreateAggregateTransferTransaction.
@Test
void shouldCreateAggregateTransferTransaction() {
TransactionInfoDTO aggregateTransferTransactionDTO = TestHelperOkHttp.loadTransactionInfoDTO("aggregateTransferTransaction.json");
Transaction aggregateTransferTransaction = map(aggregateTransferTransactionDTO);
validateAggregateTransaction((AggregateTransaction) aggregateTransferTransaction, aggregateTransferTransactionDTO);
}
use of io.nem.symbol.sdk.model.transaction.AggregateTransaction in project nem2-sdk-java by nemtech.
the class TransactionMapperOkHttpTest method validateAggregateTransaction.
void validateAggregateTransaction(AggregateTransaction aggregateTransaction, TransactionInfoDTO transactionDto) {
AggregateTransactionBodyExtendedDTO aggregateTransactionBodyDTO = jsonHelper.convert(transactionDto.getTransaction(), AggregateTransactionBodyExtendedDTO.class);
TransactionMetaDTO meta = jsonHelper.convert(transactionDto.getMeta(), TransactionMetaDTO.class);
if (aggregateTransaction.getTransactionInfo().isPresent()) {
TransactionInfo transactionInfo = aggregateTransaction.getTransactionInfo().get();
assertEquals(meta.getHeight(), transactionInfo.getHeight());
if (transactionInfo.getHash().isPresent()) {
assertEquals(meta.getHash(), transactionInfo.getHash().get());
}
if (transactionInfo.getMerkleComponentHash().isPresent()) {
assertEquals(meta.getMerkleComponentHash(), transactionInfo.getMerkleComponentHash().get());
}
if (transactionInfo.getIndex().isPresent()) {
assertEquals(transactionInfo.getIndex().get(), meta.getIndex());
}
}
assertEquals(jsonHelper.getString(transactionDto.getTransaction(), "signature"), aggregateTransaction.getSignature().get());
assertEquals(jsonHelper.getString(transactionDto.getTransaction(), "signerPublicKey"), aggregateTransaction.getSigner().get().getPublicKey().toHex());
int version = jsonHelper.getInteger(transactionDto.getTransaction(), "version");
assertEquals((int) aggregateTransaction.getVersion(), version);
int networkType = jsonHelper.getInteger(transactionDto.getTransaction(), "network");
assertEquals(aggregateTransaction.getNetworkType().getValue(), networkType);
assertEquals(aggregateTransaction.getType().getValue(), (int) jsonHelper.getInteger(transactionDto.getTransaction(), "type"));
assertEquals(jsonHelper.getBigInteger(transactionDto.getTransaction(), "maxFee"), aggregateTransaction.getMaxFee());
assertNotNull(aggregateTransaction.getDeadline());
assertEquals(aggregateTransactionBodyDTO.getCosignatures().get(0).getSignature(), aggregateTransaction.getCosignatures().get(0).getSignature());
assertEquals(aggregateTransactionBodyDTO.getCosignatures().get(0).getSignerPublicKey(), aggregateTransaction.getCosignatures().get(0).getSigner().getPublicKey().toHex());
Transaction innerTransaction = aggregateTransaction.getInnerTransactions().get(0);
validateStandaloneTransaction(innerTransaction, jsonHelper.convert(aggregateTransactionBodyDTO.getTransactions().get(0), TransactionInfoDTO.class), transactionDto);
}
use of io.nem.symbol.sdk.model.transaction.AggregateTransaction in project nem2-sdk-java by nemtech.
the class AggregateTransactionServiceIntegrationTest method isTransferFromMultisigNotComplete.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void isTransferFromMultisigNotComplete(RepositoryType type) {
Account multisigAccount = helper().getMultisigAccount(type).getLeft();
TransferTransaction transferTransaction = TransferTransactionFactory.create(getNetworkType(), getDeadline(), getRecipient(), Collections.emptyList()).message(new PlainMessage("")).maxFee(maxFee).build();
AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(getNetworkType(), getDeadline(), Collections.singletonList(transferTransaction.toAggregate(multisigAccount.getPublicAccount()))).maxFee(maxFee).build();
SignedTransaction signedAggregateTransaction = aggregateTransaction.signTransactionWithCosigners(multisigAccount, Collections.singletonList(config().getTestAccount()), getGenerationHash());
AggregateTransactionService aggregateTransactionService = new AggregateTransactionServiceImpl(getRepositoryFactory(type));
Assertions.assertFalse(get(aggregateTransactionService.isComplete(signedAggregateTransaction)));
}
Aggregations