use of io.nem.symbol.sdk.api.TransactionRepository in project nem2-sdk-java by nemtech.
the class TransactionRepositoryIntegrationTest method setup.
@BeforeAll
void setup() {
RepositoryType type = RepositoryType.VERTX;
TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
Address recipient = getRecipient();
String message = "someMessage";
TransferTransaction transferTransaction = TransferTransactionFactory.create(getNetworkType(), getDeadline(), recipient, Collections.singletonList(getNetworkCurrency().createAbsolute(BigInteger.valueOf(1)))).message(new PlainMessage(message)).maxFee(maxFee).build();
TransferTransaction processed = announceAndValidate(type, config().getDefaultAccount(), transferTransaction);
Assertions.assertEquals(message, processed.getMessage().get().getText());
PublicAccount account = config().getDefaultAccount().getPublicAccount();
List<Transaction> allTransactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).order(OrderBy.DESC).signerPublicKey(account.getPublicKey()))).getData();
List<Transaction> transactions = allTransactions.stream().filter(t -> t.getType() == TransactionType.TRANSFER).collect(Collectors.toList());
Assertions.assertTrue(allTransactions.size() > 0);
Assertions.assertTrue(transactions.size() > 0);
transactionHash = transactions.get(0).getTransactionInfo().get().getHash().get();
}
use of io.nem.symbol.sdk.api.TransactionRepository in project nem2-sdk-java by nemtech.
the class BlockServiceIntegrationTest method isValidTransactionInBlock.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void isValidTransactionInBlock(RepositoryType type) {
BigInteger height = BigInteger.ONE;
RepositoryFactory repositoryFactory = getRepositoryFactory(type);
TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).height(height).pageNumber(1))).getData();
BlockService service = new BlockServiceImpl(repositoryFactory);
transactions.forEach(t -> {
String hash = t.getTransactionInfo().get().getHash().get();
Assertions.assertNotNull(hash);
Boolean valid = get(service.isValidTransactionInBlock(height, hash));
Assertions.assertTrue(valid);
});
}
use of io.nem.symbol.sdk.api.TransactionRepository in project nem2-sdk-java by nemtech.
the class AccountRepositoryIntegrationTest method outgoingTransactionsById.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void outgoingTransactionsById(RepositoryType type) {
TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
Account account = config().getDefaultAccount();
List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).signerPublicKey(account.getPublicAccount().getPublicKey()).pageSize(10))).getData();
Assertions.assertTrue(transactions.size() > 1);
String id = transactions.get(1).getTransactionInfo().get().getId().get();
List<Transaction> transactions2 = get(transactionRepository.getTransactions(TransactionGroup.CONFIRMED, Arrays.asList(id)));
Assertions.assertEquals(1, transactions2.size());
transactions2.forEach(t -> Assertions.assertEquals(id, t.getTransactionInfo().get().getId().get()));
}
use of io.nem.symbol.sdk.api.TransactionRepository in project nem2-sdk-java by nemtech.
the class AccountRepositoryIntegrationTest method getTransactionById.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void getTransactionById(RepositoryType type) {
TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
Account account = config().getDefaultAccount();
List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).signerPublicKey(account.getPublicAccount().getPublicKey()).pageSize(10))).getData();
Assertions.assertTrue(transactions.size() > 0);
String id = transactions.get(1).getTransactionInfo().get().getId().get();
List<Transaction> transactions2 = get(transactionRepository.getTransactions(TransactionGroup.CONFIRMED, Arrays.asList(id)));
Assertions.assertEquals(1, transactions2.size());
transactions2.forEach(t -> Assertions.assertEquals(id, t.getTransactionInfo().get().getId().get()));
}
use of io.nem.symbol.sdk.api.TransactionRepository in project nem2-sdk-java by nemtech.
the class MultisignIntegrationTest method shouldReturnCosignatureAddedViaListener2.
@Disabled
@ParameterizedTest
@EnumSource(RepositoryType.class)
void shouldReturnCosignatureAddedViaListener2(RepositoryType type) {
Listener listener = getListener(type);
RepositoryFactory repositoryFactory = getRepositoryFactory(type);
TransactionRepository transactionRepository = repositoryFactory.createTransactionRepository();
SignedTransaction signedAggregatedTx = createSignedAggregatedBondTransaction(multisigAccount, cosignAccount1, account2.getAddress());
Object finalObject = get(createHashLockTransactionAndAnnounce(type, signedAggregatedTx, cosignAccount1).flatMap(t -> {
System.out.println("hash lock finished");
TransactionServiceImpl transactionService = new TransactionServiceImpl(getRepositoryFactory(type));
return transactionService.announceAggregateBonded(listener, signedAggregatedTx).flatMap(a -> {
System.out.println("Aggregate bonded finished");
return repositoryFactory.createTransactionRepository().search(new TransactionSearchCriteria(TransactionGroup.PARTIAL).signerPublicKey(cosignAccount1.getPublicAccount().getPublicKey())).flatMap((page) -> {
List<Transaction> transactions = page.getData();
System.out.println("partialTransactions " + transactions.size());
AggregateTransaction transactionToCosign = (AggregateTransaction) transactions.get(0);
CosignatureTransaction cosignatureTransaction = CosignatureTransaction.create(transactionToCosign);
CosignatureSignedTransaction cosignatureSignedTransaction = cosignAccount2.signCosignatureTransaction(cosignatureTransaction);
return transactionRepository.announceAggregateBondedCosignature(cosignatureSignedTransaction).flatMap(r -> {
System.out.println("announceAggregateBondedCosignature " + r);
return listener.cosignatureAdded(cosignAccount1.getAddress());
});
});
});
}));
System.out.println(finalObject.getClass());
Assertions.assertNull(finalObject);
}
Aggregations