use of com.hedera.mirror.common.domain.contract.ContractResult in project hedera-mirror-node by hashgraph.
the class ContractCreateTransactionHandlerTest method updateContractResultNonContractCallTransaction.
@Test
void updateContractResultNonContractCallTransaction() {
ContractResult contractResult = ContractResult.builder().build();
var recordItem = recordItemBuilder.contractCall().build();
transactionHandler.updateContractResult(contractResult, recordItem);
assertThat(contractResult).returns(null, ContractResult::getAmount).returns(null, ContractResult::getGasLimit).returns(null, ContractResult::getFunctionParameters);
}
use of com.hedera.mirror.common.domain.contract.ContractResult in project hedera-mirror-node by hashgraph.
the class ContractResultRepositoryTest method save.
@Test
void save() {
ContractResult contractResult = domainBuilder.contractResult().persist();
assertThat(contractResultRepository.findById(contractResult.getId())).get().isEqualTo(contractResult);
}
use of com.hedera.mirror.common.domain.contract.ContractResult in project hedera-mirror-node by hashgraph.
the class ContractResultServiceImpl method processContractResult.
private void processContractResult(RecordItem recordItem, EntityId contractEntityId, ContractFunctionResult functionResult, TransactionHandler transactionHandler) {
// create child contracts regardless of contractResults support
List<Long> contractIds = getCreatedContractIds(functionResult, recordItem, contractEntityId);
if (!entityProperties.getPersist().isContractResults()) {
return;
}
ContractResult contractResult = new ContractResult();
contractResult.setConsensusTimestamp(recordItem.getConsensusTimestamp());
contractResult.setContractId(contractEntityId);
contractResult.setPayerAccountId(recordItem.getPayerAccountId());
transactionHandler.updateContractResult(contractResult, recordItem);
if (isValidContractFunctionResult(functionResult)) {
if (!isContractCreateOrCall(recordItem.getTransactionBody())) {
// amount, gasLimit and functionParameters were missing from record proto prior to HAPI v0.25
contractResult.setAmount(functionResult.getAmount());
contractResult.setGasLimit(functionResult.getGas());
contractResult.setFunctionParameters(DomainUtils.toBytes(functionResult.getFunctionParameters()));
}
contractResult.setBloom(DomainUtils.toBytes(functionResult.getBloom()));
contractResult.setCallResult(DomainUtils.toBytes(functionResult.getContractCallResult()));
contractResult.setCreatedContractIds(contractIds);
contractResult.setErrorMessage(functionResult.getErrorMessage());
contractResult.setFunctionResult(functionResult.toByteArray());
contractResult.setGasUsed(functionResult.getGasUsed());
if (functionResult.hasSenderId()) {
contractResult.setSenderId(EntityId.of(functionResult.getSenderId()));
}
processContractLogs(functionResult, contractResult);
processContractStateChanges(functionResult, contractResult);
}
entityListener.onContractResult(contractResult);
}
use of com.hedera.mirror.common.domain.contract.ContractResult in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerContractTest method assertContractCallResult.
private void assertContractCallResult(ContractCallTransactionBody transactionBody, TransactionRecord record) {
long consensusTimestamp = DomainUtils.timestampInNanosMax(record.getConsensusTimestamp());
ContractFunctionResult result = record.getContractCallResult();
// get the corresponding entity id from the local cache, fall back to parseContractId if not found.
ContractID protoContractId = record.getContractCallResult().getContractID();
EntityId contractId = contractIds.getOrDefault(protoContractId, parseContractId(protoContractId));
ObjectAssert<ContractResult> contractResult = assertThat(contractResultRepository.findAll()).filteredOn(c -> c.getConsensusTimestamp().equals(consensusTimestamp)).hasSize(1).first().returns(transactionBody.getAmount(), ContractResult::getAmount).returns(contractId, ContractResult::getContractId).returns(consensusTimestamp, ContractResult::getConsensusTimestamp).returns(toBytes(transactionBody.getFunctionParameters()), ContractResult::getFunctionParameters).returns(transactionBody.getGas(), ContractResult::getGasLimit);
assertContractResult(consensusTimestamp, result, result.getLogInfoList(), contractResult, result.getStateChangesList());
}
use of com.hedera.mirror.common.domain.contract.ContractResult in project hedera-mirror-node by hashgraph.
the class CompositeBatchPersisterTest method persist.
@Test
@Transactional
void persist() {
Contract contract = domainBuilder.contract().get();
ContractResult contractResult = domainBuilder.contractResult().get();
compositeBatchInserter.persist(List.of(contract));
compositeBatchInserter.persist(List.of(contractResult));
assertThat(contractRepository.findAll()).containsExactly(contract);
assertThat(contractResultRepository.findAll()).containsExactly(contractResult);
}
Aggregations