use of io.nem.symbol.sdk.model.message.Message in project nem2-sdk-java by nemtech.
the class TransactionSearchRepositoryIntegrationTest method searchUnconfirmed.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchUnconfirmed(RepositoryType type) {
TransactionRepository transactionRepository = getTransactionRepository(type);
Address recipient = getRecipient();
TransferTransaction transferTransaction = TransferTransactionFactory.create(getNetworkType(), getDeadline(), recipient, Collections.singletonList(getNetworkCurrency().createAbsolute(BigInteger.valueOf(1)))).message(new PlainMessage("")).maxFee(maxFee).build();
Account signer = config().getDefaultAccount();
SignedTransaction signedTransaction = transferTransaction.signWith(signer, getGenerationHash());
get(transactionRepository.announce(signedTransaction));
get(getListener(type).unconfirmedAdded(signer.getAddress(), signedTransaction.getHash()).take(1));
TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
TransactionGroup group = TransactionGroup.UNCONFIRMED;
TransactionSearchCriteria criteria = new TransactionSearchCriteria(group);
criteria.transactionTypes(Collections.singletonList(TransactionType.TRANSFER));
List<Transaction> transactions = get(streamer.search(criteria).toList().toObservable());
transactions.forEach(b -> Assertions.assertEquals(TransactionType.TRANSFER, b.getType()));
Assertions.assertTrue(transactions.stream().filter(t -> t.getTransactionInfo().get().getHash().get().equals(signedTransaction.getHash())).findAny().isPresent());
helper.assertById(transactionRepository, group, transactions);
}
use of io.nem.symbol.sdk.model.message.Message in project nem2-sdk-java by nemtech.
the class TransferTransactionIntegrationTest method standaloneTransferTransactionEncryptedMessage.
@ParameterizedTest
@EnumSource(RepositoryType.class)
public void standaloneTransferTransactionEncryptedMessage(RepositoryType type) throws Exception {
this.helper().sendMosaicFromNemesis(type, getRecipient(), false);
String namespaceName = "standaloneTransferTransactionEncryptedMessagealias".toLowerCase();
NamespaceId recipient = setAddressAlias(type, getRecipient(), namespaceName);
System.out.println(recipient.getIdAsHex());
Assertions.assertEquals("9960629109A48AFBC0000000000000000000000000000000", recipient.encoded(getNetworkType()));
String message = "E2ETest:standaloneTransferTransaction:message 漢字";
KeyPair senderKeyPair = KeyPair.random();
KeyPair recipientKeyPair = KeyPair.random();
Message encryptedMessage = EncryptedMessage.create(message, senderKeyPair.getPrivateKey(), recipientKeyPair.getPublicKey());
Currency networkCurrency = getNetworkCurrency();
Mosaic mosaic = new Mosaic(networkCurrency.getNamespaceId().get(), BigInteger.valueOf(10202020));
TransferTransaction transferTransaction = TransferTransactionFactory.create(getNetworkType(), getDeadline(), recipient, Collections.singletonList(mosaic)).message(encryptedMessage).maxFee(maxFee).build();
TransferTransaction processed = announceAndValidate(type, signerAccount, transferTransaction);
assertTransferTransactions(transferTransaction, processed);
assertEncryptedMessageTransaction(message, senderKeyPair, recipientKeyPair, processed);
TransferTransaction restTransaction = (TransferTransaction) get(getRepositoryFactory(type).createTransactionRepository().getTransaction(TransactionGroup.CONFIRMED, processed.getTransactionInfo().get().getHash().get()));
assertTransferTransactions(transferTransaction, restTransaction);
assertEncryptedMessageTransaction(message, senderKeyPair, recipientKeyPair, restTransaction);
}
use of io.nem.symbol.sdk.model.message.Message in project nem2-sdk-java by nemtech.
the class TransactionSearchRepositoryIntegrationTest method searchEmbedded.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchEmbedded(RepositoryType type) {
TransactionRepository transactionRepository = getTransactionRepository(type);
TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
TransactionGroup group = TransactionGroup.CONFIRMED;
TransactionSearchCriteria criteria = new TransactionSearchCriteria(group).embedded(true);
List<Transaction> transactions = get(streamer.search(criteria).toList().toObservable());
transactions.forEach(b -> {
TransferTransaction transferTransaction = (TransferTransaction) b;
Message message = transferTransaction.getMessage().orElse(PlainMessage.create("No Message!!"));
Assertions.assertNotNull(message.getText());
});
Assertions.assertFalse(transactions.isEmpty());
}
use of io.nem.symbol.sdk.model.message.Message in project nem2-sdk-java by nemtech.
the class TransactionSearchRepositoryIntegrationTest method searchTransactionType.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchTransactionType(RepositoryType type) {
TransactionRepository transactionRepository = getTransactionRepository(type);
TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
TransactionGroup group = TransactionGroup.CONFIRMED;
TransactionSearchCriteria criteria = new TransactionSearchCriteria(group).transactionTypes(Arrays.asList(TransactionType.TRANSFER));
List<Transaction> transactions = get(streamer.search(criteria).toList().toObservable());
transactions.forEach(b -> {
TransferTransaction transferTransaction = (TransferTransaction) b;
Message message = transferTransaction.getMessage().orElse(PlainMessage.create("No Message!!"));
Assertions.assertNotNull(message.getText());
});
Assertions.assertFalse(transactions.isEmpty());
}
Aggregations