use of com.hedera.mirror.common.domain.transaction.Transaction in project hedera-mirror-node by hashgraph.
the class TokenUpdateTransactionHandlerTest method noTreasuryUpdate.
@Test
void noTreasuryUpdate() {
AbstractEntity entity = getExpectedUpdatedEntity();
TokenTransferList tokenTransferList = TokenTransferList.newBuilder().setToken(TokenID.newBuilder().setTokenNum(3L).build()).addNftTransfers(NftTransfer.newBuilder().setReceiverAccountID(AccountID.newBuilder().setAccountNum(2L).build()).setSenderAccountID(AccountID.newBuilder().setAccountNum(1L).build()).setSerialNumber(// Not wildcard
1L).build()).build();
TransactionRecord record = getDefaultTransactionRecord().addTokenTransferLists(tokenTransferList).build();
RecordItem recordItem = getRecordItem(getDefaultTransactionBody().build(), record);
when(entityIdService.lookup(AccountID.newBuilder().setAccountNum(DEFAULT_AUTO_RENEW_ACCOUNT_NUM).build())).thenReturn(EntityIdEndec.decode(DEFAULT_AUTO_RENEW_ACCOUNT_NUM, EntityType.ACCOUNT));
Transaction transaction = new Transaction();
transaction.setEntityId(entity.toEntityId());
transactionHandler.updateTransaction(transaction, recordItem);
Mockito.verifyNoInteractions(nftRepository);
}
use of com.hedera.mirror.common.domain.transaction.Transaction in project hedera-mirror-node by hashgraph.
the class EthereumTransactionHandlerTest method updateTransactionDisabled.
@Test
void updateTransactionDisabled() {
entityProperties.getPersist().setEthereumTransactions(false);
var recordItem = recordItemBuilder.ethereumTransaction(true).build();
transactionHandler.updateTransaction(new Transaction(), recordItem);
// verify parse and listener are never called
verify(entityListener, never()).onEntity(any());
verify(entityListener, never()).onEthereumTransaction(any());
verify(ethereumTransactionParser, never()).decode(any());
}
use of com.hedera.mirror.common.domain.transaction.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListener method buildTransaction.
private Transaction buildTransaction(long consensusTimestamp, RecordItem recordItem) {
TransactionBody body = recordItem.getTransactionBody();
TransactionRecord txRecord = recordItem.getRecord();
Long validDurationSeconds = body.hasTransactionValidDuration() ? body.getTransactionValidDuration().getSeconds() : null;
// transactions in stream always have valid node account id.
var nodeAccount = EntityId.of(body.getNodeAccountID());
var transactionId = body.getTransactionID();
// build transaction
Transaction transaction = new Transaction();
transaction.setChargedTxFee(txRecord.getTransactionFee());
transaction.setConsensusTimestamp(consensusTimestamp);
transaction.setIndex(recordItem.getTransactionIndex());
transaction.setInitialBalance(0L);
transaction.setMaxFee(body.getTransactionFee());
transaction.setMemo(DomainUtils.toBytes(body.getMemoBytes()));
transaction.setNodeAccountId(nodeAccount);
transaction.setNonce(transactionId.getNonce());
transaction.setPayerAccountId(recordItem.getPayerAccountId());
transaction.setResult(txRecord.getReceipt().getStatusValue());
transaction.setScheduled(txRecord.hasScheduleRef());
transaction.setTransactionBytes(entityProperties.getPersist().isTransactionBytes() ? recordItem.getTransactionBytes() : null);
transaction.setTransactionHash(DomainUtils.toBytes(txRecord.getTransactionHash()));
transaction.setType(recordItem.getTransactionType());
transaction.setValidDurationSeconds(validDurationSeconds);
transaction.setValidStartNs(DomainUtils.timeStampInNanos(transactionId.getTransactionValidStart()));
if (txRecord.hasParentConsensusTimestamp()) {
transaction.setParentConsensusTimestamp(DomainUtils.timestampInNanosMax(txRecord.getParentConsensusTimestamp()));
}
return transaction;
}
use of com.hedera.mirror.common.domain.transaction.Transaction in project hedera-mirror-node by hashgraph.
the class ContractResultServiceImplIntegrationTest method parseRecordItemAndCommit.
protected void parseRecordItemAndCommit(RecordItem recordItem, Transaction transaction) {
transactionTemplate.executeWithoutResult(status -> {
Instant instant = Instant.ofEpochSecond(0, recordItem.getConsensusTimestamp());
String filename = StreamFilename.getFilename(StreamType.RECORD, DATA, instant);
long consensusStart = recordItem.getConsensusTimestamp();
RecordFile recordFile = domainBuilder.recordFile().customize(x -> x.consensusStart(consensusStart).consensusEnd(consensusStart + 1).name(filename)).get();
recordStreamFileListener.onStart();
contractResultService.process(recordItem, transaction);
// commit, close connection
recordStreamFileListener.onEnd(recordFile);
});
}
use of com.hedera.mirror.common.domain.transaction.Transaction in project hedera-mirror-node by hashgraph.
the class RemoveInvalidEntityMigrationTest method verifyEntityTypeMigrationInvalidEntitiesMultiBatch.
@Test
void verifyEntityTypeMigrationInvalidEntitiesMultiBatch() throws Exception {
insertEntity(entityId(1, EntityType.ACCOUNT));
insertEntity(entityId(2, EntityType.CONTRACT));
insertEntity(entityId(3, EntityType.FILE));
insertEntity(entityId(4, EntityType.TOPIC));
insertEntity(entityId(5, EntityType.TOKEN));
EntityId typeMismatchedAccountEntityId = entityId(6, EntityType.TOPIC);
EntityId typeMismatchedContractEntityId = entityId(7, EntityType.TOKEN);
EntityId typeMismatchedFileEntityId = entityId(8, EntityType.CONTRACT);
EntityId typeMismatchedTopicEntityId = entityId(9, EntityType.ACCOUNT);
EntityId typeMismatchedTokenEntityId = entityId(10, EntityType.FILE);
insertEntity(typeMismatchedAccountEntityId);
insertEntity(typeMismatchedContractEntityId);
insertEntity(typeMismatchedFileEntityId);
insertEntity(typeMismatchedTopicEntityId);
insertEntity(typeMismatchedTokenEntityId);
List<Transaction> transactionList = new ArrayList<>();
transactionList.add(transaction(1, 1, EntityType.ACCOUNT, ResponseCodeEnum.SUCCESS, TransactionType.CRYPTOCREATEACCOUNT));
transactionList.add(transaction(20, 2, EntityType.CONTRACT, ResponseCodeEnum.SUCCESS, TransactionType.CONTRACTCREATEINSTANCE));
transactionList.add(transaction(30, 3, EntityType.FILE, ResponseCodeEnum.SUCCESS, TransactionType.FILECREATE));
transactionList.add(transaction(40, 4, EntityType.TOPIC, ResponseCodeEnum.SUCCESS, TransactionType.CONSENSUSCREATETOPIC));
transactionList.add(transaction(50, 5, EntityType.TOKEN, ResponseCodeEnum.SUCCESS, TransactionType.TOKENCREATION));
transactionList.add(transaction(60, 6, EntityType.ACCOUNT, ResponseCodeEnum.SUCCESS, TransactionType.CRYPTOCREATEACCOUNT));
transactionList.add(transaction(70, 7, EntityType.CONTRACT, ResponseCodeEnum.SUCCESS, TransactionType.CONTRACTCREATEINSTANCE));
transactionList.add(transaction(80, 8, EntityType.FILE, ResponseCodeEnum.SUCCESS, TransactionType.FILECREATE));
transactionList.add(transaction(90, 9, EntityType.TOPIC, ResponseCodeEnum.SUCCESS, TransactionType.CONSENSUSCREATETOPIC));
transactionList.add(transaction(100, 10, EntityType.TOKEN, ResponseCodeEnum.SUCCESS, TransactionType.TOKENCREATION));
transactionList.add(transaction(500, 50, EntityType.TOPIC, ResponseCodeEnum.INVALID_TOPIC_ID, TransactionType.CONSENSUSSUBMITMESSAGE));
transactionList.add(transaction(1000, 100, EntityType.TOPIC, ResponseCodeEnum.TOPIC_EXPIRED, TransactionType.CONSENSUSSUBMITMESSAGE));
transactionList.forEach(this::insertTransaction);
// migration
migrate();
assertEquals(10, getEntityCount());
assertEquals(12, transactionRepository.count());
assertAll(() -> assertThat(findEntityById(typeMismatchedAccountEntityId.getId())).extracting(Entity::getType).isEqualTo(EntityType.ACCOUNT), () -> assertThat(findEntityById(typeMismatchedContractEntityId.getId())).extracting(Entity::getType).isEqualTo(EntityType.CONTRACT), () -> assertThat(findEntityById(typeMismatchedFileEntityId.getId())).extracting(Entity::getType).isEqualTo(EntityType.FILE), () -> assertThat(findEntityById(typeMismatchedTopicEntityId.getId())).extracting(Entity::getType).isEqualTo(EntityType.TOPIC), () -> assertThat(findEntityById(typeMismatchedTokenEntityId.getId())).extracting(Entity::getType).isEqualTo(EntityType.TOKEN));
}
Aggregations