use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.
the class MosaicAliasTransactionTest method shouldBuild.
@Test
void shouldBuild() {
MosaicId mosaicId = new MosaicId(BigInteger.TEN);
NamespaceId namespaceId = NamespaceId.createFromName("anamespaced");
MosaicAliasTransaction transaction = MosaicAliasTransactionFactory.create(NetworkType.MIJIN_TEST, new Deadline(BigInteger.ONE), AliasAction.LINK, namespaceId, mosaicId).build();
assertEquals(NetworkType.MIJIN_TEST, transaction.getNetworkType());
assertEquals(AliasAction.LINK, transaction.getAliasAction());
assertEquals(mosaicId, transaction.getMosaicId());
assertEquals(namespaceId, transaction.getNamespaceId());
}
use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.
the class AddressAliasTransactionTest method shouldSerialize.
@Test
void shouldSerialize() {
NetworkType networkType = NetworkType.MIJIN_TEST;
BigInteger fee = BigInteger.ONE;
NamespaceId namespaceId = NamespaceId.createFromId(new BigInteger("-8884663987180930485"));
PublicAccount signature = PublicAccount.createFromPublicKey("68b3fbb18729c1fde225c57f8ce080fa828f0067e451a3fd81fa628842b0b763", NetworkType.MIJIN_TEST);
TransactionInfo transactionInfo = TransactionInfo.createAggregate(new BigInteger("121855"), 1, "5A3D23889CD1E800015929A9", "3D28C804EDD07D5A728E5C5FFEC01AB07AFA5766AE6997B38526D36015A4D006", "5A0069D83F17CF0001777E55");
String signatureHex = createRandomSignature();
AddressAliasTransaction transaction = AddressAliasTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), AliasAction.LINK, namespaceId, signature.getAddress()).signer(signature).transactionInfo(transactionInfo).signature(signatureHex).maxFee(fee).build();
String expectedHash = "A100000000000000" + signatureHex + "68B3FBB18729C1FDE225C57F8CE080FA828F0067E451A3FD81FA628842B0B7630000000001904E42010000000000000001000000000000004BFA5F372D55B3849049E14BEBCA93758EB36805BAE760A57239976F009A545C01";
assertSerialization(expectedHash, transaction);
String expectedEmbeddedHash = "510000000000000068B3FBB18729C1FDE225C57F8CE080FA828F0067E451A3FD81FA628842B0B7630000000001904E424BFA5F372D55B3849049E14BEBCA93758EB36805BAE760A57239976F009A545C01";
assertEmbeddedSerialization(expectedEmbeddedHash, transaction);
}
use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.
the class TestHelper method getTestAccount.
public Pair<Account, NamespaceId> getTestAccount(RepositoryType type) {
Account testAccount = config().getTestAccount();
NamespaceId namespaceId = setAddressAlias(type, testAccount.getAddress(), "testaccount");
sendMosaicFromNemesis(type, testAccount.getAddress(), false);
return Pair.of(testAccount, namespaceId);
}
use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.
the class TestHelper method setMosaicAlias.
protected NamespaceId setMosaicAlias(RepositoryType type, MosaicId mosaicId, String namespaceName) {
Account nemesisAccount = config().getNemesisAccount1();
NamespaceId namespaceId = NamespaceId.createFromName(namespaceName);
if (isAlias(type, mosaicId, namespaceId)) {
System.out.println(namespaceName + " MOSAIC Alias found, reusing it.");
return namespaceId;
} else {
System.out.println(namespaceName + " MOSAIC Alias not found, CREATING MOSAIC ALIAS");
}
System.out.println("Setting up namespace " + namespaceName);
NamespaceRegistrationTransaction namespaceRegistrationTransaction = NamespaceRegistrationTransactionFactory.createRootNamespace(getNetworkType(), getDeadline(), namespaceName, getDuration()).maxFee(maxFee).build();
NamespaceId rootNamespaceId = announceAggregateAndValidate(type, namespaceRegistrationTransaction, nemesisAccount).getLeft().getNamespaceId();
System.out.println("Setting mosaic alias " + mosaicId.getIdAsHex() + " alias: " + namespaceName);
MosaicAliasTransaction aliasTransaction = MosaicAliasTransactionFactory.create(getNetworkType(), getDeadline(), AliasAction.LINK, rootNamespaceId, mosaicId).maxFee(maxFee).build();
announceAggregateAndValidate(type, aliasTransaction, nemesisAccount);
int retry = 10;
while (!isAlias(type, mosaicId, namespaceId)) {
sleep(300);
retry--;
if (retry == 0) {
Assertions.fail("Could not create " + mosaicId.getIdAsHex() + " alias: " + namespaceName);
}
}
return rootNamespaceId;
}
use of io.nem.symbol.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.
the class TestHelper method setAddressAlias.
public NamespaceId setAddressAlias(RepositoryType type, Address address, String namespaceName) {
NamespaceId namespaceId = NamespaceId.createFromName(namespaceName);
if (isAlias(type, address, namespaceId)) {
System.out.println(namespaceName + " ADDRESS Alias for address " + address.plain() + " found, reusing it.");
return namespaceId;
}
System.out.println(namespaceName + " ADDRESS Alias not found, CREATING ADDRESS " + address.plain() + " ALIAS");
Account nemesisAccount = config().getNemesisAccount1();
System.out.println("Setting up namespace " + namespaceName);
NamespaceRegistrationTransaction namespaceRegistrationTransaction = NamespaceRegistrationTransactionFactory.createRootNamespace(getNetworkType(), getDeadline(), namespaceName, getDuration()).maxFee(maxFee).build();
NamespaceId rootNamespaceId = announceAggregateAndValidate(type, namespaceRegistrationTransaction, nemesisAccount).getLeft().getNamespaceId();
System.out.println("Setting account alias " + address.plain() + " alias: " + namespaceName);
AddressAliasTransaction aliasTransaction = AddressAliasTransactionFactory.create(getNetworkType(), getDeadline(), AliasAction.LINK, rootNamespaceId, address).maxFee(maxFee).build();
announceAggregateAndValidate(type, aliasTransaction, nemesisAccount);
int retry = 10;
while (!isAlias(type, address, namespaceId)) {
sleep(300);
retry--;
if (retry == 0) {
Assertions.fail("Could not create " + address.plain() + " alias: " + namespaceName);
}
}
return rootNamespaceId;
}
Aggregations