Search in sources :

Example 16 with SignedTransaction

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

the class ListenerIntegrationTest method shouldReturnAggregateBondedAddedTransactionViaListener.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void shouldReturnAggregateBondedAddedTransactionViaListener(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());
    AggregateTransaction aggregateTransaction = get(transactionService.announceAggregateBonded(listener, signedTransaction).take(1));
    assertEquals(signedTransaction.getHash(), aggregateTransaction.getTransactionInfo().get().getHash().get());
}
Also used : Listener(io.nem.symbol.sdk.api.Listener) TransactionService(io.nem.symbol.sdk.api.TransactionService) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) 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)

Example 17 with SignedTransaction

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

the class ListenerIntegrationTest method shouldReturnUnconfirmedAddedTransactionViaListener.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void shouldReturnUnconfirmedAddedTransactionViaListener(RepositoryType type) {
    Listener listener = getListener(type);
    SignedTransaction signedTransaction = this.announceStandaloneTransferTransaction(type, this.getRecipient());
    Transaction transaction = get(listener.unconfirmedAdded(this.account.getAddress(), signedTransaction.getHash()).take(1));
    assertEquals(signedTransaction.getHash(), transaction.getTransactionInfo().get().getHash().get());
}
Also used : Listener(io.nem.symbol.sdk.api.Listener) 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) 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 18 with SignedTransaction

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

the class ListenerIntegrationTest method announceStandaloneTransferTransactionWithInsufficientBalance.

private SignedTransaction announceStandaloneTransferTransactionWithInsufficientBalance(RepositoryType type) {
    TransferTransaction transferTransaction = TransferTransactionFactory.create(getNetworkType(), getDeadline(), Address.generateRandom(getNetworkType()), Collections.singletonList(getNetworkCurrency().createRelative(new BigInteger("100000000000")))).message(new PlainMessage("test-message")).maxFee(maxFee).build();
    SignedTransaction signedTransaction = this.account.sign(transferTransaction, getGenerationHash());
    get(getTransactionRepository(type).announce(signedTransaction));
    return signedTransaction;
}
Also used : PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) BigInteger(java.math.BigInteger) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction)

Example 19 with SignedTransaction

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

the class ListenerIntegrationTest method shouldReturnConfirmedTransactionAddressRecipientViaListener.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void shouldReturnConfirmedTransactionAddressRecipientViaListener(RepositoryType type) {
    Listener listener = getListener(type);
    SignedTransaction signedTransaction = this.announceStandaloneTransferTransaction(type, this.getRecipient());
    Observable<Transaction> confirmed = listener.confirmed(this.getRecipient(), signedTransaction.getHash());
    Transaction transaction = get(confirmed.take(1));
    assertEquals(signedTransaction.getHash(), transaction.getTransactionInfo().get().getHash().get());
}
Also used : Listener(io.nem.symbol.sdk.api.Listener) 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) 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 20 with SignedTransaction

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

the class AggregateTransactionServiceTest method shouldReturnCorrectIsCompleteStatusForAggregatedCompleteTransaction2LevelsMultisigMultiinnerTransaction.

/*
   * MLMA - with multiple transaction Alice (account1): normal account Bob (multisig2) - Multisig
   * 2-1 (account1 && multisig1) Charles (multisig1) - Multisig 1-1 (account2 || account3) An
   * extra inner transaction to account4 (just to increase the complexity) Given signatories:
   * Account1 && Account4 Expecting incomplete as Bob needs 2 signatures (account1 && (account2 ||
   * account3))
   */
@Test
void shouldReturnCorrectIsCompleteStatusForAggregatedCompleteTransaction2LevelsMultisigMultiinnerTransaction() throws ExecutionException, InterruptedException {
    TransferTransaction transferTransaction = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), Address.generateRandom(networkType), Collections.emptyList()).message(new PlainMessage("test-message")).build();
    TransferTransaction transferTransaction2 = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), account2.getAddress(), Collections.emptyList()).message(new PlainMessage("test-message")).build();
    AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(networkType, new Deadline(BigInteger.ONE), Arrays.asList(transferTransaction.toAggregate(multisig2.getPublicAccount()), transferTransaction2.toAggregate(account4.getPublicAccount()))).build();
    SignedTransaction signedTransaction = account1.signTransactionWithCosignatories(aggregateTransaction, Collections.singletonList(account4), generationHash);
    Assertions.assertFalse(service.isComplete(signedTransaction).toFuture().get());
}
Also used : PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) Deadline(io.nem.symbol.sdk.model.transaction.Deadline) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) Test(org.junit.jupiter.api.Test)

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