use of com.hedera.mirror.common.domain.entity.EntityType.CONTRACT in project hedera-mirror-node by hashgraph.
the class ContractCreateTransactionHandlerTest method updateTransactionStakedAccountId.
@Test
void updateTransactionStakedAccountId() {
// given
final AccountID accountID = AccountID.newBuilder().setAccountNum(1L).build();
var recordItem = recordItemBuilder.contractCreate().transactionBody(b -> b.clearAutoRenewAccountId().setDeclineReward(false).setStakedAccountId(accountID)).build();
// when
transactionHandler.updateTransaction(transaction(recordItem), recordItem);
// then
verify(entityListener).onContract(contracts.capture());
assertThat(contracts.getValue()).isNotNull().returns(false, Contract::isDeclineReward).returns(accountID.getAccountNum(), Contract::getStakedAccountId).returns(-1L, Contract::getStakedNodeId).returns(Utility.getEpochDay(recordItem.getConsensusTimestamp()), Contract::getStakePeriodStart);
}
use of com.hedera.mirror.common.domain.entity.EntityType.CONTRACT in project hedera-mirror-node by hashgraph.
the class ContractUpdateTransactionHandlerTest method updateTransactionStakedAccountId.
@Test
void updateTransactionStakedAccountId() {
AccountID accountId = AccountID.newBuilder().setAccountNum(1L).build();
RecordItem withStakedNodeIdSet = recordItemBuilder.contractUpdate().transactionBody(body -> body.clear().setStakedAccountId(accountId)).build();
setupForContractUpdateTransactionTest(withStakedNodeIdSet, t -> assertThat(t).returns(1L, Contract::getStakedAccountId).returns(false, Contract::isDeclineReward).returns(-1L, Contract::getStakedNodeId).returns(Utility.getEpochDay(withStakedNodeIdSet.getConsensusTimestamp()), Contract::getStakePeriodStart));
}
use of com.hedera.mirror.common.domain.entity.EntityType.CONTRACT in project hedera-mirror-node by hashgraph.
the class ContractUpdateTransactionHandlerTest method updateTransactionStakedNodeId.
@Test
void updateTransactionStakedNodeId() {
RecordItem withStakedNodeIdSet = recordItemBuilder.contractUpdate().transactionBody(body -> body.setStakedNodeId(1L)).build();
setupForContractUpdateTransactionTest(withStakedNodeIdSet, t -> assertThat(t).returns(1L, Contract::getStakedNodeId).returns(-1L, Contract::getStakedAccountId).returns(true, Contract::isDeclineReward).returns(Utility.getEpochDay(withStakedNodeIdSet.getConsensusTimestamp()), Contract::getStakePeriodStart));
}
use of com.hedera.mirror.common.domain.entity.EntityType.CONTRACT in project hedera-mirror-node by hashgraph.
the class EntityIdServiceImplTest method lookupContracts.
@Test
void lookupContracts() {
ContractID nullContractId = null;
ContractID contractId = ContractID.newBuilder().setContractNum(100).build();
ContractID contractIdInvalid = ContractID.newBuilder().setRealmNum(1).build();
Contract contractDeleted = domainBuilder.contract().customize(e -> e.deleted(true)).persist();
EntityId entityId = entityIdService.lookup(nullContractId, ContractID.getDefaultInstance(), getProtoContractId(contractDeleted), contractIdInvalid, contractId);
assertThat(entityId).isEqualTo(EntityId.of(contractId));
}
use of com.hedera.mirror.common.domain.entity.EntityType.CONTRACT in project hedera-mirror-node by hashgraph.
the class EntityIdServiceImplTest method lookupContractsAliasNotFoundActionError.
@Test
void lookupContractsAliasNotFoundActionError() {
Contract contract1 = domainBuilder.contract().get();
Contract contract2 = domainBuilder.contract().customize(c -> c.evmAddress(null)).get();
assertThrows(AliasNotFoundException.class, () -> entityIdService.lookup(AliasNotFoundAction.ERROR, getProtoContractId(contract1), getProtoContractId(contract2)));
}
Aggregations