use of io.nem.symbol.sdk.model.transaction.AggregateTransaction in project nem2-sdk-java by nemtech.
the class TransactionServiceTest method announceAggregateBonded.
@Test
void announceAggregateBonded() throws ExecutionException, InterruptedException {
TransferTransaction transaction1 = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), Address.generateRandom(networkType), Arrays.asList(new Mosaic(new MosaicId(new BigInteger("95442763262823")), BigInteger.valueOf(100)))).message(new PlainMessage("Some Message")).signer(account.getPublicAccount()).build();
AggregateTransaction aggregateTransaction = AggregateTransactionFactory.create(TransactionType.AGGREGATE_BONDED, networkType, new Deadline(BigInteger.ONE), Collections.singletonList(transaction1), Collections.emptyList()).build();
String generationHash = "abc";
SignedTransaction aggregateSignedTransaction = aggregateTransaction.signWith(account, generationHash);
TransactionAnnounceResponse aggregateTransactionAnnounceResponse = new TransactionAnnounceResponse("Aggregate Some Message");
Mockito.when(transactionRepositoryMock.announceAggregateBonded(Mockito.eq(aggregateSignedTransaction))).thenReturn(Observable.just(aggregateTransactionAnnounceResponse));
Mockito.when(listener.aggregateBondedAddedOrError(Mockito.eq(account.getAddress()), Mockito.eq(aggregateSignedTransaction.getHash()))).thenReturn(Observable.just(aggregateTransaction));
Observable<AggregateTransaction> announcedTransaction = service.announceAggregateBonded(listener, aggregateSignedTransaction);
Assertions.assertEquals(aggregateTransaction, announcedTransaction.toFuture().get());
}
use of io.nem.symbol.sdk.model.transaction.AggregateTransaction in project nem2-sdk-java by nemtech.
the class AggregateTransactionServiceTest method shouldReturnCorrectIsCompleteStatuTrueMultipleNormalAccount.
/*
* ACT Alice: account1 Bob: account4 An escrow contract is signed by all the participants
* (normal accounts) Given Alice defined the following escrow contract: | sender | recipient |
* type | data | | Alice | Bob | send-an-asset | 1 concert.ticket | | Bob | Alice |
* send-an-asset | 20 euros | And Bob signs the contract And Alice signs the contract Then the
* contract should appear as complete
*/
@Test
void shouldReturnCorrectIsCompleteStatuTrueMultipleNormalAccount() throws ExecutionException, InterruptedException {
TransferTransaction transferTransaction = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), account1.getAddress(), Collections.emptyList()).message(new PlainMessage("test-message")).build();
TransferTransaction transferTransaction2 = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), account4.getAddress(), Collections.emptyList()).message(new PlainMessage("test-message")).build();
AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(networkType, new Deadline(BigInteger.ONE), Arrays.asList(transferTransaction.toAggregate(account4.getPublicAccount()), transferTransaction2.toAggregate(account1.getPublicAccount()))).build();
SignedTransaction signedTransaction1 = aggregateTransaction.signWith(account1, generationHash);
Assertions.assertFalse(service.isComplete(signedTransaction1).toFuture().get());
SignedTransaction signedTransaction2 = account1.signTransactionWithCosignatories(aggregateTransaction, Collections.singletonList(account4), generationHash);
Assertions.assertTrue(service.isComplete(signedTransaction2).toFuture().get());
}
use of io.nem.symbol.sdk.model.transaction.AggregateTransaction in project nem2-sdk-java by nemtech.
the class AggregateTransactionServiceTest method shouldReturnCorrectIsCompleteStatusTRUEMultisigSingleLevel.
/*
* ACT - Multisig single level Alice (account1): initiate an transfer to Bob Bob (multisig3): is
* a 2/2 multisig account (account2 && account3)
*/
@Test
void shouldReturnCorrectIsCompleteStatusTRUEMultisigSingleLevel() throws ExecutionException, InterruptedException {
TransferTransaction transferTransaction = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), account4.getAddress(), Collections.emptyList()).message(new PlainMessage("test-message")).build();
AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(networkType, new Deadline(BigInteger.ONE), Collections.singletonList(transferTransaction.toAggregate(multisig3.getPublicAccount()))).build();
SignedTransaction signedTransactionNoCosignatures = account2.sign(aggregateTransaction, generationHash);
SignedTransaction signedTransaction1 = account2.signTransactionGivenSignatures(aggregateTransaction, Collections.singletonList(account3.signCosignatureTransaction(signedTransactionNoCosignatures.getHash())), generationHash);
SignedTransaction signedTransaction2 = account2.signTransactionWithCosignatories(aggregateTransaction, Collections.singletonList(account3), generationHash);
Assertions.assertEquals(signedTransaction1.getPayload(), signedTransaction2.getPayload());
Assertions.assertEquals(signedTransaction1.getHash(), signedTransaction2.getHash());
Assertions.assertEquals(signedTransaction1.getSigner(), signedTransaction2.getSigner());
Assertions.assertEquals(signedTransaction1.getType(), signedTransaction2.getType());
Assertions.assertTrue(service.isComplete(signedTransaction1).toFuture().get());
Assertions.assertTrue(service.isComplete(signedTransaction2).toFuture().get());
}
use of io.nem.symbol.sdk.model.transaction.AggregateTransaction in project nem2-sdk-java by nemtech.
the class AggregateTransactionServiceTest method shouldReturnIsCompleteTrueForAggregatedCompleteTransaction2LevelsMultisig.
/*
* MLMA Alice (account1): normal account Bob (multisig2) - Multisig 2-1 (account1 && multisig1)
* Charles (multisig1) - Multisig 1-1 (account2 || account3) Given signatories: Account1 &&
* Account4 Expecting complete as Bob needs 2 signatures (account1 && (account2 || account3))
*/
@Test
void shouldReturnIsCompleteTrueForAggregatedCompleteTransaction2LevelsMultisig() throws ExecutionException, InterruptedException {
TransferTransaction transferTransaction = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), Address.generateRandom(networkType), Collections.emptyList()).message(new PlainMessage("test-message")).build();
AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(networkType, new Deadline(BigInteger.ONE), Collections.singletonList(transferTransaction.toAggregate(multisig2.getPublicAccount()))).build();
SignedTransaction signedTransaction = account1.signTransactionWithCosignatories(aggregateTransaction, Collections.singletonList(account2), generationHash);
Assertions.assertTrue(service.isComplete(signedTransaction).toFuture().get());
}
use of io.nem.symbol.sdk.model.transaction.AggregateTransaction in project nem2-sdk-java by nemtech.
the class AggregateTransactionServiceTest method shouldUseMinRemovalForMultisigAccountValidationIfInnerTransactionIsModifyMultisigRemove.
/*
* If the inner transaction is issued to a multisig account and the inner transaction itself is
* a ModifyMultiSigAccountTransaction - Removal The validator should use minRemoval value rather
* than minApproval value to determine if the act is complete or not
*/
@Test
void shouldUseMinRemovalForMultisigAccountValidationIfInnerTransactionIsModifyMultisigRemove() throws ExecutionException, InterruptedException {
MultisigAccountModificationTransaction modifyMultisigTransaction = MultisigAccountModificationTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), (byte) 1, (byte) 1, Collections.emptyList(), Collections.singletonList(account1.getAddress())).build();
AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(networkType, new Deadline(BigInteger.ONE), Collections.singletonList(modifyMultisigTransaction.toAggregate(multisig2.getPublicAccount()))).build();
SignedTransaction signedTransaction = aggregateTransaction.signWith(account2, generationHash);
Assertions.assertTrue(service.isComplete(signedTransaction).toFuture().get());
}
Aggregations