use of io.nem.symbol.sdk.model.transaction.TransferTransaction in project nem2-sdk-java by nemtech.
the class TransactionServiceIntegrationTest method testTransferCustomCurrencyFromAccount1UsingAggregate.
@ParameterizedTest
@EnumSource(RepositoryType.class)
public void testTransferCustomCurrencyFromAccount1UsingAggregate(RepositoryType type) {
String mosaicAlias = ("testTransferCustomCurrencyFromAccount1UsingAggregate" + RandomUtils.nextInt(0, 10000)).toLowerCase();
Account testAccount = helper().getTestAccount(type).getLeft();
String recipientAlias = "testaccount" + RandomUtils.nextInt(0, 10000);
MosaicId mosaicId = helper().createMosaic(testAccount, type, BigInteger.valueOf(10000), mosaicAlias);
String aggregateTransactionHash = transferUsingAliasesAggregate(testAccount, type, mosaicAlias, recipientAlias, BigInteger.ONE).getTransactionInfo().get().getHash().get();
List<Transaction> transactions = get(getTransactionService(type).resolveAliases(Collections.singletonList(aggregateTransactionHash)));
Assertions.assertEquals(1, transactions.size());
TransferTransaction resolvedTransaction = (TransferTransaction) ((AggregateTransaction) transactions.get(0)).getInnerTransactions().get(0);
assertTransaction(mosaicId, resolvedTransaction, testAccount);
}
use of io.nem.symbol.sdk.model.transaction.TransferTransaction in project nem2-sdk-java by nemtech.
the class TransactionSearchRepositoryIntegrationTest method searchEmbedded.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchEmbedded(RepositoryType type) {
TransactionRepository transactionRepository = getTransactionRepository(type);
TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
TransactionGroup group = TransactionGroup.CONFIRMED;
TransactionSearchCriteria criteria = new TransactionSearchCriteria(group).embedded(true);
List<Transaction> transactions = get(streamer.search(criteria).toList().toObservable());
transactions.forEach(b -> {
TransferTransaction transferTransaction = (TransferTransaction) b;
Message message = transferTransaction.getMessage().orElse(PlainMessage.create("No Message!!"));
Assertions.assertNotNull(message.getText());
});
Assertions.assertFalse(transactions.isEmpty());
}
use of io.nem.symbol.sdk.model.transaction.TransferTransaction in project nem2-sdk-java by nemtech.
the class TransactionSearchRepositoryIntegrationTest method searchTransactionType.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchTransactionType(RepositoryType type) {
TransactionRepository transactionRepository = getTransactionRepository(type);
TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
TransactionGroup group = TransactionGroup.CONFIRMED;
TransactionSearchCriteria criteria = new TransactionSearchCriteria(group).transactionTypes(Arrays.asList(TransactionType.TRANSFER));
List<Transaction> transactions = get(streamer.search(criteria).toList().toObservable());
transactions.forEach(b -> {
TransferTransaction transferTransaction = (TransferTransaction) b;
Message message = transferTransaction.getMessage().orElse(PlainMessage.create("No Message!!"));
Assertions.assertNotNull(message.getText());
});
Assertions.assertFalse(transactions.isEmpty());
}
use of io.nem.symbol.sdk.model.transaction.TransferTransaction in project nem2-sdk-java by nemtech.
the class RepositoryFactoryConfigurationExamplesIntegrationTest method appDoSomeStuff.
public void appDoSomeStuff(RepositoryFactory repositoryFactory) throws ExecutionException, InterruptedException {
// The application logic is exactly the same regardless of how the repository
// factory was
// set
// Note: if rest is used, these values are cached form rest
Currency currency = repositoryFactory.getNetworkCurrency().toFuture().get();
String generationHash = repositoryFactory.getGenerationHash().toFuture().get();
NetworkType networkType = repositoryFactory.getNetworkType().toFuture().get();
Account sender = Account.generateNewAccount(networkType);
Account recipient = Account.generateNewAccount(networkType);
Duration epochAdjustment = repositoryFactory.getEpochAdjustment().toFuture().get();
TransferTransaction transferTransaction = TransferTransactionFactory.create(networkType, Deadline.create(epochAdjustment), recipient.getAddress(), Collections.singletonList(currency.createRelative(BigInteger.TEN))).message(new PlainMessage("")).build();
SignedTransaction signedTransaction = transferTransaction.signWith(sender, generationHash);
// Announce or store somewhere....
}
use of io.nem.symbol.sdk.model.transaction.TransferTransaction in project nem2-sdk-java by nemtech.
the class MultisigAccountOperationsIntegrationTest method cosignatureTransactionOnSign.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void cosignatureTransactionOnSign(RepositoryType type) {
Account multisigAccount = helper().getMultisigAccount(type).getLeft();
Account cosignatoryAccount = config().getCosignatoryAccount();
Address recipient = getRecipient();
TransferTransaction transferTransaction = TransferTransactionFactory.create(getNetworkType(), getDeadline(), recipient, Collections.singletonList(getNetworkCurrency().createAbsolute(BigInteger.valueOf(1)))).message(new PlainMessage("test-message")).maxFee(maxFee).build();
AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createBonded(getNetworkType(), getDeadline(), Collections.singletonList(transferTransaction.toAggregate(multisigAccount.getPublicAccount()))).maxFee(maxFee).build();
SignedTransaction signedTransaction = cosignatoryAccount.sign(aggregateTransaction, getGenerationHash());
TransactionFactory<HashLockTransaction> hashLockTransaction = HashLockTransactionFactory.create(getNetworkType(), getDeadline(), getNetworkCurrency().createRelative(BigInteger.valueOf(10)), BigInteger.valueOf(100), signedTransaction).maxFee(maxFee);
SignedTransaction signedHashLockTransaction = hashLockTransaction.build().signWith(cosignatoryAccount, getGenerationHash());
AggregateTransaction finalTransaction = getTransactionOrFail(getTransactionService(type).announceHashLockAggregateBonded(getListener(type), signedHashLockTransaction, signedTransaction), aggregateTransaction);
Assertions.assertNotNull(finalTransaction);
}
Aggregations