Search in sources :

Example 41 with TransferTransaction

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());
}
Also used : TransactionInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.TransactionInfoDTO) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Test(org.junit.jupiter.api.Test)

Example 42 with TransferTransaction

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());
}
Also used : TransferTransactionFactory(io.nem.symbol.sdk.model.transaction.TransferTransactionFactory) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction)

Example 43 with TransferTransaction

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);
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Address(io.nem.symbol.sdk.model.account.Address) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 44 with TransferTransaction

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);
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 45 with TransferTransaction

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;
}
Also used : PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) TransferTransactionFactory(io.nem.symbol.sdk.model.transaction.TransferTransactionFactory) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Mosaic(io.nem.symbol.sdk.model.mosaic.Mosaic)

Aggregations

TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)63 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)48 Test (org.junit.jupiter.api.Test)37 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)35 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)31 Deadline (io.nem.symbol.sdk.model.transaction.Deadline)28 Account (io.nem.symbol.sdk.model.account.Account)18 Mosaic (io.nem.symbol.sdk.model.mosaic.Mosaic)17 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)14 EnumSource (org.junit.jupiter.params.provider.EnumSource)14 Address (io.nem.symbol.sdk.model.account.Address)13 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)13 PublicAccount (io.nem.symbol.sdk.model.account.PublicAccount)10 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)8 BigInteger (java.math.BigInteger)8 ArrayList (java.util.ArrayList)8 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)7 HashLockTransaction (io.nem.symbol.sdk.model.transaction.HashLockTransaction)7 TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)5 TransactionSearchCriteria (io.nem.symbol.sdk.api.TransactionSearchCriteria)5