use of io.nem.symbol.sdk.model.transaction.TransferTransaction in project nem2-sdk-java by nemtech.
the class TransactionMapperVertxTest method shouldCreateTransferEmptyMessage.
@Test
void shouldCreateTransferEmptyMessage() {
TransactionInfoDTO transferTransactionDTO = TestHelperVertx.loadTransactionInfoDTO("transferEmptyMessage.json");
TransferTransaction transferTransaction = (TransferTransaction) map(transferTransactionDTO);
validateStandaloneTransaction(transferTransaction, transferTransactionDTO);
Assertions.assertEquals("", transferTransaction.getMessage().get().getText());
}
use of io.nem.symbol.sdk.model.transaction.TransferTransaction in project nem2-sdk-java by nemtech.
the class TestHelper method basicTransfer.
public void basicTransfer(RepositoryType type, Account nemesisAccount, UnresolvedAddress recipient, BigInteger amount) {
TransferTransactionFactory factory = TransferTransactionFactory.create(getNetworkType(), getDeadline(), recipient, Collections.singletonList(getCurrency().createAbsolute(amount)));
factory.maxFee(maxFee);
TransferTransaction transferTransaction = factory.build();
TransferTransaction processedTransaction = announceAndValidate(type, nemesisAccount, transferTransaction);
Assertions.assertEquals(amount, processedTransaction.getMosaics().get(0).getAmount());
}
use of io.nem.symbol.sdk.model.transaction.TransferTransaction in project nem2-sdk-java by nemtech.
the class TransactionServiceIntegrationTest method testTransferCatCurrencyFromNemesis.
@ParameterizedTest
@EnumSource(RepositoryType.class)
public void testTransferCatCurrencyFromNemesis(RepositoryType type) {
String mosaicAlias = getNetworkCurrency().getNamespaceId().get().getFullName().get();
Account testAccount = helper().getTestAccount(type).getLeft();
String recipientAlias = "testaccount" + RandomUtils.nextInt(0, 10000);
helper().setAddressAlias(type, testAccount.getAddress(), recipientAlias);
String hash = transferUsingAliases(config().getNemesisAccount(), type, mosaicAlias, recipientAlias, BigInteger.TEN).getTransactionInfo().get().getHash().get();
List<Transaction> transactions = get(getTransactionService(type).resolveAliases(Collections.singletonList(hash)));
Assertions.assertEquals(1, transactions.size());
TransferTransaction resolvedTransaction = (TransferTransaction) transactions.get(0);
System.out.println(toJson(resolvedTransaction));
Assertions.assertEquals(testAccount.getAddress(), resolvedTransaction.getRecipient());
System.out.println(resolvedTransaction.getMosaics().get(0).getId());
Assertions.assertTrue(resolvedTransaction.getMosaics().get(0).getId() instanceof MosaicId);
Assertions.assertTrue(resolvedTransaction.getRecipient() instanceof Address);
}
use of io.nem.symbol.sdk.model.transaction.TransferTransaction in project nem2-sdk-java by nemtech.
the class TransactionServiceIntegrationTest method testTransferCustomCurrencyFromAccount1.
@ParameterizedTest
@EnumSource(RepositoryType.class)
public void testTransferCustomCurrencyFromAccount1(RepositoryType type) {
String mosaicAlias = ("testTransferCustomCurrencyFromAccount1" + RandomUtils.nextInt(0, 10000)).toLowerCase();
String recipientAlias = "testaccount" + RandomUtils.nextInt(0, 10000);
Account testAccount = helper.getTestAccount(type).getLeft();
MosaicId mosaicId = helper().createMosaic(testAccount, type, BigInteger.valueOf(10000), mosaicAlias);
helper().setAddressAlias(type, testAccount.getAddress(), recipientAlias);
String transferTransactionHash = transferUsingAliases(testAccount, type, mosaicAlias, recipientAlias, BigInteger.ONE).getTransactionInfo().get().getHash().get();
List<Transaction> transactions = get(getTransactionService(type).resolveAliases(Arrays.asList(transferTransactionHash)));
Assertions.assertEquals(1, transactions.size());
TransferTransaction resolvedTransaction = (TransferTransaction) transactions.get(0);
assertTransaction(mosaicId, resolvedTransaction, testAccount);
}
use of io.nem.symbol.sdk.model.transaction.TransferTransaction in project nem2-sdk-java by nemtech.
the class TransactionServiceIntegrationTest method transferUsingAliases.
private TransferTransaction transferUsingAliases(Account sender, RepositoryType type, String mosaicAlias, String recipientAlias, BigInteger amount) {
NamespaceId recipientNamespace = NamespaceId.createFromName(recipientAlias);
NamespaceId mosaicNamespace = NamespaceId.createFromName(mosaicAlias);
System.out.println("Sending " + amount + " Mosaic to: " + mosaicAlias);
TransferTransactionFactory factory = TransferTransactionFactory.create(getNetworkType(), getDeadline(), recipientNamespace, Collections.singletonList(new Mosaic(mosaicNamespace, amount))).message(new PlainMessage("E2ETest:TransactionServiceIntegrationTest"));
factory.maxFee(maxFee);
TransferTransaction transferTransaction = factory.build();
Assertions.assertTrue(transferTransaction.getMosaics().get(0).getId() instanceof NamespaceId);
Assertions.assertTrue(transferTransaction.getRecipient() instanceof NamespaceId);
TransferTransaction processedTransferTransaction = announceAndValidate(type, sender, transferTransaction);
Assertions.assertEquals(amount, processedTransferTransaction.getMosaics().get(0).getAmount());
System.out.println(toJson(processedTransferTransaction));
Assertions.assertTrue(processedTransferTransaction.getMosaics().get(0).getId() instanceof NamespaceId);
Assertions.assertTrue(processedTransferTransaction.getRecipient() instanceof NamespaceId);
return processedTransferTransaction;
}
Aggregations