Search in sources :

Example 41 with EnumSource

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

the class NamespaceRegistrationIntegrationTest method aggregateRootRegisterNamespaceTransaction.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void aggregateRootRegisterNamespaceTransaction(RepositoryType type) {
    String namespaceName = "test-root-namespace-" + Double.valueOf(Math.floor(Math.random() * 10000)).intValue();
    NamespaceRegistrationTransaction namespaceRegistrationTransaction = NamespaceRegistrationTransactionFactory.createRootNamespace(getNetworkType(), getDeadline(), namespaceName, helper().getDuration()).maxFee(maxFee).build();
    announceAggregateAndValidate(type, namespaceRegistrationTransaction, this.account);
    rootNamespaceId = namespaceRegistrationTransaction.getNamespaceId();
    sleep(1000);
    NamespaceInfo namespaceInfo = get(getRepositoryFactory(type).createNamespaceRepository().getNamespace(namespaceRegistrationTransaction.getNamespaceId()));
    Assertions.assertEquals(this.account.getAddress(), namespaceInfo.getOwnerAddress());
    Assertions.assertEquals(namespaceRegistrationTransaction.getNamespaceId(), namespaceInfo.getId());
}
Also used : NamespaceInfo(io.nem.symbol.sdk.model.namespace.NamespaceInfo) NamespaceRegistrationTransaction(io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 42 with EnumSource

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

the class NamespaceRegistrationIntegrationTest method standaloneRootRegisterNamespaceTransaction.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void standaloneRootRegisterNamespaceTransaction(RepositoryType type) {
    String namespaceName = "test-root-namespace-" + Double.valueOf(Math.floor(Math.random() * 10000)).intValue();
    NamespaceRegistrationTransaction namespaceRegistrationTransaction = NamespaceRegistrationTransactionFactory.createRootNamespace(getNetworkType(), getDeadline(), namespaceName, helper().getDuration()).maxFee(maxFee).build();
    announceAndValidate(type, this.account, namespaceRegistrationTransaction);
    rootNamespaceId = namespaceRegistrationTransaction.getNamespaceId();
    sleep(1000);
    NamespaceInfo namespaceInfo = get(getRepositoryFactory(type).createNamespaceRepository().getNamespace(namespaceRegistrationTransaction.getNamespaceId()));
    Assertions.assertEquals(this.account.getAddress(), namespaceInfo.getOwnerAddress());
    Assertions.assertEquals(namespaceRegistrationTransaction.getNamespaceId(), namespaceInfo.getId());
}
Also used : NamespaceInfo(io.nem.symbol.sdk.model.namespace.NamespaceInfo) NamespaceRegistrationTransaction(io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 43 with EnumSource

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

the class SecretLockSecretProofTransactionIntegrationTest method aggregateSecretLockTransaction.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void aggregateSecretLockTransaction(RepositoryType type) {
    byte[] secretBytes = RandomUtils.generateRandomBytes(20);
    byte[] result = Hashes.sha3_256(secretBytes);
    String secret = ConvertUtils.toHex(result);
    Address recipient = config().getTestAccount2().getAddress();
    SecretLockTransaction transaction = SecretLockTransactionFactory.create(getNetworkType(), getDeadline(), getNetworkCurrency().createRelative(BigInteger.valueOf(10)), BigInteger.valueOf(100), LockHashAlgorithm.SHA3_256, secret, recipient).maxFee(maxFee).build();
    announceAggregateAndValidate(type, transaction, account);
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) SecretLockTransaction(io.nem.symbol.sdk.model.transaction.SecretLockTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 44 with EnumSource

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

the class SecretLockSecretProofTransactionIntegrationTest method standaloneSecretProofTransaction.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void standaloneSecretProofTransaction(RepositoryType type) {
    byte[] secretBytes = RandomUtils.generateRandomBytes(20);
    byte[] result = Hashes.sha3_256(secretBytes);
    String secret = ConvertUtils.toHex(result);
    String proof = ConvertUtils.toHex(secretBytes);
    Address recipient = config().getTestAccount2().getAddress();
    SecretLockTransaction secretLockTransaction = SecretLockTransactionFactory.create(getNetworkType(), getDeadline(), getNetworkCurrency().createRelative(BigInteger.valueOf(10)), BigInteger.valueOf(100), LockHashAlgorithm.SHA3_256, secret, recipient).maxFee(maxFee).build();
    announceAndValidate(type, account, secretLockTransaction);
    SecretProofTransaction secretProofTransaction = SecretProofTransactionFactory.create(getNetworkType(), getDeadline(), LockHashAlgorithm.SHA3_256, recipient, secret, proof).maxFee(maxFee).build();
    announceAndValidate(type, account, secretProofTransaction);
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) SecretProofTransaction(io.nem.symbol.sdk.model.transaction.SecretProofTransaction) SecretLockTransaction(io.nem.symbol.sdk.model.transaction.SecretLockTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 45 with EnumSource

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

the class AccountRepositoryIntegrationTest method outgoingTransactions.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void outgoingTransactions(RepositoryType type) {
    TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
    PublicAccount recipient = this.helper().getTestAccount(type).getLeft().getPublicAccount();
    List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).transactionTypes(Collections.singletonList(TransactionType.TRANSFER)).recipientAddress(recipient.getAddress()))).getData();
    System.out.println(transactions.size());
    transactions.forEach(transaction -> {
        assertTransaction(transaction, null);
        TransferTransaction transferTransaction = (TransferTransaction) transaction;
        Assertions.assertEquals(recipient.getAddress(), transferTransaction.getRecipient());
    });
}
Also used : Transaction(io.nem.symbol.sdk.model.transaction.Transaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

EnumSource (org.junit.jupiter.params.provider.EnumSource)397 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)393 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