use of io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction in project nem2-sdk-java by nemtech.
the class TransactionMapperVertxTest 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());
}
}
// if (transaction.getTransactionInfo().get().getId().isPresent()) {
// assertEquals(
// transactionDTO.getMeta().getId(),
// transaction.getTransactionInfo().get().getId().get());
// }
// if (transaction.getTransactionInfo().get().getAggregateHash().isPresent()) {
// assertEquals(
// transactionDTO.getMeta().getAggregateHash(),
// transaction.getTransactionInfo().get().getAggregateHash().get());
// }
// if (transaction.getTransactionInfo().get().getAggregateId().isPresent()) {
// assertEquals(
// transactionDTO.getMeta().getAggregateId(),
// transaction.getTransactionInfo().get().getAggregateId().get());
// }
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);
}
}
use of io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction in project nem2-sdk-java by nemtech.
the class TestHelper method createRootNamespace.
public NamespaceId createRootNamespace(RepositoryType type, Account testAccount, String namespaceName) {
System.out.println("Creating namespace " + namespaceName);
NamespaceRegistrationTransaction namespaceRegistrationTransaction = NamespaceRegistrationTransactionFactory.createRootNamespace(getNetworkType(), getDeadline(), namespaceName, getDuration()).maxFee(maxFee).build();
NamespaceRegistrationTransaction processedTransaction = announceAndValidate(type, testAccount, namespaceRegistrationTransaction);
Assertions.assertEquals(namespaceRegistrationTransaction.getNamespaceId().getIdAsHex(), processedTransaction.getNamespaceId().getIdAsHex());
Assertions.assertEquals(namespaceRegistrationTransaction.getNamespaceName(), processedTransaction.getNamespaceName());
return namespaceRegistrationTransaction.getNamespaceId();
}
use of io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction in project nem2-sdk-java by nemtech.
the class NamespaceRegistrationIntegrationTest method standaloneSubNamespaceRegisterNamespaceTransaction.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void standaloneSubNamespaceRegisterNamespaceTransaction(RepositoryType type) {
this.standaloneRootRegisterNamespaceTransaction(type);
String namespaceName = "test-sub-namespace-" + Double.valueOf(Math.floor(Math.random() * 10000)).intValue();
NamespaceRegistrationTransaction namespaceRegistrationTransaction = NamespaceRegistrationTransactionFactory.createSubNamespace(getNetworkType(), getDeadline(), namespaceName, this.rootNamespaceId).maxFee(maxFee).build();
announceAndValidate(type, this.account, namespaceRegistrationTransaction);
sleep(1000);
NamespaceInfo namespaceInfo = get(getRepositoryFactory(type).createNamespaceRepository().getNamespace(namespaceRegistrationTransaction.getNamespaceId()));
Assertions.assertEquals(this.account.getAddress(), namespaceInfo.getOwnerAddress());
Assertions.assertEquals(namespaceRegistrationTransaction.getNamespaceId(), namespaceInfo.getId());
}
use of io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction 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());
}
use of io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction 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());
}
Aggregations