use of io.nem.symbol.sdk.model.transaction.HashLockTransaction in project nem2-sdk-java by nemtech.
the class TransactionServiceTest method announceHashLockAggregateBonded.
@Test
void announceHashLockAggregateBonded() throws ExecutionException, InterruptedException {
TransferTransaction transaction1 = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), Address.generateRandom(networkType), Collections.singletonList(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);
HashLockTransaction hashLockTransaction = HashLockTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), Currency.CAT_CURRENCY.createRelative(BigInteger.valueOf(10)), BigInteger.valueOf(100), aggregateSignedTransaction.getHash()).build();
SignedTransaction hashLockSignedTranscation = hashLockTransaction.signWith(account, generationHash);
TransactionAnnounceResponse aggregateTransactionAnnounceResponse = new TransactionAnnounceResponse("Aggregate Some Message");
TransactionAnnounceResponse hashTransactionAnnounceResponse = new TransactionAnnounceResponse("Hash Some Message");
Mockito.when(transactionRepositoryMock.announceAggregateBonded(Mockito.eq(aggregateSignedTransaction))).thenReturn(Observable.just(aggregateTransactionAnnounceResponse));
Mockito.when(transactionRepositoryMock.announce(Mockito.eq(hashLockSignedTranscation))).thenReturn(Observable.just(hashTransactionAnnounceResponse));
Mockito.when(listener.confirmedOrError(Mockito.eq(account.getAddress()), Mockito.eq(hashLockSignedTranscation.getHash()))).thenReturn(Observable.just(hashLockTransaction));
Mockito.when(listener.aggregateBondedAddedOrError(Mockito.eq(account.getAddress()), Mockito.eq(aggregateSignedTransaction.getHash()))).thenReturn(Observable.just(aggregateTransaction));
Observable<AggregateTransaction> announcedTransaction = service.announceHashLockAggregateBonded(listener, hashLockSignedTranscation, aggregateSignedTransaction);
Assertions.assertEquals(aggregateTransaction, announcedTransaction.toFuture().get());
}
Aggregations