use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class SqlEntityListenerTest method makeTransaction.
private Transaction makeTransaction() {
EntityId entityId = EntityId.of(10, 10, 10, ACCOUNT);
Transaction transaction = new Transaction();
transaction.setConsensusTimestamp(101L);
transaction.setEntityId(entityId);
transaction.setNodeAccountId(entityId);
transaction.setMemo("memo".getBytes());
transaction.setNonce(0);
transaction.setType(14);
transaction.setResult(22);
transaction.setTransactionHash("transaction hash".getBytes());
transaction.setTransactionBytes("transaction bytes".getBytes());
transaction.setPayerAccountId(entityId);
transaction.setValidStartNs(1L);
transaction.setValidDurationSeconds(1L);
transaction.setMaxFee(1L);
transaction.setChargedTxFee(1L);
transaction.setInitialBalance(0L);
transaction.setScheduled(true);
return transaction;
}
use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class SqlEntityListenerTest method onSchedule.
@Test
void onSchedule() {
EntityId entityId1 = EntityId.of("0.0.100", EntityType.SCHEDULE);
EntityId entityId2 = EntityId.of("0.0.200", EntityType.SCHEDULE);
Schedule schedule1 = domainBuilder.schedule().get();
Schedule schedule2 = domainBuilder.schedule().get();
// when
sqlEntityListener.onSchedule(schedule1);
sqlEntityListener.onSchedule(schedule2);
completeFileAndCommit();
// then
assertThat(scheduleRepository.findAll()).containsExactlyInAnyOrder(schedule1, schedule2);
}
use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class SqlEntityListenerTest method onEntityMerge.
@Test
void onEntityMerge() {
// given
Entity entity = getEntity(1, 1L, 1L, 0, "memo", keyFromString(KEY));
sqlEntityListener.onEntity(entity);
Entity entityAutoUpdated = getEntity(1, 5L);
EntityId autoRenewAccountId = EntityId.of("0.0.10", ACCOUNT);
entityAutoUpdated.setAutoRenewAccountId(autoRenewAccountId);
entityAutoUpdated.setAutoRenewPeriod(360L);
sqlEntityListener.onEntity(entityAutoUpdated);
Entity entityExpirationUpdated = getEntity(1, 10L);
entityExpirationUpdated.setExpirationTimestamp(720L);
sqlEntityListener.onEntity(entityExpirationUpdated);
Entity entitySubmitKeyUpdated = getEntity(1, 15L);
entitySubmitKeyUpdated.setSubmitKey(keyFromString(KEY2).toByteArray());
sqlEntityListener.onEntity(entitySubmitKeyUpdated);
Entity entityMemoUpdated = getEntity(1, 20L);
entityMemoUpdated.setMemo("memo-updated");
sqlEntityListener.onEntity(entityMemoUpdated);
Entity entityMaxAutomaticTokenAssociationsUpdated = getEntity(1, 25L);
entityMaxAutomaticTokenAssociationsUpdated.setMaxAutomaticTokenAssociations(10);
sqlEntityListener.onEntity(entityMaxAutomaticTokenAssociationsUpdated);
Entity entityReceiverSigRequired = getEntity(1, 30L);
entityReceiverSigRequired.setReceiverSigRequired(true);
sqlEntityListener.onEntity(entityReceiverSigRequired);
// when
completeFileAndCommit();
// then
Entity expected = getEntity(1, 1L, 30L, "memo-updated", keyFromString(KEY), autoRenewAccountId, 360L, null, 720L, 10, true, keyFromString(KEY2));
assertThat(entityRepository.findAll()).containsExactlyInAnyOrder(expected);
assertThat(contractRepository.count()).isZero();
}
use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTokenTest method assertNftTransferInRepository.
private void assertNftTransferInRepository(long consensusTimestamp, long serialNumber, TokenID tokenID, AccountID receiverId, AccountID senderId) {
EntityId receiver = receiverId != null ? EntityId.of(receiverId) : null;
EntityId sender = senderId != null ? EntityId.of(senderId) : null;
var id = new NftTransferId(consensusTimestamp, serialNumber, EntityId.of(tokenID));
assertThat(nftTransferRepository.findById(id)).get().returns(receiver, from(com.hedera.mirror.common.domain.token.NftTransfer::getReceiverAccountId)).returns(sender, from(com.hedera.mirror.common.domain.token.NftTransfer::getSenderAccountId));
}
use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerContractTest method assertCreatedContract.
private void assertCreatedContract(RecordItem recordItem) {
var contractCreateResult = recordItem.getRecord().getContractCreateResult();
byte[] evmAddress = contractCreateResult.hasEvmAddress() ? DomainUtils.toBytes(contractCreateResult.getEvmAddress().getValue()) : null;
EntityId createdId = EntityId.of(recordItem.getRecord().getReceipt().getContractID());
var contractAssert = assertThat(contractRepository.findById(createdId.getId())).get().returns(recordItem.getConsensusTimestamp(), Contract::getCreatedTimestamp).returns(false, Contract::getDeleted).returns(evmAddress, Contract::getEvmAddress).returns(createdId.getId(), Contract::getId).returns(recordItem.getConsensusTimestamp(), Contract::getTimestampLower).returns(createdId.getEntityNum(), Contract::getNum).returns(createdId.getShardNum(), Contract::getShard).returns(createdId.getType(), Contract::getType);
var contractCreateInstance = recordItem.getTransactionBody().getContractCreateInstance();
contractAssert.returns(contractCreateInstance.getDeclineReward(), Contract::isDeclineReward);
if (contractCreateInstance.getStakedIdCase() == ContractCreateTransactionBody.StakedIdCase.STAKEDID_NOT_SET) {
return;
}
contractAssert.returns(Utility.getEpochDay(recordItem.getConsensusTimestamp()), Contract::getStakePeriodStart);
if (contractCreateInstance.hasStakedAccountId()) {
long accountId = AccountIdConverter.INSTANCE.convertToDatabaseColumn(EntityId.of(contractCreateInstance.getStakedAccountId()));
contractAssert.returns(accountId, Contract::getStakedAccountId).returns(-1L, Contract::getStakedNodeId);
} else {
contractAssert.returns(contractCreateInstance.getStakedNodeId(), Contract::getStakedNodeId).returns(-1L, Contract::getStakedAccountId);
}
}
Aggregations