use of io.nem.symbol.sdk.model.message.EncryptedMessage 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);
}
Aggregations