use of com.hederahashgraph.api.proto.java.ContractID in project hedera-mirror-node by hashgraph.
the class EntityIdServiceImplTest method cache.
@Test
void cache() {
Contract contract = domainBuilder.contract().persist();
ContractID contractId = getProtoContractId(contract);
EntityId expected = contract.toEntityId();
// db query and cache put
assertThat(entityIdService.lookup(contractId)).isEqualTo(expected);
// mark it as deleted
contract.setDeleted(true);
contractRepository.save(contract);
// cache hit
assertThat(entityIdService.lookup(contractId)).isEqualTo(expected);
contractRepository.deleteById(contract.getId());
assertThat(entityIdService.lookup(contractId)).isEqualTo(expected);
// cache miss
reset();
assertThrows(AliasNotFoundException.class, () -> entityIdService.lookup(getProtoContractId(contract)));
}
use of com.hederahashgraph.api.proto.java.ContractID in project hedera-mirror-node by hashgraph.
the class ContractResultMigrationTest method contractFunctionResult.
private ContractFunctionResult.Builder contractFunctionResult() {
long contractNum = ++id;
ContractID contractID = ContractID.newBuilder().setContractNum(contractNum).build();
return ContractFunctionResult.newBuilder().setBloom(ByteString.copyFrom(new byte[] { 0, 1 })).setContractCallResult(ByteString.copyFrom(new byte[] { 2, 3 })).setContractID(contractID).addCreatedContractIDs(ContractID.newBuilder().setContractNum(contractNum + 1).build()).setErrorMessage("").setGasUsed(100L).addLogInfo(ContractLoginfo.newBuilder().setBloom(ByteString.copyFrom(new byte[] { 4, 5 })).setContractID(contractID).setData(ByteString.copyFrom(new byte[] { 6, 7 })).addTopic(ByteString.copyFrom(new byte[] { 0 })).addTopic(ByteString.copyFrom(new byte[] { 1 })).addTopic(ByteString.copyFrom(new byte[] { 2 })).addTopic(ByteString.copyFrom(new byte[] { 3 })).build());
}
use of com.hederahashgraph.api.proto.java.ContractID in project hedera-mirror-node by hashgraph.
the class EntityIdServiceImplTest method lookupContractNum.
@Test
void lookupContractNum() {
ContractID contractId = ContractID.newBuilder().setContractNum(100).build();
assertThat(entityIdService.lookup(contractId)).isEqualTo(EntityId.of(100, CONTRACT));
}
use of com.hederahashgraph.api.proto.java.ContractID in project hedera-mirror-node by hashgraph.
the class EntityIdServiceImplTest method lookupContractThrows.
@Test
void lookupContractThrows() {
ContractID contractId = ContractID.newBuilder().setRealmNum(1).build();
assertThrows(InvalidDatasetException.class, () -> entityIdService.lookup(contractId));
}
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, EntityId parentEntityContractId) {
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(parentEntityContractId)) {
processCreatedContractEntity(recordItem, contractId);
}
}
}
return createdContractIds;
}
Aggregations