use of com.hedera.mirror.common.domain.contract.Contract in project hedera-mirror-node by hashgraph.
the class EntityIdServiceImplTest method lookupContractCreate2EvmAddressNoMatch.
@Test
void lookupContractCreate2EvmAddressNoMatch() {
Contract contract = domainBuilder.contract().get();
assertThrows(AliasNotFoundException.class, () -> entityIdService.lookup(getProtoContractId(contract)));
}
use of com.hedera.mirror.common.domain.contract.Contract in project hedera-mirror-node by hashgraph.
the class ContractRepositoryTest method findByEvmAddress.
@Test
void findByEvmAddress() {
Contract contract = domainBuilder.contract().persist();
assertThat(contractRepository.findByEvmAddress(contract.getEvmAddress())).get().isEqualTo(contract.getId());
}
use of com.hedera.mirror.common.domain.contract.Contract in project hedera-mirror-node by hashgraph.
the class ContractRepositoryTest method save.
@Test
void save() {
Contract contract = domainBuilder.contract().persist();
assertThat(contractRepository.findById(contract.getId())).get().isEqualTo(contract);
}
use of com.hedera.mirror.common.domain.contract.Contract in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerContractTest method contractDeleteToExisting.
@ParameterizedTest
@EnumSource(ContractIdType.class)
void contractDeleteToExisting(ContractIdType contractIdType) {
SetupResult setupResult = setupContract(CONTRACT_ID, contractIdType, true, true);
Transaction transaction = contractDeleteTransaction(setupResult.protoContractId);
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord record = getContractTransactionRecord(transactionBody, ContractTransactionType.DELETE);
RecordItem recordItem = new RecordItem(transaction, record);
parseRecordItemAndCommit(recordItem);
Contract dbContractEntity = getTransactionEntity(record.getConsensusTimestamp());
assertAll(() -> assertEquals(1, transactionRepository.count()), () -> assertEquals(0, contractResultRepository.count()), () -> assertEquals(3, cryptoTransferRepository.count()), () -> assertEntities(setupResult.contract.toEntityId()), () -> assertTransactionAndRecord(transactionBody, record), () -> assertThat(dbContractEntity).isNotNull().returns(true, Contract::getDeleted).returns(recordItem.getConsensusTimestamp(), Contract::getTimestampLower).returns(EntityId.of(PAYER), Contract::getObtainerId).usingRecursiveComparison().ignoringFields("deleted", "obtainerId", "timestampRange").isEqualTo(setupResult.contract));
}
use of com.hedera.mirror.common.domain.contract.Contract in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerContractTest method assertContractEntity.
private void assertContractEntity(RecordItem recordItem) {
long createdTimestamp = recordItem.getConsensusTimestamp();
var transactionBody = recordItem.getTransactionBody().getContractCreateInstance();
var adminKey = transactionBody.getAdminKey().toByteArray();
var transaction = transactionRepository.findById(createdTimestamp).get();
var contractCreateResult = recordItem.getRecord().getContractCreateResult();
byte[] evmAddress = contractCreateResult.hasEvmAddress() ? DomainUtils.toBytes(contractCreateResult.getEvmAddress().getValue()) : null;
EntityId entityId = transaction.getEntityId();
Contract contract = getEntity(entityId);
Long expectedAutoRenewAccountId = transactionBody.hasAutoRenewAccountId() ? transactionBody.getAutoRenewAccountId().getAccountNum() : null;
EntityId expectedFileId = transactionBody.hasFileID() ? EntityId.of(transactionBody.getFileID()) : null;
byte[] expectedInitcode = transactionBody.getInitcode() != ByteString.EMPTY ? DomainUtils.toBytes(transactionBody.getInitcode()) : null;
assertThat(transaction).isNotNull().returns(transactionBody.getInitialBalance(), t -> t.getInitialBalance());
assertThat(contract).isNotNull().returns(expectedAutoRenewAccountId, Contract::getAutoRenewAccountId).returns(transactionBody.getAutoRenewPeriod().getSeconds(), Contract::getAutoRenewPeriod).returns(createdTimestamp, Contract::getCreatedTimestamp).returns(false, Contract::getDeleted).returns(evmAddress, Contract::getEvmAddress).returns(null, Contract::getExpirationTimestamp).returns(expectedFileId, Contract::getFileId).returns(entityId.getId(), Contract::getId).returns(expectedInitcode, Contract::getInitcode).returns(adminKey, Contract::getKey).returns(transactionBody.getMaxAutomaticTokenAssociations(), Contract::getMaxAutomaticTokenAssociations).returns(transactionBody.getMemo(), Contract::getMemo).returns(createdTimestamp, Contract::getTimestampLower).returns(null, Contract::getObtainerId).returns(EntityId.of(transactionBody.getProxyAccountID()), Contract::getProxyAccountId).returns(DomainUtils.getPublicKey(adminKey), Contract::getPublicKey).returns(EntityType.CONTRACT, Contract::getType);
if (entityProperties.getPersist().isContracts()) {
assertCreatedContract(recordItem);
}
}
Aggregations