Search in sources :

Example 16 with EnumSource

use of org.junit.jupiter.params.provider.EnumSource in project nem2-sdk-java by nemtech.

the class TransactionSearchRepositoryIntegrationTest method searchEmbeddedTransactionType.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchEmbeddedTransactionType(RepositoryType type) {
    TransactionRepository transactionRepository = getTransactionRepository(type);
    TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
    TransactionSearchCriteria criteria = new TransactionSearchCriteria(TransactionGroup.CONFIRMED);
    criteria.setEmbedded(true);
    List<Transaction> transactions = get(streamer.search(criteria).toList().toObservable());
    Assertions.assertFalse(transactions.isEmpty());
    transactions.stream().forEach(t -> {
        Transaction storedById = get(transactionRepository.getTransaction(TransactionGroup.CONFIRMED, t.getRecordId().get()));
        Assertions.assertEquals(storedById.getRecordId().get(), t.getRecordId().get());
        if (t.getTransactionInfo().get().getHash().isPresent()) {
            Transaction transaction = get(transactionRepository.getTransaction(TransactionGroup.CONFIRMED, t.getTransactionInfo().get().getHash().get()));
            Assertions.assertEquals(storedById.getRecordId().get(), t.getRecordId().get());
            Assertions.assertEquals(t.getTransactionInfo().get().getHash().get(), t.getTransactionInfo().get().getHash().get());
        } else {
            Assertions.assertEquals(0, t.getMaxFee().intValue());
        }
    });
}
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) 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)

Example 17 with EnumSource

use of org.junit.jupiter.params.provider.EnumSource in project nem2-sdk-java by nemtech.

the class TransferTransactionIntegrationTest method standaloneTransferTransactionEncryptedMessage.

@ParameterizedTest
@EnumSource(RepositoryType.class)
public void standaloneTransferTransactionEncryptedMessage(RepositoryType type) throws Exception {
    this.helper().sendMosaicFromNemesis(type, getRecipient(), false);
    String namespaceName = "standaloneTransferTransactionEncryptedMessagealias".toLowerCase();
    NamespaceId recipient = setAddressAlias(type, getRecipient(), namespaceName);
    System.out.println(recipient.getIdAsHex());
    Assertions.assertEquals("9960629109A48AFBC0000000000000000000000000000000", recipient.encoded(getNetworkType()));
    String message = "E2ETest:standaloneTransferTransaction:message 漢字";
    KeyPair senderKeyPair = KeyPair.random();
    KeyPair recipientKeyPair = KeyPair.random();
    Message encryptedMessage = EncryptedMessage.create(message, senderKeyPair.getPrivateKey(), recipientKeyPair.getPublicKey());
    Currency networkCurrency = getNetworkCurrency();
    Mosaic mosaic = new Mosaic(networkCurrency.getNamespaceId().get(), BigInteger.valueOf(10202020));
    TransferTransaction transferTransaction = TransferTransactionFactory.create(getNetworkType(), getDeadline(), recipient, Collections.singletonList(mosaic)).message(encryptedMessage).maxFee(maxFee).build();
    TransferTransaction processed = announceAndValidate(type, signerAccount, transferTransaction);
    assertTransferTransactions(transferTransaction, processed);
    assertEncryptedMessageTransaction(message, senderKeyPair, recipientKeyPair, processed);
    TransferTransaction restTransaction = (TransferTransaction) get(getRepositoryFactory(type).createTransactionRepository().getTransaction(TransactionGroup.CONFIRMED, processed.getTransactionInfo().get().getHash().get()));
    assertTransferTransactions(transferTransaction, restTransaction);
    assertEncryptedMessageTransaction(message, senderKeyPair, recipientKeyPair, restTransaction);
}
Also used : KeyPair(io.nem.symbol.core.crypto.KeyPair) Message(io.nem.symbol.sdk.model.message.Message) EncryptedMessage(io.nem.symbol.sdk.model.message.EncryptedMessage) PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) PersistentHarvestingDelegationMessage(io.nem.symbol.sdk.model.message.PersistentHarvestingDelegationMessage) Currency(io.nem.symbol.sdk.model.mosaic.Currency) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Mosaic(io.nem.symbol.sdk.model.mosaic.Mosaic) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 18 with EnumSource

use of org.junit.jupiter.params.provider.EnumSource in project nem2-sdk-java by nemtech.

the class TransferTransactionIntegrationTest method standaloneCreatePersistentDelegationRequestTransaction.

@ParameterizedTest
@EnumSource(RepositoryType.class)
public void standaloneCreatePersistentDelegationRequestTransaction(RepositoryType type) {
    KeyPair signingKeyPair = KeyPair.random();
    KeyPair vrfPrivateKey = KeyPair.random();
    KeyPair recipientKeyPair = KeyPair.random();
    TransferTransaction transferTransaction = TransferTransactionFactory.createPersistentDelegationRequestTransaction(getNetworkType(), getDeadline(), signingKeyPair.getPrivateKey(), vrfPrivateKey.getPrivateKey(), recipientKeyPair.getPublicKey()).maxFee(maxFee).build();
    TransferTransaction processed = announceAndValidate(type, signerAccount, transferTransaction);
    assertPersistentDelegationTransaction(recipientKeyPair, signingKeyPair, vrfPrivateKey, processed);
    TransferTransaction restTransaction = (TransferTransaction) get(getRepositoryFactory(type).createTransactionRepository().getTransaction(TransactionGroup.CONFIRMED, processed.getTransactionInfo().get().getHash().get()));
    assertPersistentDelegationTransaction(recipientKeyPair, signingKeyPair, vrfPrivateKey, restTransaction);
}
Also used : KeyPair(io.nem.symbol.core.crypto.KeyPair) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 19 with EnumSource

use of org.junit.jupiter.params.provider.EnumSource in project nem2-sdk-java by nemtech.

the class TransferTransactionIntegrationTest method transferTransactionNotEnoughFundAccount.

@ParameterizedTest
@EnumSource(RepositoryType.class)
public void transferTransactionNotEnoughFundAccount(RepositoryType type) {
    Address recipient = config().getTestAccount2().getAddress();
    NetworkType networkType = getNetworkType();
    Account account = Account.generateNewAccount(networkType);
    TransferTransaction transferTransaction = TransferTransactionFactory.create(getNetworkType(), getDeadline(), recipient, Collections.singletonList(getNetworkCurrency().createAbsolute(BigInteger.valueOf(1000000000)))).message(new PlainMessage("")).maxFee(maxFee).build();
    IllegalArgumentException exceptions = Assertions.assertThrows(IllegalArgumentException.class, () -> announceAndValidate(type, account, transferTransaction));
    Assertions.assertTrue(exceptions.getMessage().contains("Failure_Core_Insufficient_Balance"));
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) UnresolvedAddress(io.nem.symbol.sdk.model.account.UnresolvedAddress) Address(io.nem.symbol.sdk.model.account.Address) PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) NetworkType(io.nem.symbol.sdk.model.network.NetworkType) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 20 with EnumSource

use of org.junit.jupiter.params.provider.EnumSource in project nem2-sdk-java by nemtech.

the class VrfKeyLinkTransactionIntegrationTest method basicAnnounce.

@ParameterizedTest
@EnumSource(RepositoryType.class)
public void basicAnnounce(RepositoryType type) {
    Account account = config().getNemesisAccount2();
    PublicKey linkedPublicKey = PublicKey.fromHexString("F5D0AAD909CFBC810A3F888C33C57A9051AE1A59D1CDA872A8B90BCA7EF2D34A");
    VrfKeyLinkTransaction linkTransaction = VrfKeyLinkTransactionFactory.create(getNetworkType(), getDeadline(), linkedPublicKey, LinkAction.LINK).maxFee(maxFee).build();
    announceAndValidate(type, account, linkTransaction);
    VrfKeyLinkTransaction unlinkTransaction = VrfKeyLinkTransactionFactory.create(getNetworkType(), getDeadline(), linkedPublicKey, LinkAction.UNLINK).maxFee(maxFee).build();
    announceAndValidate(type, account, unlinkTransaction);
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) VrfKeyLinkTransaction(io.nem.symbol.sdk.model.transaction.VrfKeyLinkTransaction) PublicKey(io.nem.symbol.core.crypto.PublicKey) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

EnumSource (org.junit.jupiter.params.provider.EnumSource)382 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)378 Account (io.nem.symbol.sdk.model.account.Account)40 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)38 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)34 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)34 Address (io.nem.symbol.sdk.model.account.Address)30 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)27 TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)26 TransactionSearchCriteria (io.nem.symbol.sdk.api.TransactionSearchCriteria)26 BigInteger (java.math.BigInteger)25 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)23 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)23 EntityUpdates (org.neo4j.storageengine.api.EntityUpdates)21 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)19 Path (java.nio.file.Path)18 ArrayList (java.util.ArrayList)16 Listener (io.nem.symbol.sdk.api.Listener)15 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)15 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)14