use of io.nem.symbol.sdk.model.account.Account in project nem2-sdk-java by nemtech.
the class AccountKeyLinkTransactionIntegrationTest method basicAnnounce.
@ParameterizedTest
@EnumSource(RepositoryType.class)
public void basicAnnounce(RepositoryType type) {
Account account = config().getNemesisAccount2();
PublicKey linkedPublicKey = PublicKey.fromHexString("F5D0AAD909CFBC810A3F888C33C57A9051AE1A59D1CDA872A8B90BCA7EF2D34A");
AccountKeyLinkTransaction linkTransaction = AccountKeyLinkTransactionFactory.create(getNetworkType(), getDeadline(), linkedPublicKey, LinkAction.LINK).maxFee(maxFee).build();
announceAndValidate(type, account, linkTransaction);
AccountKeyLinkTransaction unlinkTransaction = AccountKeyLinkTransactionFactory.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 TransactionRepositoryVertxImplTest method getSignedTransaction.
private SignedTransaction getSignedTransaction() {
String generationHash = "A94B1BE81F1D4C95D6D252AD7BA3FFFB1674991FD880B7A57DC3180AF8D69C32";
Account account = Account.generateNewAccount(this.networkType);
Address recipientAddress = Address.generateRandom(this.networkType);
TransferTransaction transferTransaction = TransferTransactionFactory.create(NetworkType.MIJIN_TEST, new Deadline(BigInteger.ONE), recipientAddress, Collections.singletonList(createAbsolute(BigInteger.valueOf(1)))).message(new PlainMessage("E2ETest:standaloneTransferTransaction:message")).build();
SignedTransaction signedTransaction = account.sign(transferTransaction, generationHash);
String payload = signedTransaction.getPayload();
assertEquals(444, payload.length());
return signedTransaction;
}
use of io.nem.symbol.sdk.model.account.Account in project nem2-sdk-java by nemtech.
the class AccountRepositoryVertxImplTest method shouldGetAccountInfo.
@Test
public void shouldGetAccountInfo() throws Exception {
Account account = Account.generateNewAccount(this.networkType);
Address address = account.getAddress();
AccountDTO accountDTO = new AccountDTO();
accountDTO.setVersion(1);
accountDTO.setAccountType(AccountTypeEnum.NUMBER_1);
accountDTO.setAddress(encodeAddress(address));
accountDTO.setAddressHeight(BigInteger.TEN);
accountDTO.setPublicKeyHeight(BigInteger.valueOf(20));
accountDTO.setPublicKey(account.getPublicAccount().getPublicKey().toHex());
accountDTO.setImportance(BigInteger.valueOf(5));
accountDTO.setImportanceHeight(BigInteger.valueOf(10));
List<Mosaic> mosaicDtos = new ArrayList<>();
mosaicDtos.add(new Mosaic().id("0000000000000ABC").amount(BigInteger.TEN));
accountDTO.setMosaics(mosaicDtos);
AccountInfoDTO accountInfoDTO = new AccountInfoDTO();
accountInfoDTO.setAccount(accountDTO);
mockRemoteCall(accountInfoDTO);
AccountInfo resolvedAccountInfo = repository.getAccountInfo(address).toFuture().get();
Assertions.assertEquals(address, resolvedAccountInfo.getAddress());
Assertions.assertEquals(AccountType.MAIN, resolvedAccountInfo.getAccountType());
Assertions.assertEquals(1, resolvedAccountInfo.getMosaics().size());
Assertions.assertEquals("0000000000000ABC", resolvedAccountInfo.getMosaics().get(0).getId().getIdAsHex());
Assertions.assertEquals(BigInteger.TEN, resolvedAccountInfo.getMosaics().get(0).getAmount());
}
use of io.nem.symbol.sdk.model.account.Account in project nem2-sdk-java by nemtech.
the class ListenerVertxTest method shouldHandleStatus.
@Test
public void shouldHandleStatus() throws InterruptedException, ExecutionException, TimeoutException {
Account account1 = Account.generateNewAccount(NETWORK_TYPE);
AtomicReference<TransactionStatusError> reference = new AtomicReference<>();
simulateWebSocketStartup();
Assertions.assertNotNull(listener.status(account1.getAddress()).subscribe(reference::set));
Map<String, Object> message = new HashMap<>();
message.put("hash", "1234hash");
message.put("address", account1.getAddress().encoded());
message.put("code", "some error");
message.put("deadline", 5555);
handle(message, "status/" + account1.getAddress().plain());
Assertions.assertNotNull(reference.get());
Assertions.assertEquals(message.get("hash"), reference.get().getHash());
Assertions.assertEquals(message.get("code"), reference.get().getStatus());
Assertions.assertEquals(account1.getAddress(), reference.get().getAddress());
Mockito.verify(webSocketMock).handler(Mockito.any());
Mockito.verify(webSocketMock).writeTextMessage(jsonHelper.print(new ListenerSubscribeMessage(this.wsId, "status" + "/" + account1.getAddress().plain())));
}
use of io.nem.symbol.sdk.model.account.Account 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;
}
Aggregations