Search in sources :

Example 6 with NamespaceRegistrationTransaction

use of io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction in project nem2-sdk-java by nemtech.

the class AddressAliasTransactionIntegrationTest method sendAddressAliasTransactionAggregate.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void sendAddressAliasTransactionAggregate(RepositoryType type) {
    Account account = config().getDefaultAccount();
    String namespaceName = "test-root-namespace-aggregate-for-address-alias-" + Double.valueOf(Math.floor(Math.random() * 10000)).intValue();
    NamespaceRegistrationTransaction namespaceRegistrationTransaction = NamespaceRegistrationTransactionFactory.createRootNamespace(getNetworkType(), getDeadline(), namespaceName, helper().getDuration()).maxFee(maxFee).build();
    NamespaceId rootNamespaceId = announceAggregateAndValidate(type, namespaceRegistrationTransaction, account).getLeft().getNamespaceId();
    AddressAliasTransaction addressAliasTransaction = AddressAliasTransactionFactory.create(getNetworkType(), getDeadline(), AliasAction.LINK, rootNamespaceId, account.getAddress()).maxFee(maxFee).build();
    AggregateTransaction aggregateTransaction2 = AggregateTransactionFactory.createComplete(getNetworkType(), getDeadline(), Collections.singletonList(addressAliasTransaction.toAggregate(account.getPublicAccount()))).maxFee(maxFee).build();
    announceAndValidate(type, account, aggregateTransaction2);
    sleep(1000);
    List<AccountNames> accountNames = get(getRepositoryFactory(type).createNamespaceRepository().getAccountsNames(Collections.singletonList(account.getAddress())));
    Assertions.assertEquals(1, accountNames.size());
    assertEquals(1, accountNames.size());
    assertEquals(account.getAddress(), accountNames.get(0).getAddress());
    assertTrue(accountNames.get(0).getNames().stream().map(NamespaceName::getName).collect(Collectors.toList()).contains(namespaceName));
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) AddressAliasTransaction(io.nem.symbol.sdk.model.transaction.AddressAliasTransaction) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) AccountNames(io.nem.symbol.sdk.model.account.AccountNames) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) NamespaceRegistrationTransaction(io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with NamespaceRegistrationTransaction

use of io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction in project nem2-sdk-java by nemtech.

the class AddressAliasTransactionIntegrationTest method sendAddressAliasTransaction.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void sendAddressAliasTransaction(RepositoryType type) {
    Account account = config().getDefaultAccount();
    String namespaceName = "test-root-namespace-for-address-alias-" + Double.valueOf(Math.floor(Math.random() * 10000)).intValue();
    NamespaceRegistrationTransaction namespaceRegistrationTransaction = NamespaceRegistrationTransactionFactory.createRootNamespace(getNetworkType(), getDeadline(), namespaceName, helper().getDuration()).maxFee(maxFee).build();
    NamespaceId rootNamespaceId = announceAndValidate(type, account, namespaceRegistrationTransaction).getNamespaceId();
    AddressAliasTransaction addressAliasTransaction = AddressAliasTransactionFactory.create(getNetworkType(), getDeadline(), AliasAction.LINK, rootNamespaceId, account.getAddress()).maxFee(maxFee).build();
    announceAndValidate(type, account, addressAliasTransaction);
    sleep(1000);
    List<AccountNames> accountNames = get(getRepositoryFactory(type).createNamespaceRepository().getAccountsNames(Collections.singletonList(account.getAddress())));
    Assertions.assertEquals(1, accountNames.size());
    assertEquals(1, accountNames.size());
    assertEquals(account.getAddress(), accountNames.get(0).getAddress());
    assertTrue(accountNames.get(0).getNames().stream().map(NamespaceName::getName).collect(Collectors.toList()).contains(namespaceName));
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) AddressAliasTransaction(io.nem.symbol.sdk.model.transaction.AddressAliasTransaction) AccountNames(io.nem.symbol.sdk.model.account.AccountNames) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) NamespaceRegistrationTransaction(io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with NamespaceRegistrationTransaction

use of io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction in project nem2-sdk-java by nemtech.

the class AAASetupIntegrationTest method createRootAndChild.

@Test
@Order(1)
void createRootAndChild() {
    Account account = config().getNemesisAccount();
    NamespaceRegistrationTransaction root = NamespaceRegistrationTransactionFactory.createRootNamespace(getNetworkType(), getDeadline(), "root", helper.getDuration()).maxFee(maxFee).build();
    helper().announceAndValidate(type, account, root);
    NamespaceRegistrationTransaction child = NamespaceRegistrationTransactionFactory.createSubNamespace(getNetworkType(), getDeadline(), "child", root.getNamespaceId()).maxFee(maxFee).build();
    helper().announceAndValidate(type, account, child);
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) NamespaceRegistrationTransaction(io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 9 with NamespaceRegistrationTransaction

use of io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction in project nem2-sdk-java by nemtech.

the class AAASetupIntegrationTest method createNamespces.

@Test
@Order(1)
void createNamespces() {
    Account account = config().getNemesisAccount();
    NamespaceRegistrationTransaction root = NamespaceRegistrationTransactionFactory.createRootNamespace(getNetworkType(), getDeadline(), "root3", helper.getDuration()).maxFee(maxFee).build();
    helper().announceAndValidate(type, account, root);
    NamespaceRegistrationTransaction child1 = NamespaceRegistrationTransactionFactory.createSubNamespace(getNetworkType(), getDeadline(), "child1", root.getNamespaceId()).maxFee(maxFee).build();
    helper().announceAndValidate(type, account, child1);
    NamespaceRegistrationTransaction subchild1 = NamespaceRegistrationTransactionFactory.createSubNamespace(getNetworkType(), getDeadline(), "subchild1", child1.getNamespaceId()).maxFee(maxFee).build();
    helper().announceAndValidate(type, account, subchild1);
    NamespaceRegistrationTransaction subchild2 = NamespaceRegistrationTransactionFactory.createSubNamespace(getNetworkType(), getDeadline(), "subchild2", child1.getNamespaceId()).maxFee(maxFee).build();
    helper().announceAndValidate(type, account, subchild2);
    NamespaceRegistrationTransaction child2 = NamespaceRegistrationTransactionFactory.createSubNamespace(getNetworkType(), getDeadline(), "child2", root.getNamespaceId()).maxFee(maxFee).build();
    helper().announceAndValidate(type, account, child2);
    NamespaceRegistrationTransaction child3 = NamespaceRegistrationTransactionFactory.createSubNamespace(getNetworkType(), getDeadline(), "child3", root.getNamespaceId()).maxFee(maxFee).build();
    helper().announceAndValidate(type, account, child3);
    NamespaceRegistrationTransaction subchild3 = NamespaceRegistrationTransactionFactory.createSubNamespace(getNetworkType(), getDeadline(), "subchild3", child1.getNamespaceId()).maxFee(maxFee).build();
    helper().announceAndValidate(type, account, subchild3);
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) NamespaceRegistrationTransaction(io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 10 with NamespaceRegistrationTransaction

use of io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction in project nem2-sdk-java by nemtech.

the class TransactionMapperOkHttpTest method validateStandaloneTransaction.

void validateStandaloneTransaction(Transaction transaction, TransactionInfoDTO transactionDTO, TransactionInfoDTO parentTransaction) {
    TransactionMetaDTO meta = jsonHelper.convert(transactionDTO.getMeta(), TransactionMetaDTO.class);
    if (transaction.getTransactionInfo().isPresent()) {
        TransactionInfo transactionInfo = transaction.getTransactionInfo().get();
        assertEquals(meta.getHeight(), transactionInfo.getHeight());
        if (transactionInfo.getHash().isPresent()) {
            assertEquals(meta.getHash(), transactionInfo.getHash().get());
        }
        if (transactionInfo.getMerkleComponentHash().isPresent()) {
            assertEquals(meta.getMerkleComponentHash(), transactionInfo.getMerkleComponentHash().get());
        }
        if (transactionInfo.getIndex().isPresent()) {
            assertEquals(transactionInfo.getIndex().get(), meta.getIndex());
        }
    }
    assertEquals(jsonHelper.getString(parentTransaction.getTransaction(), "signature"), transaction.getSignature().get());
    assertEquals(jsonHelper.getString(transactionDTO.getTransaction(), "signerPublicKey"), transaction.getSigner().get().getPublicKey().toHex());
    assertEquals(transaction.getType().getValue(), (int) jsonHelper.getInteger(transactionDTO.getTransaction(), "type"));
    int version = jsonHelper.getInteger(transactionDTO.getTransaction(), "version");
    assertEquals((int) transaction.getVersion(), version);
    int networkType = jsonHelper.getInteger(transactionDTO.getTransaction(), "network");
    assertEquals(transaction.getNetworkType().getValue(), networkType);
    assertEquals(jsonHelper.getBigInteger(parentTransaction.getTransaction(), "maxFee"), transaction.getMaxFee());
    assertNotNull(transaction.getDeadline());
    if (transaction.getType() == TransactionType.TRANSFER) {
        validateTransferTx((TransferTransaction) transaction, transactionDTO);
    } else if (transaction.getType() == TransactionType.NAMESPACE_REGISTRATION) {
        validateNamespaceCreationTx((NamespaceRegistrationTransaction) transaction, transactionDTO);
    } else if (transaction.getType() == TransactionType.MOSAIC_DEFINITION) {
        validateMosaicCreationTx((MosaicDefinitionTransaction) transaction, transactionDTO);
    } else if (transaction.getType() == TransactionType.MOSAIC_SUPPLY_CHANGE) {
        validateMosaicSupplyChangeTx((MosaicSupplyChangeTransaction) transaction, transactionDTO);
    } else if (transaction.getType() == TransactionType.MULTISIG_ACCOUNT_MODIFICATION) {
        validateMultisigModificationTx((MultisigAccountModificationTransaction) transaction, transactionDTO);
    } else if (transaction.getType() == TransactionType.HASH_LOCK) {
        validateLockFundsTx((HashLockTransaction) transaction, transactionDTO);
    } else if (transaction.getType() == TransactionType.SECRET_LOCK) {
        validateSecretLockTx((SecretLockTransaction) transaction, transactionDTO);
    } else if (transaction.getType() == TransactionType.SECRET_PROOF) {
        validateSecretProofTx((SecretProofTransaction) transaction, transactionDTO);
    }
}
Also used : MosaicSupplyChangeTransaction(io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransaction) HashLockTransaction(io.nem.symbol.sdk.model.transaction.HashLockTransaction) TransactionInfo(io.nem.symbol.sdk.model.transaction.TransactionInfo) TransactionMetaDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionMetaDTO) SecretProofTransaction(io.nem.symbol.sdk.model.transaction.SecretProofTransaction) NamespaceRegistrationTransaction(io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction)

Aggregations

NamespaceRegistrationTransaction (io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction)14 Account (io.nem.symbol.sdk.model.account.Account)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 EnumSource (org.junit.jupiter.params.provider.EnumSource)7 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)5 NamespaceInfo (io.nem.symbol.sdk.model.namespace.NamespaceInfo)4 AddressAliasTransaction (io.nem.symbol.sdk.model.transaction.AddressAliasTransaction)3 AccountNames (io.nem.symbol.sdk.model.account.AccountNames)2 HashLockTransaction (io.nem.symbol.sdk.model.transaction.HashLockTransaction)2 MosaicAliasTransaction (io.nem.symbol.sdk.model.transaction.MosaicAliasTransaction)2 MosaicSupplyChangeTransaction (io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransaction)2 SecretProofTransaction (io.nem.symbol.sdk.model.transaction.SecretProofTransaction)2 TransactionInfo (io.nem.symbol.sdk.model.transaction.TransactionInfo)2 Order (org.junit.jupiter.api.Order)2 Test (org.junit.jupiter.api.Test)2 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)2 AccountInfo (io.nem.symbol.sdk.model.account.AccountInfo)1 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)1 MosaicNames (io.nem.symbol.sdk.model.mosaic.MosaicNames)1 AliasAction (io.nem.symbol.sdk.model.namespace.AliasAction)1