use of io.nem.symbol.sdk.model.transaction.AccountMetadataTransaction in project nem2-sdk-java by nemtech.
the class TransactionMapperVertxTest method shouldCreateAggregateAccountMetadataTransaction.
@Test
void shouldCreateAggregateAccountMetadataTransaction() {
TransactionInfoDTO aggregateTransferTransactionDTO = TestHelperVertx.loadTransactionInfoDTO("aggregateAccountMetadataTransaction.json");
AggregateTransaction aggregateTransferTransaction = (AggregateTransaction) map(aggregateTransferTransactionDTO);
validateAggregateTransaction(aggregateTransferTransaction, aggregateTransferTransactionDTO);
AccountMetadataTransaction transaction = (AccountMetadataTransaction) aggregateTransferTransaction.getInnerTransactions().get(0);
Assertions.assertEquals("90E6FF7755A80B6AA935A5C31B6D3D0CFAF82E06BF2B9CC9", transaction.getTargetAddress().encoded(transaction.getNetworkType()));
Assertions.assertEquals(-1, transaction.getValueSizeDelta());
Assertions.assertEquals(new BigInteger("11529215046069664444"), transaction.getScopedMetadataKey());
Assertions.assertArrayEquals(StringEncoder.getBytes("This is the message for this account! 汉字89664"), transaction.getValue());
}
use of io.nem.symbol.sdk.model.transaction.AccountMetadataTransaction in project nem2-sdk-java by nemtech.
the class AccountMetadataIntegrationTest method addMetadataToAccount.
@ParameterizedTest
@EnumSource(RepositoryType.class)
public void addMetadataToAccount(RepositoryType type) {
BigInteger key = SerializationUtils.toUnsignedBigInteger(RandomUtils.generateRandomInt(100000) + Long.MAX_VALUE);
Assertions.assertTrue(key.compareTo(BigInteger.ZERO) > 0);
System.out.println("Key: " + key);
String message = "This is the message for this account! 汉字" + key;
System.out.println("Storing message '" + message + "' in account metadata " + testAccount.getAddress().plain());
AccountMetadataTransaction transaction = AccountMetadataTransactionFactory.create(getNetworkType(), getDeadline(), testAccount.getAddress(), key, StringEncoder.getBytes(message)).maxFee(maxFee).build();
AccountMetadataTransaction processedTransaction = announceAggregateAndValidate(type, transaction, testAccount).getLeft();
Assertions.assertEquals(transaction.getValueSizeDelta(), processedTransaction.getValueSizeDelta());
Assertions.assertEquals(transaction.getScopedMetadataKey(), processedTransaction.getScopedMetadataKey());
sleep(1000);
Metadata metadata = assertMetadata(transaction, get(getRepositoryFactory(type).createMetadataRepository().search(new MetadataSearchCriteria().metadataType(MetadataType.ACCOUNT).sourceAddress(testAccount.getAddress()))).getData());
assertMetadata(transaction, get(getRepositoryFactory(type).createMetadataRepository().search(new MetadataSearchCriteria().metadataType(MetadataType.ACCOUNT).sourceAddress(testAccount.getAddress()).scopedMetadataKey(metadata.getScopedMetadataKey()))).getData());
assertMetadata(transaction, get(getRepositoryFactory(type).createMetadataRepository().search(new MetadataSearchCriteria().metadataType(MetadataType.ACCOUNT).sourceAddress(testAccount.getAddress()).targetAddress(testAccount.getAddress()).scopedMetadataKey(metadata.getScopedMetadataKey()))).getData());
Assertions.assertArrayEquals(StringEncoder.getBytes(message), processedTransaction.getValue());
}
use of io.nem.symbol.sdk.model.transaction.AccountMetadataTransaction in project nem2-sdk-java by nemtech.
the class TransactionMapperOkHttpTest method shouldCreateAggregateAccountMetadataTransaction.
@Test
void shouldCreateAggregateAccountMetadataTransaction() {
TransactionInfoDTO aggregateTransferTransactionDTO = TestHelperOkHttp.loadTransactionInfoDTO("aggregateAccountMetadataTransaction.json");
AggregateTransaction aggregateTransferTransaction = (AggregateTransaction) map(aggregateTransferTransactionDTO);
validateAggregateTransaction(aggregateTransferTransaction, aggregateTransferTransactionDTO);
AccountMetadataTransaction transaction = (AccountMetadataTransaction) aggregateTransferTransaction.getInnerTransactions().get(0);
Assertions.assertEquals("90E6FF7755A80B6AA935A5C31B6D3D0CFAF82E06BF2B9CC9", transaction.getTargetAddress().encoded(transaction.getNetworkType()));
Assertions.assertEquals(-1, transaction.getValueSizeDelta());
Assertions.assertEquals(new BigInteger("11529215046069664444"), transaction.getScopedMetadataKey());
Assertions.assertArrayEquals(StringEncoder.getBytes("This is the message for this account! 汉字89664"), transaction.getValue());
}
use of io.nem.symbol.sdk.model.transaction.AccountMetadataTransaction in project nem2-sdk-java by nemtech.
the class AccountMetadataServiceIntegrationTest method setAndUpdateAccountMetadata.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void setAndUpdateAccountMetadata(RepositoryType type) {
BigInteger key = BigInteger.valueOf(RandomUtils.generateRandomInt(100000));
String originalMessage = "The original message";
String newMessage = "The new Message";
RepositoryFactory repositoryFactory = getRepositoryFactory(type);
MetadataRepository metadataRepository = repositoryFactory.createMetadataRepository();
MetadataTransactionService service = new MetadataTransactionServiceImpl(repositoryFactory);
AccountMetadataTransaction originalTransaction = get(service.createAccountMetadataTransactionFactory(targetAccount.getAddress(), key, originalMessage, signerAccount.getAddress())).maxFee(maxFee).build();
announceAggregateAndValidate(type, originalTransaction, signerAccount);
sleep(1000);
assertMetadata(key, originalMessage, metadataRepository);
AccountMetadataTransaction updateTransaction = get(service.createAccountMetadataTransactionFactory(targetAccount.getAddress(), key, newMessage, signerAccount.getAddress())).maxFee(maxFee).build();
announceAggregateAndValidate(type, updateTransaction, signerAccount);
sleep(1000);
assertMetadata(key, newMessage, metadataRepository);
}
Aggregations