use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.
the class TestHelper method getMultisigAccount.
public Pair<Account, NamespaceId> getMultisigAccount(RepositoryType type) {
Account multisigAccount = config().getMultisigAccount();
sendMosaicFromNemesis(type, multisigAccount.getAddress(), false);
NamespaceId namespaceId = setAddressAlias(type, multisigAccount.getAddress(), "multisigaccount");
this.createMultisigAccountBonded(type, multisigAccount, config().getCosignatoryAccount(), config().getCosignatory2Account());
return Pair.of(multisigAccount, namespaceId);
}
use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.
the class TransactionServiceIntegrationTest method transferUsingAliasesAggregate.
private AggregateTransaction transferUsingAliasesAggregate(Account sender, RepositoryType type, String mosaicAlias, String recipientAlias, BigInteger amount) {
NamespaceId recipientNamespace = NamespaceId.createFromName(recipientAlias);
NamespaceId mosaicNamespace = NamespaceId.createFromName(mosaicAlias);
System.out.println("Sending " + amount + " Mosaic to: " + mosaicAlias);
TransferTransactionFactory factory = TransferTransactionFactory.create(getNetworkType(), getDeadline(), recipientNamespace, Collections.singletonList(new Mosaic(mosaicNamespace, amount))).message(new PlainMessage("E2ETest:TransactionServiceIntegrationTest"));
factory.maxFee(maxFee);
TransferTransaction transferTransaction = factory.build();
Assertions.assertTrue(transferTransaction.getMosaics().get(0).getId() instanceof NamespaceId);
Assertions.assertTrue(transferTransaction.getRecipient() instanceof NamespaceId);
Pair<TransferTransaction, AggregateTransaction> pair = announceAggregateAndValidate(type, transferTransaction, sender);
TransferTransaction processedTransferTransaction = pair.getLeft();
Assertions.assertEquals(amount, processedTransferTransaction.getMosaics().get(0).getAmount());
System.out.println(toJson(processedTransferTransaction));
Assertions.assertTrue(processedTransferTransaction.getMosaics().get(0).getId() instanceof NamespaceId);
Assertions.assertTrue(processedTransferTransaction.getRecipient() instanceof NamespaceId);
return pair.getRight();
}
use of io.nem.symbol.sdk.model.namespace.NamespaceId 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));
}
use of io.nem.symbol.sdk.model.namespace.NamespaceId 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));
}
use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.
the class NamespaceMetadataServiceIntegrationTest method setAndUpdateNamespaceMetadata.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void setAndUpdateNamespaceMetadata(RepositoryType type) {
// TODO try target != signer
Account signerAccount = config().getDefaultAccount();
Account targetAccount = config().getDefaultAccount();
String namespaceName = "namespace-id-metadata-service-integration-test-" + Double.valueOf(Math.floor(Math.random() * 10000)).intValue();
NamespaceId targetNamespaceId = super.createRootNamespace(type, signerAccount, namespaceName);
BigInteger key = BigInteger.valueOf(RandomUtils.generateRandomInt(100000));
String originalMessage = "The original message";
String newMessage = "The new Message";
RepositoryFactory repositoryFactory = getRepositoryFactory(type);
MetadataRepository metadataRepository = repositoryFactory.createMetadataRepository();
MetadataTransactionService service = new MetadataTransactionServiceImpl(repositoryFactory);
NamespaceMetadataTransaction originalTransaction = get(service.createNamespaceMetadataTransactionFactory(targetAccount.getAddress(), key, originalMessage, signerAccount.getAddress(), targetNamespaceId)).maxFee(maxFee).build();
announceAggregateAndValidate(type, originalTransaction, signerAccount);
assertMetadata(targetNamespaceId, key, originalMessage, metadataRepository, signerAccount);
NamespaceMetadataTransaction updateTransaction = get(service.createNamespaceMetadataTransactionFactory(targetAccount.getAddress(), key, newMessage, signerAccount.getAddress(), targetNamespaceId)).maxFee(maxFee).build();
announceAggregateAndValidate(type, updateTransaction, signerAccount);
assertMetadata(targetNamespaceId, key, newMessage, metadataRepository, signerAccount);
}
Aggregations