use of com.hederahashgraph.api.proto.java.ContractID in project hedera-services by hashgraph.
the class GetAccountBalanceAnswerTest method syntaxCheckValidatesCidIfPresent.
@Test
void syntaxCheckValidatesCidIfPresent() {
// setup:
ContractID cid = asContract(contractIdLit);
// given:
CryptoGetAccountBalanceQuery op = CryptoGetAccountBalanceQuery.newBuilder().setContractID(cid).build();
Query query = Query.newBuilder().setCryptogetAccountBalance(op).build();
// and:
given(optionValidator.queryableContractStatus(cid, accounts)).willReturn(CONTRACT_DELETED);
// when:
ResponseCodeEnum status = subject.checkValidity(query, view);
// expect:
assertEquals(CONTRACT_DELETED, status);
}
use of com.hederahashgraph.api.proto.java.ContractID in project hedera-mirror-node by hashgraph.
the class ContractResultServiceImpl method getCreatedContractIds.
@SuppressWarnings("deprecation")
private List<Long> getCreatedContractIds(ContractFunctionResult functionResult, RecordItem recordItem, ContractResult contractResult) {
List<Long> createdContractIds = new ArrayList<>();
boolean persist = shouldPersistCreatedContractIDs(recordItem);
for (ContractID createdContractId : functionResult.getCreatedContractIDsList()) {
EntityId contractId = entityIdService.lookup(createdContractId);
if (!EntityId.isEmpty(contractId)) {
createdContractIds.add(contractId.getId());
// The parent contract ID can also sometimes appear in the created contract IDs list, so exclude it
if (persist && !contractId.equals(contractResult.getContractId())) {
processCreatedContractEntity(recordItem, contractId);
}
}
}
return createdContractIds;
}
use of com.hederahashgraph.api.proto.java.ContractID 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.hederahashgraph.api.proto.java.ContractID in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerContractTest method contractUpdateAllWithMemoToExisting.
@Test
void contractUpdateAllWithMemoToExisting() {
// first create the contract
EntityId contractId = EntityId.of(CONTRACT_ID);
Contract contract = domainBuilder.contract().customize(c -> c.obtainerId(null).id(contractId.getId()).num(contractId.getEntityNum()).stakedNodeId(1L)).persist();
// now update
Transaction transaction = contractUpdateAllTransaction(false);
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord record = getContractTransactionRecord(transactionBody, ContractTransactionType.UPDATE);
ContractUpdateTransactionBody contractUpdateTransactionBody = transactionBody.getContractUpdateInstance();
parseRecordItemAndCommit(new RecordItem(transaction, record));
assertAll(() -> assertEquals(1, transactionRepository.count()), () -> assertEntities(EntityId.of(CONTRACT_ID)), () -> assertEquals(0, contractResultRepository.count()), () -> assertEquals(3, cryptoTransferRepository.count()), () -> assertTransactionAndRecord(transactionBody, record), () -> assertContractEntity(contractUpdateTransactionBody, record.getConsensusTimestamp()).returns(contract.getCreatedTimestamp(), Contract::getCreatedTimestamp).returns(contract.getFileId(), // FileId is ignored on updates by HAPI
Contract::getFileId));
}
use of com.hederahashgraph.api.proto.java.ContractID in project hedera-mirror-node by hashgraph.
the class ContractCallTransactionHandlerTest method testGetEntityIdReceipt.
@Test
void testGetEntityIdReceipt() {
var recordItem = recordItemBuilder.contractCall().build();
ContractID contractIdBody = recordItem.getTransactionBody().getContractCall().getContractID();
ContractID contractIdReceipt = recordItem.getRecord().getReceipt().getContractID();
EntityId expectedEntityId = EntityId.of(contractIdReceipt);
when(entityIdService.lookup(contractIdReceipt, contractIdBody)).thenReturn(expectedEntityId);
EntityId entityId = transactionHandler.getEntity(recordItem);
assertThat(entityId).isEqualTo(expectedEntityId);
}
Aggregations