Search in sources :

Example 31 with SignedTransaction

use of io.nem.symbol.sdk.model.transaction.SignedTransaction in project nem2-sdk-java by nemtech.

the class ListenerIntegrationTest method shouldReturnTransactionStatusGivenAddedViaListener.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void shouldReturnTransactionStatusGivenAddedViaListener(RepositoryType type) {
    Listener listener = getListener(type);
    SignedTransaction signedTransaction = this.announceStandaloneTransferTransactionWithInsufficientBalance(type);
    TransactionStatusError transactionHash = get(listener.status(this.account.getAddress(), signedTransaction.getHash()).take(1));
    assertEquals(signedTransaction.getHash(), transactionHash.getHash());
}
Also used : TransactionStatusError(io.nem.symbol.sdk.model.transaction.TransactionStatusError) Listener(io.nem.symbol.sdk.api.Listener) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 32 with SignedTransaction

use of io.nem.symbol.sdk.model.transaction.SignedTransaction in project nem2-sdk-java by nemtech.

the class ListenerIntegrationTest method shouldReturnCosignatureAddedViaListener.

@ParameterizedTest
@EnumSource(RepositoryType.class)
@Disabled
void shouldReturnCosignatureAddedViaListener(RepositoryType type) {
    Listener listener = getListener(type);
    RepositoryFactory repositoryFactory = getRepositoryFactory(type);
    TransactionService transactionService = new TransactionServiceImpl(repositoryFactory);
    Pair<SignedTransaction, SignedTransaction> pair = this.createAggregateBondedTransaction(type);
    System.out.println("Announcing HashLock transaction " + pair.getRight().getHash());
    get(transactionService.announce(listener, pair.getRight()));
    SignedTransaction signedTransaction = pair.getLeft();
    AggregateTransaction announcedTransaction = get(transactionService.announceAggregateBonded(listener, signedTransaction));
    assertEquals(signedTransaction.getHash(), announcedTransaction.getTransactionInfo().get().getHash().get());
    TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
    List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).transactionTypes(Collections.singletonList(TransactionType.AGGREGATE_BONDED)).signerPublicKey(this.cosignatoryAccount.getPublicAccount().getPublicKey()))).getData();
    AggregateTransaction transactionToCosign = (AggregateTransaction) transactions.get(0);
    this.announceCosignatureTransaction(transactionToCosign, type);
    CosignatureSignedTransaction cosignatureSignedTransaction = get(listener.cosignatureAdded(this.cosignatoryAccount.getAddress()).take(1));
    assertEquals(cosignatureSignedTransaction.getSigner(), this.cosignatoryAccount2.getPublicAccount());
}
Also used : CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) Listener(io.nem.symbol.sdk.api.Listener) TransactionService(io.nem.symbol.sdk.api.TransactionService) HashLockTransaction(io.nem.symbol.sdk.model.transaction.HashLockTransaction) CosignatureTransaction(io.nem.symbol.sdk.model.transaction.CosignatureTransaction) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Disabled(org.junit.jupiter.api.Disabled)

Example 33 with SignedTransaction

use of io.nem.symbol.sdk.model.transaction.SignedTransaction in project nem2-sdk-java by nemtech.

the class ListenerIntegrationTest method shouldReturnAggregateBondedRemovedTransactionViaListener.

@ParameterizedTest
@EnumSource(RepositoryType.class)
@Disabled
void shouldReturnAggregateBondedRemovedTransactionViaListener(RepositoryType type) {
    Listener listener = getListener(type);
    RepositoryFactory repositoryFactory = getRepositoryFactory(type);
    TransactionService transactionService = new TransactionServiceImpl(repositoryFactory);
    Pair<SignedTransaction, SignedTransaction> pair = this.createAggregateBondedTransaction(type);
    System.out.println("Announcing HashLock transaction " + pair.getRight().getHash());
    get(transactionService.announce(listener, pair.getRight()));
    SignedTransaction signedTransaction = pair.getLeft();
    System.out.println("Announcing Aggregate transaction " + signedTransaction.getHash());
    get(transactionService.announceAggregateBonded(listener, signedTransaction).take(1));
    String transactionHash = get(listener.aggregateBondedRemoved(this.account.getAddress()).take(1));
    assertEquals(signedTransaction.getHash(), transactionHash);
}
Also used : Listener(io.nem.symbol.sdk.api.Listener) TransactionService(io.nem.symbol.sdk.api.TransactionService) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Disabled(org.junit.jupiter.api.Disabled)

Example 34 with SignedTransaction

use of io.nem.symbol.sdk.model.transaction.SignedTransaction in project nem2-sdk-java by nemtech.

the class AggregateTransactionServiceIntegrationTest method isMultisigAccountModificationTransactionAdditionComplete.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void isMultisigAccountModificationTransactionAdditionComplete(RepositoryType type) {
    Account multisigAccount = helper().getMultisigAccount(type).getKey();
    Account cosignatoryAccount = config().getCosignatoryAccount();
    Account cosignatory2Account = config().getCosignatory2Account();
    List<Account> accounts = Arrays.asList(cosignatoryAccount, cosignatory2Account);
    List<UnresolvedAddress> additions = accounts.stream().map(Account::getAddress).collect(Collectors.toList());
    MultisigAccountModificationTransaction multisigAccountModificationTransaction = MultisigAccountModificationTransactionFactory.create(getNetworkType(), getDeadline(), (byte) 1, (byte) 1, additions, Collections.emptyList()).maxFee(maxFee).build();
    AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(getNetworkType(), getDeadline(), Collections.singletonList(multisigAccountModificationTransaction.toAggregate(multisigAccount.getPublicAccount()))).maxFee(maxFee).build();
    SignedTransaction signedAggregateTransaction = aggregateTransaction.signTransactionWithCosigners(multisigAccount, accounts, getGenerationHash());
    AggregateTransactionService aggregateTransactionService = new AggregateTransactionServiceImpl(getRepositoryFactory(type));
    Assertions.assertTrue(get(aggregateTransactionService.isComplete(signedAggregateTransaction)));
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) MultisigAccountModificationTransaction(io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction) UnresolvedAddress(io.nem.symbol.sdk.model.account.UnresolvedAddress) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) AggregateTransactionService(io.nem.symbol.sdk.api.AggregateTransactionService) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 35 with SignedTransaction

use of io.nem.symbol.sdk.model.transaction.SignedTransaction in project nem2-sdk-java by nemtech.

the class AggregateTransactionServiceIntegrationTest method isTransferFromMultisigComplete.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void isTransferFromMultisigComplete(RepositoryType type) {
    Account multisigAccount = helper().getMultisigAccount(type).getKey();
    Account cosignatoryAccount = config().getCosignatoryAccount();
    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, Arrays.asList(cosignatoryAccount, config().getTestAccount()), getGenerationHash());
    AggregateTransactionService aggregateTransactionService = new AggregateTransactionServiceImpl(getRepositoryFactory(type));
    Assertions.assertTrue(get(aggregateTransactionService.isComplete(signedAggregateTransaction)));
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) AggregateTransactionService(io.nem.symbol.sdk.api.AggregateTransactionService) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)57 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)40 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)40 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)31 Test (org.junit.jupiter.api.Test)24 Deadline (io.nem.symbol.sdk.model.transaction.Deadline)21 CosignatureSignedTransaction (io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction)20 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 EnumSource (org.junit.jupiter.params.provider.EnumSource)20 HashLockTransaction (io.nem.symbol.sdk.model.transaction.HashLockTransaction)18 Account (io.nem.symbol.sdk.model.account.Account)17 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)16 Listener (io.nem.symbol.sdk.api.Listener)12 MultisigAccountModificationTransaction (io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction)12 BigInteger (java.math.BigInteger)11 Address (io.nem.symbol.sdk.model.account.Address)10 TransactionService (io.nem.symbol.sdk.api.TransactionService)8 AggregateTransactionService (io.nem.symbol.sdk.api.AggregateTransactionService)7 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)7 Mosaic (io.nem.symbol.sdk.model.mosaic.Mosaic)6