use of io.nem.symbol.sdk.model.message.PlainMessage in project nem2-sdk-java by nemtech.
the class ListenerStatusIntegrationTest method statusListener.
@Test
void statusListener() throws ExecutionException, InterruptedException {
RepositoryType type = DEFAULT_REPOSITORY_TYPE;
Account account1 = Account.generateNewAccount(getNetworkType());
Account account2 = Account.generateNewAccount(getNetworkType());
Account account3 = Account.generateNewAccount(getNetworkType());
createListener(type).status(account1.getAddress()).subscribe(a -> {
System.out.println(">>>> account 1 " + a.getAddress() + " " + a.getHash() + " " + a.getStatus());
});
createListener(type).status(account2.getAddress()).subscribe(a -> {
System.out.println(">>>> account 2 " + a.getAddress() + " " + a.getHash() + " " + a.getStatus());
});
createListener(type).status(account3.getAddress()).subscribe(a -> {
System.out.println(">>>> account 3 " + a.getAddress() + " " + a.getHash() + " " + a.getStatus());
});
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);
}
use of io.nem.symbol.sdk.model.message.PlainMessage in project nem2-sdk-java by nemtech.
the class AggregateTransactionServiceIntegrationTest method isTransferFromMultisigComplete.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void isTransferFromMultisigComplete(RepositoryType type) {
Account multisigAccount = helper().getMultisigAccount(type).getKey();
Account cosignatoryAccount = config().getCosignatoryAccount();
TransferTransaction transferTransaction = TransferTransactionFactory.create(getNetworkType(), getDeadline(), getRecipient(), Collections.emptyList()).message(new PlainMessage("")).maxFee(maxFee).build();
AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(getNetworkType(), getDeadline(), Collections.singletonList(transferTransaction.toAggregate(multisigAccount.getPublicAccount()))).maxFee(maxFee).build();
SignedTransaction signedAggregateTransaction = aggregateTransaction.signTransactionWithCosigners(multisigAccount, Arrays.asList(cosignatoryAccount, config().getTestAccount()), getGenerationHash());
AggregateTransactionService aggregateTransactionService = new AggregateTransactionServiceImpl(getRepositoryFactory(type));
Assertions.assertTrue(get(aggregateTransactionService.isComplete(signedAggregateTransaction)));
}
use of io.nem.symbol.sdk.model.message.PlainMessage 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.message.PlainMessage in project nem2-sdk-java by nemtech.
the class VertxAggregateTransactionTest method createAAggregateTransactionViaStaticConstructor.
@Test
void createAAggregateTransactionViaStaticConstructor() {
Duration epochAdjustment = Duration.ofSeconds(100);
Address recipient = Address.generateRandom(networkType);
Deadline deadline = Deadline.create(epochAdjustment);
TransferTransaction transferTx = TransferTransactionFactory.create(networkType, deadline, recipient, Collections.emptyList()).message(new PlainMessage("")).build();
AggregateTransaction aggregateTx = AggregateTransactionFactory.createComplete(networkType, deadline, Collections.singletonList(transferTx.toAggregate(new PublicAccount("9A49366406ACA952B88BADF5F1E9BE6CE4968141035A60BE503273EA65456B24", networkType)))).build();
assertEquals(networkType, aggregateTx.getNetworkType());
assertEquals(1, (int) aggregateTx.getVersion());
assertTrue(LocalDateTime.now().isBefore(aggregateTx.getDeadline().getLocalDateTime(epochAdjustment)));
assertEquals(BigInteger.valueOf(0), aggregateTx.getMaxFee());
assertEquals(1, aggregateTx.getInnerTransactions().size());
}
use of io.nem.symbol.sdk.model.message.PlainMessage in project nem2-sdk-java by nemtech.
the class TransactionServiceIntegrationTest method transferUsingAliases.
private TransferTransaction transferUsingAliases(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);
TransferTransaction processedTransferTransaction = announceAndValidate(type, sender, transferTransaction);
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 processedTransferTransaction;
}
Aggregations