Search in sources :

Example 1 with TransactionSearchCriteria

use of io.nem.symbol.sdk.api.TransactionSearchCriteria in project nem2-sdk-java by nemtech.

the class TransactionRepositoryVertxImplTest method searchTransactions.

@Test
public void searchTransactions() throws Exception {
    TransactionInfoDTO transferTransactionDTO = loadTransactionInfoDTO("standaloneTransferTransaction.json");
    PublicAccount publicAccount = Account.generateNewAccount(networkType).getPublicAccount();
    mockRemoteCall(toPage(transferTransactionDTO));
    Page<Transaction> transactions = repository.search(new TransactionSearchCriteria(TransactionGroup.UNCONFIRMED).signerPublicKey(publicAccount.getPublicKey())).toFuture().get();
    Assertions.assertEquals(TransactionType.TRANSFER, transactions.getData().get(0).getType());
    Assertions.assertEquals(TransactionGroup.UNCONFIRMED, transactions.getData().get(0).getGroup().get());
    Assertions.assertEquals(1, transactions.getData().size());
    Assertions.assertEquals(1, transactions.getPageNumber());
    Assertions.assertEquals(2, transactions.getPageSize());
}
Also used : 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) TestHelperVertx.loadTransactionInfoDTO(io.nem.symbol.sdk.infrastructure.vertx.TestHelperVertx.loadTransactionInfoDTO) TransactionInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.TransactionInfoDTO) AnnounceTransactionInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.AnnounceTransactionInfoDTO) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) Test(org.junit.jupiter.api.Test)

Example 2 with TransactionSearchCriteria

use of io.nem.symbol.sdk.api.TransactionSearchCriteria in project nem2-sdk-java by nemtech.

the class TransactionRepositoryVertxImplTest method searchTransactionsTransactionTypes.

@Test
public void searchTransactionsTransactionTypes() throws Exception {
    TransactionInfoDTO transferTransactionDTO = loadTransactionInfoDTO("standaloneTransferTransaction.json");
    mockRemoteCall(toPage(transferTransactionDTO));
    TransactionSearchCriteria criteria = new TransactionSearchCriteria(TransactionGroup.CONFIRMED).transactionTypes(Arrays.asList(TransactionType.NAMESPACE_METADATA, TransactionType.AGGREGATE_COMPLETE));
    Page<Transaction> transactions = repository.search(criteria).toFuture().get();
    Assertions.assertEquals(TransactionType.TRANSFER, transactions.getData().get(0).getType());
    Assertions.assertEquals(TransactionGroup.CONFIRMED, transactions.getData().get(0).getGroup().get());
    Assertions.assertEquals(1, transactions.getData().size());
    Assertions.assertEquals(1, transactions.getPageNumber());
    Assertions.assertEquals(2, transactions.getPageSize());
}
Also used : 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) TestHelperVertx.loadTransactionInfoDTO(io.nem.symbol.sdk.infrastructure.vertx.TestHelperVertx.loadTransactionInfoDTO) TransactionInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.TransactionInfoDTO) AnnounceTransactionInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.AnnounceTransactionInfoDTO) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) Test(org.junit.jupiter.api.Test)

Example 3 with TransactionSearchCriteria

use of io.nem.symbol.sdk.api.TransactionSearchCriteria 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);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) Arrays(java.util.Arrays) HashLockTransaction(io.nem.symbol.sdk.model.transaction.HashLockTransaction) HashLockTransactionFactory(io.nem.symbol.sdk.model.transaction.HashLockTransactionFactory) Account(io.nem.symbol.sdk.model.account.Account) EnumSource(org.junit.jupiter.params.provider.EnumSource) Disabled(org.junit.jupiter.api.Disabled) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) CosignatureTransaction(io.nem.symbol.sdk.model.transaction.CosignatureTransaction) TestInstance(org.junit.jupiter.api.TestInstance) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Observable(io.reactivex.Observable) BigInteger(java.math.BigInteger) Listener(io.nem.symbol.sdk.api.Listener) MultisigAccountModificationTransaction(io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction) MultisigAccountModificationTransactionFactory(io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransactionFactory) PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) TransactionGroup(io.nem.symbol.sdk.model.transaction.TransactionGroup) List(java.util.List) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) TransferTransactionFactory(io.nem.symbol.sdk.model.transaction.TransferTransactionFactory) Assertions(org.junit.jupiter.api.Assertions) AggregateTransactionFactory(io.nem.symbol.sdk.model.transaction.AggregateTransactionFactory) Address(io.nem.symbol.sdk.model.account.Address) Collections(java.util.Collections) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) Listener(io.nem.symbol.sdk.api.Listener) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) List(java.util.List) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) CosignatureTransaction(io.nem.symbol.sdk.model.transaction.CosignatureTransaction) 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 4 with TransactionSearchCriteria

use of io.nem.symbol.sdk.api.TransactionSearchCriteria in project nem2-sdk-java by nemtech.

the class TestnetTester method readTransactions.

private static void readTransactions(RepositoryFactory repositoryFactory) throws Exception {
    String generationHash = repositoryFactory.getGenerationHash().toFuture().get();
    NetworkType networkType = repositoryFactory.getNetworkType().toFuture().get();
    List<Transaction> transactions = repositoryFactory.createTransactionRepository().streamer().search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).order(OrderBy.DESC).transactionTypes(Arrays.asList(TransactionType.VOTING_KEY_LINK))).take(50).toList().blockingGet();
    transactions.forEach(t -> {
        System.out.println(t.getVersion());
        System.out.println(t.getTransactionInfo().get().getHash().get());
        System.out.println(t.createTransactionHash(ConvertUtils.toHex(t.serialize()), ConvertUtils.fromHexToBytes(generationHash)));
    });
}
Also used : VotingKeyLinkTransaction(io.nem.symbol.sdk.model.transaction.VotingKeyLinkTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) NetworkType(io.nem.symbol.sdk.model.network.NetworkType) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria)

Example 5 with TransactionSearchCriteria

use of io.nem.symbol.sdk.api.TransactionSearchCriteria in project nem2-sdk-java by nemtech.

the class TransactionSearchRepositoryIntegrationTest method searchBySignerPublicKeyInvalid.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchBySignerPublicKeyInvalid(RepositoryType type) {
    TransactionRepository transactionRepository = getTransactionRepository(type);
    TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
    TransactionSearchCriteria criteria = new TransactionSearchCriteria(TransactionGroup.CONFIRMED);
    PublicKey expectedSignerPublicKey = Account.generateNewAccount(getNetworkType()).getPublicAccount().getPublicKey();
    criteria.setSignerPublicKey(expectedSignerPublicKey);
    List<Transaction> transactions = get(streamer.search(criteria).toList().toObservable());
    Assertions.assertTrue(transactions.isEmpty());
    helper.assertById(transactionRepository, TransactionGroup.CONFIRMED, transactions);
}
Also used : SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) PublicKey(io.nem.symbol.core.crypto.PublicKey) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) TransactionPaginationStreamer(io.nem.symbol.sdk.api.TransactionPaginationStreamer) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

TransactionSearchCriteria (io.nem.symbol.sdk.api.TransactionSearchCriteria)31 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)31 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)29 TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)24 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)24 EnumSource (org.junit.jupiter.params.provider.EnumSource)24 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)21 TransactionPaginationStreamer (io.nem.symbol.sdk.api.TransactionPaginationStreamer)13 PublicAccount (io.nem.symbol.sdk.model.account.PublicAccount)12 Account (io.nem.symbol.sdk.model.account.Account)8 CosignatureSignedTransaction (io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction)8 BigInteger (java.math.BigInteger)7 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)6 TransactionGroup (io.nem.symbol.sdk.model.transaction.TransactionGroup)6 Test (org.junit.jupiter.api.Test)6 TransactionType (io.nem.symbol.sdk.model.transaction.TransactionType)5 PublicKey (io.nem.symbol.core.crypto.PublicKey)4 Address (io.nem.symbol.sdk.model.account.Address)4 Message (io.nem.symbol.sdk.model.message.Message)4 TransferTransactionFactory (io.nem.symbol.sdk.model.transaction.TransferTransactionFactory)4