use of org.junit.jupiter.params.provider.EnumSource in project nem2-sdk-java by nemtech.
the class TransactionSearchRepositoryIntegrationTest method searchEmbeddedTransactionType.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchEmbeddedTransactionType(RepositoryType type) {
TransactionRepository transactionRepository = getTransactionRepository(type);
TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
TransactionSearchCriteria criteria = new TransactionSearchCriteria(TransactionGroup.CONFIRMED);
criteria.setEmbedded(true);
List<Transaction> transactions = get(streamer.search(criteria).toList().toObservable());
Assertions.assertFalse(transactions.isEmpty());
transactions.stream().forEach(t -> {
Transaction storedById = get(transactionRepository.getTransaction(TransactionGroup.CONFIRMED, t.getRecordId().get()));
Assertions.assertEquals(storedById.getRecordId().get(), t.getRecordId().get());
if (t.getTransactionInfo().get().getHash().isPresent()) {
Transaction transaction = get(transactionRepository.getTransaction(TransactionGroup.CONFIRMED, t.getTransactionInfo().get().getHash().get()));
Assertions.assertEquals(storedById.getRecordId().get(), t.getRecordId().get());
Assertions.assertEquals(t.getTransactionInfo().get().getHash().get(), t.getTransactionInfo().get().getHash().get());
} else {
Assertions.assertEquals(0, t.getMaxFee().intValue());
}
});
}
use of org.junit.jupiter.params.provider.EnumSource 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 org.junit.jupiter.params.provider.EnumSource in project nem2-sdk-java by nemtech.
the class TransferTransactionIntegrationTest method standaloneCreatePersistentDelegationRequestTransaction.
@ParameterizedTest
@EnumSource(RepositoryType.class)
public void standaloneCreatePersistentDelegationRequestTransaction(RepositoryType type) {
KeyPair signingKeyPair = KeyPair.random();
KeyPair vrfPrivateKey = KeyPair.random();
KeyPair recipientKeyPair = KeyPair.random();
TransferTransaction transferTransaction = TransferTransactionFactory.createPersistentDelegationRequestTransaction(getNetworkType(), getDeadline(), signingKeyPair.getPrivateKey(), vrfPrivateKey.getPrivateKey(), recipientKeyPair.getPublicKey()).maxFee(maxFee).build();
TransferTransaction processed = announceAndValidate(type, signerAccount, transferTransaction);
assertPersistentDelegationTransaction(recipientKeyPair, signingKeyPair, vrfPrivateKey, processed);
TransferTransaction restTransaction = (TransferTransaction) get(getRepositoryFactory(type).createTransactionRepository().getTransaction(TransactionGroup.CONFIRMED, processed.getTransactionInfo().get().getHash().get()));
assertPersistentDelegationTransaction(recipientKeyPair, signingKeyPair, vrfPrivateKey, restTransaction);
}
use of org.junit.jupiter.params.provider.EnumSource in project nem2-sdk-java by nemtech.
the class TransferTransactionIntegrationTest method transferTransactionNotEnoughFundAccount.
@ParameterizedTest
@EnumSource(RepositoryType.class)
public void transferTransactionNotEnoughFundAccount(RepositoryType type) {
Address recipient = config().getTestAccount2().getAddress();
NetworkType networkType = getNetworkType();
Account account = Account.generateNewAccount(networkType);
TransferTransaction transferTransaction = TransferTransactionFactory.create(getNetworkType(), getDeadline(), recipient, Collections.singletonList(getNetworkCurrency().createAbsolute(BigInteger.valueOf(1000000000)))).message(new PlainMessage("")).maxFee(maxFee).build();
IllegalArgumentException exceptions = Assertions.assertThrows(IllegalArgumentException.class, () -> announceAndValidate(type, account, transferTransaction));
Assertions.assertTrue(exceptions.getMessage().contains("Failure_Core_Insufficient_Balance"));
}
use of org.junit.jupiter.params.provider.EnumSource 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);
}
Aggregations