use of io.nem.symbol.sdk.model.account.Account in project nem2-sdk-java by nemtech.
the class VrfKeyLinkTransactionIntegrationTest method basicAnnounce.
@ParameterizedTest
@EnumSource(RepositoryType.class)
public void basicAnnounce(RepositoryType type) {
Account account = config().getNemesisAccount2();
PublicKey linkedPublicKey = PublicKey.fromHexString("F5D0AAD909CFBC810A3F888C33C57A9051AE1A59D1CDA872A8B90BCA7EF2D34A");
VrfKeyLinkTransaction linkTransaction = VrfKeyLinkTransactionFactory.create(getNetworkType(), getDeadline(), linkedPublicKey, LinkAction.LINK).maxFee(maxFee).build();
announceAndValidate(type, account, linkTransaction);
VrfKeyLinkTransaction unlinkTransaction = VrfKeyLinkTransactionFactory.create(getNetworkType(), getDeadline(), linkedPublicKey, LinkAction.UNLINK).maxFee(maxFee).build();
announceAndValidate(type, account, unlinkTransaction);
}
use of io.nem.symbol.sdk.model.account.Account 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.account.Account in project nem2-sdk-java by nemtech.
the class ListenerIntegrationTest method getAllMultisigAddressesAndAliasesWhenBasic.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void getAllMultisigAddressesAndAliasesWhenBasic(RepositoryType type) {
Account testAccount = this.helper().getTestAccount(type).getKey();
Set<NamespaceId> cosignatoryAccount1aliases = get(getRepositoryFactory(type).createNamespaceRepository().getAccountsNames(Collections.singletonList(testAccount.getAddress()))).stream().flatMap(a -> a.getNames().stream().map(NamespaceName::getNamespaceId)).collect(Collectors.toSet());
Listener listener = getRepositoryFactory(type).createListener();
final Set<UnresolvedAddress> unresolvedAddresses = get(listener.getAllMultisigAddressesAndAliases(testAccount.getAddress()));
final Set<UnresolvedAddress> expectedAddresees = Sets.newSet(testAccount.getAddress());
expectedAddresees.addAll(cosignatoryAccount1aliases);
Assertions.assertEquals(expectedAddresees, unresolvedAddresses);
}
use of io.nem.symbol.sdk.model.account.Account in project nem2-sdk-java by nemtech.
the class ListenerStatusIntegrationTest method sendTransactionsReusingListener.
@Test
void sendTransactionsReusingListener() throws ExecutionException, InterruptedException {
RepositoryType type = DEFAULT_REPOSITORY_TYPE;
Account account1 = config().getNemesisAccount1();
Account account2 = Account.generateNewAccount(getNetworkType());
Account account3 = Account.generateNewAccount(getNetworkType());
Listener listener = createListener(type);
listener.unconfirmedRemoved(account1.getAddress()).subscribe(a -> {
System.out.println(">>>> account 1 " + a);
});
listener.unconfirmedRemoved(account2.getAddress()).subscribe(a -> {
System.out.println(">>>> account 2 " + a);
});
listener.unconfirmedRemoved(account3.getAddress()).subscribe(a -> {
System.out.println(">>>> account 3 " + a);
});
// IT PRINTS:
// >>>> account 1
// 94BE61F8FA091319A3564D843468ABD8E51034F7CDF132A74BBA2A7465E27C7D
// >>>> account 2
// 94BE61F8FA091319A3564D843468ABD8E51034F7CDF132A74BBA2A7465E27C7D
// >>>> account 3
// 94BE61F8FA091319A3564D843468ABD8E51034F7CDF132A74BBA2A7465E27C7D
// >>>> account 1
// 94BE61F8FA091319A3564D843468ABD8E51034F7CDF132A74BBA2A7465E27C7D
// >>>> account 2
// 94BE61F8FA091319A3564D843468ABD8E51034F7CDF132A74BBA2A7465E27C7D
// >>>> account 3
// 94BE61F8FA091319A3564D843468ABD8E51034F7CDF132A74BBA2A7465E27C7D
TransferTransaction transferTransaction = TransferTransactionFactory.create(getNetworkType(), getDeadline(), account2.getAddress(), Collections.singletonList(getNetworkCurrency().createAbsolute(BigInteger.valueOf(1)))).message(new PlainMessage("test-message")).maxFee(maxFee).build();
announceAndValidate(type, account1, transferTransaction);
sleep(1000);
}
use of io.nem.symbol.sdk.model.account.Account in project nem2-sdk-java by nemtech.
the class MosaicAddressRestrictionIntegrationTest method createMosaicAddressRestrictionAndValidateEndpoints.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void createMosaicAddressRestrictionAndValidateEndpoints(RepositoryType type) {
Account testAccount = helper().createTestAccount(type);
Account testAccount2 = config().getTestAccount2();
// 1) Create a mosaic
MosaicId mosaicId = createMosaic(type, testAccount);
BigInteger restrictionKey = BigInteger.valueOf(22222);
// 2) Create a global restriction on the mosaic
MosaicGlobalRestrictionTransaction mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransactionFactory.create(getNetworkType(), getDeadline(), mosaicId, restrictionKey, BigInteger.valueOf(20), MosaicRestrictionType.GE).maxFee(maxFee).build();
announceAndValidate(type, testAccount, mosaicGlobalRestrictionTransaction);
sleep(1000);
// 3)Create a new MosaicAddressRestrictionTransaction
BigInteger originalRestrictionValue = BigInteger.valueOf(30);
Address targetAddress = testAccount2.getAddress();
MosaicAddressRestrictionTransaction createTransaction = MosaicAddressRestrictionTransactionFactory.create(getNetworkType(), getDeadline(), mosaicId, restrictionKey, targetAddress, originalRestrictionValue).maxFee(maxFee).build();
// 4)Announce and validate
MosaicAddressRestrictionTransaction announce1 = announceAggregateAndValidate(type, createTransaction, testAccount).getLeft();
sleep(1000);
assertTransaction(restrictionKey, createTransaction, announce1);
// 5) Validate that endpoints have the data.
sleep(1000);
RestrictionMosaicRepository restrictionRepository = getRepositoryFactory(type).createRestrictionMosaicRepository();
assertMosaicAddressRestriction(restrictionRepository, targetAddress, createTransaction, targetAddress, mosaicId);
// 6) Update the restriction
MosaicAddressRestrictionTransaction updateTransaction = MosaicAddressRestrictionTransactionFactory.create(getNetworkType(), getDeadline(), mosaicId, restrictionKey, targetAddress, BigInteger.valueOf(40)).previousRestrictionValue(originalRestrictionValue).maxFee(maxFee).build();
// 7) Announce and validate.
MosaicAddressRestrictionTransaction announced = announceAggregateAndValidate(type, updateTransaction, testAccount).getLeft();
sleep(1000);
assertTransaction(restrictionKey, updateTransaction, announced);
assertMosaicAddressRestriction(restrictionRepository, targetAddress, updateTransaction, targetAddress, mosaicId);
}
Aggregations