use of com.hederahashgraph.api.proto.java.TransactionBody in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerCryptoTest method cryptoDeleteLiveHash.
@Test
void cryptoDeleteLiveHash() {
Transaction transactionAddLiveHash = cryptoAddLiveHashTransaction();
parseRecordItemAndCommit(new RecordItem(transactionAddLiveHash, transactionRecordSuccess(getTransactionBody(transactionAddLiveHash))));
// now delete the live hash
Transaction transaction = cryptoDeleteLiveHashTransaction();
TransactionBody transactionBody = getTransactionBody(transaction);
CryptoDeleteLiveHashTransactionBody deleteLiveHashTransactionBody = transactionBody.getCryptoDeleteLiveHash();
TransactionRecord record = transactionRecordSuccess(transactionBody);
parseRecordItemAndCommit(new RecordItem(transaction, record));
assertAll(() -> assertEquals(2, transactionRepository.count()), () -> assertEntities(), () -> assertCryptoTransfers(6), () -> assertEquals(1, liveHashRepository.count()), () -> assertTransactionAndRecord(transactionBody, record));
}
use of com.hederahashgraph.api.proto.java.TransactionBody in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerCryptoTest method cryptoUpdateFailedTransaction.
@Test
void cryptoUpdateFailedTransaction() {
Transaction createTransaction = cryptoCreateTransaction();
TransactionRecord createRecord = transactionRecordSuccess(getTransactionBody(createTransaction));
parseRecordItemAndCommit(new RecordItem(createTransaction, createRecord));
// now update
Transaction transaction = cryptoUpdateTransaction(accountId1);
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord record = transactionRecord(transactionBody, ResponseCodeEnum.INSUFFICIENT_ACCOUNT_BALANCE);
parseRecordItemAndCommit(new RecordItem(transaction, record));
Entity dbAccountEntityBefore = getTransactionEntity(createRecord.getConsensusTimestamp());
Entity dbAccountEntity = getTransactionEntity(record.getConsensusTimestamp());
assertAll(() -> assertEquals(2, transactionRepository.count()), () -> assertEntities(EntityId.of(accountId1)), // 3 + 3 fee transfers with one transfer per account
() -> assertCryptoTransfers(6), () -> assertTransactionAndRecord(transactionBody, record), () -> assertAccount(record.getReceipt().getAccountID(), dbAccountEntity), // no changes to entity
() -> assertEquals(dbAccountEntityBefore, dbAccountEntity));
}
use of com.hederahashgraph.api.proto.java.TransactionBody in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerCryptoTest method cryptoUpdateSuccessfulTransaction.
@Test
void cryptoUpdateSuccessfulTransaction() {
createAccount();
// now update
Transaction transaction = cryptoUpdateTransaction(accountId1);
TransactionBody transactionBody = getTransactionBody(transaction);
CryptoUpdateTransactionBody cryptoUpdateTransactionBody = transactionBody.getCryptoUpdateAccount();
TransactionRecord record = transactionRecordSuccess(transactionBody);
parseRecordItemAndCommit(new RecordItem(transaction, record));
Entity dbAccountEntity = getTransactionEntity(record.getConsensusTimestamp());
assertAll(() -> assertEquals(2, transactionRepository.count()), () -> assertEntities(EntityId.of(accountId1)), () -> assertEquals(6, cryptoTransferRepository.count()), () -> assertCryptoTransaction(transactionBody, record), // transaction body inputs
() -> assertEquals(cryptoUpdateTransactionBody.getAutoRenewPeriod().getSeconds(), dbAccountEntity.getAutoRenewPeriod()), () -> assertEquals(DomainUtils.getPublicKey(cryptoUpdateTransactionBody.getKey().toByteArray()), dbAccountEntity.getPublicKey()), () -> assertEquals(EntityId.of(cryptoUpdateTransactionBody.getProxyAccountID()), dbAccountEntity.getProxyAccountId()), () -> assertArrayEquals(cryptoUpdateTransactionBody.getKey().toByteArray(), dbAccountEntity.getKey()), () -> assertEquals(cryptoUpdateTransactionBody.getMaxAutomaticTokenAssociations().getValue(), dbAccountEntity.getMaxAutomaticTokenAssociations()), () -> assertEquals(cryptoUpdateTransactionBody.getMemo().getValue(), dbAccountEntity.getMemo()), () -> assertEquals(DomainUtils.timeStampInNanos(cryptoUpdateTransactionBody.getExpirationTime()), dbAccountEntity.getExpirationTimestamp()), () -> assertEquals(DomainUtils.timestampInNanosMax(record.getConsensusTimestamp()), dbAccountEntity.getTimestampLower()), () -> assertFalse(dbAccountEntity.getReceiverSigRequired()), () -> assertFalse(dbAccountEntity.isDeclineReward()), () -> assertEquals(cryptoUpdateTransactionBody.getStakedNodeId(), dbAccountEntity.getStakedNodeId()), () -> assertEquals(-1L, dbAccountEntity.getStakedAccountId()), () -> assertEquals(Utility.getEpochDay(DomainUtils.timestampInNanosMax(record.getConsensusTimestamp())), dbAccountEntity.getStakePeriodStart()));
}
use of com.hederahashgraph.api.proto.java.TransactionBody in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerCryptoTest method cryptoAddLiveHashDoNotPersist.
@Test
void cryptoAddLiveHashDoNotPersist() {
entityProperties.getPersist().setClaims(false);
Transaction transaction = cryptoAddLiveHashTransaction();
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord record = transactionRecordSuccess(transactionBody);
parseRecordItemAndCommit(new RecordItem(transaction, record));
assertAll(() -> assertEquals(1, transactionRepository.count()), () -> assertEntities(), () -> assertCryptoTransfers(3), () -> assertEquals(0, liveHashRepository.count()), () -> assertTransactionAndRecord(transactionBody, record));
}
use of com.hederahashgraph.api.proto.java.TransactionBody in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerCryptoTest method cryptoTransferWithUnknownAlias.
@ParameterizedTest
@EnumSource(value = PartialDataAction.class, names = { "DEFAULT", "SKIP" })
void cryptoTransferWithUnknownAlias(PartialDataAction partialDataAction) {
// given
// both accounts have alias, and only account2's alias is in db
entityProperties.getPersist().setCryptoTransferAmounts(true);
entityProperties.getPersist().setNonFeeTransfers(true);
parserProperties.setPartialDataAction(partialDataAction);
Entity account1 = domainBuilder.entity().get();
Entity account2 = domainBuilder.entity().persist();
// crypto transfer from unknown account1 alias to account2 alias
Transaction transaction = buildTransaction(builder -> builder.getCryptoTransferBuilder().getTransfersBuilder().addAccountAmounts(accountAliasAmount(DomainUtils.fromBytes(account1.getAlias()), 100)).addAccountAmounts(accountAliasAmount(DomainUtils.fromBytes(account2.getAlias()), -100)));
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord transactionRecord = buildTransactionRecord(r -> r.getTransferListBuilder().addAccountAmounts(accountAmount(account1.getNum(), 100)).addAccountAmounts(accountAmount(account2.getNum(), -100)), transactionBody, ResponseCodeEnum.SUCCESS.getNumber());
List<EntityId> expectedEntityIds = partialDataAction == PartialDataAction.DEFAULT ? Arrays.asList(account2.toEntityId(), null) : List.of(account2.toEntityId());
// when
parseRecordItemAndCommit(new RecordItem(transaction, transactionRecord));
// then
assertAll(() -> assertEquals(1, transactionRepository.count()), () -> assertEquals(5, cryptoTransferRepository.count()), () -> assertTransactionAndRecord(transactionBody, transactionRecord), () -> assertThat(findNonFeeTransfers()).extracting(NonFeeTransfer::getEntityId).containsExactlyInAnyOrderElementsOf(expectedEntityIds));
}
Aggregations