use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class AbstractEntityRecordItemListenerTest method createEntity.
protected Entity createEntity(EntityId entityId, Key adminKey, Long autoRenewAccountId, Long autoRenewPeriod, Boolean deleted, Long expiryTimeNs, String memo, Key submitKey, Long createdTimestamp, Long modifiedTimestamp) {
byte[] adminKeyBytes = rawBytesFromKey(adminKey);
byte[] submitKeyBytes = rawBytesFromKey(submitKey);
Entity entity = entityId.toEntity();
entity.setAutoRenewAccountId(autoRenewAccountId);
entity.setAutoRenewPeriod(autoRenewPeriod);
entity.setCreatedTimestamp(createdTimestamp);
entity.setDeleted(deleted);
entity.setEthereumNonce(0L);
entity.setExpirationTimestamp(expiryTimeNs);
entity.setMemo(memo);
entity.setTimestampLower(modifiedTimestamp);
entity.setKey(adminKeyBytes);
entity.setSubmitKey(submitKeyBytes);
entity.setStakedAccountId(-1L);
entity.setStakedNodeId(-1L);
entity.setStakePeriodStart(-1L);
return entity;
}
use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class SqlEntityListenerTest method onEntityWithNonHistoryUpdates.
@Test
void onEntityWithNonHistoryUpdates() {
// given
// Update to non-history field with existing entity should just update nonce
Entity existingEntity = domainBuilder.entity().persist();
Entity existingEntityNonce1 = existingEntity.toEntityId().toEntity();
existingEntityNonce1.setEthereumNonce(100L);
existingEntityNonce1.setTimestampRange(null);
Entity existingEntityNonce2 = existingEntity.toEntityId().toEntity();
existingEntityNonce2.setEthereumNonce(101L);
existingEntityNonce2.setTimestampRange(null);
Entity existingEntityStakePeriodStart1 = existingEntity.toEntityId().toEntity();
existingEntityStakePeriodStart1.setStakePeriodStart(2L);
existingEntityStakePeriodStart1.setTimestampRange(null);
Entity existingEntityStakePeriodStart2 = existingEntity.toEntityId().toEntity();
existingEntityStakePeriodStart2.setStakePeriodStart(5L);
existingEntityStakePeriodStart2.setTimestampRange(null);
// Update to non-history field with partial data should be discarded
Entity nonExistingEntity = domainBuilder.entity().get();
Entity nonExistingEntityNonce1 = nonExistingEntity.toEntityId().toEntity();
nonExistingEntityNonce1.setEthereumNonce(200L);
nonExistingEntityNonce1.setTimestampRange(null);
Entity nonExistingEntityNonce2 = nonExistingEntity.toEntityId().toEntity();
nonExistingEntityNonce2.setEthereumNonce(201L);
nonExistingEntityNonce2.setTimestampRange(null);
Entity nonExistingEntityStakePeriodStart1 = nonExistingEntity.toEntityId().toEntity();
nonExistingEntityStakePeriodStart1.setStakePeriodStart(6L);
nonExistingEntityStakePeriodStart1.setTimestampRange(null);
Entity nonExistingEntityStakePeriodStart2 = nonExistingEntity.toEntityId().toEntity();
nonExistingEntityStakePeriodStart2.setStakePeriodStart(8L);
nonExistingEntityStakePeriodStart2.setTimestampRange(null);
// when
sqlEntityListener.onEntity(existingEntityNonce1);
sqlEntityListener.onEntity(existingEntityNonce2);
sqlEntityListener.onEntity(existingEntityStakePeriodStart1);
sqlEntityListener.onEntity(existingEntityStakePeriodStart2);
sqlEntityListener.onEntity(nonExistingEntityNonce1);
sqlEntityListener.onEntity(nonExistingEntityNonce2);
sqlEntityListener.onEntity(nonExistingEntityStakePeriodStart1);
sqlEntityListener.onEntity(nonExistingEntityStakePeriodStart2);
completeFileAndCommit();
existingEntity.setEthereumNonce(existingEntityNonce2.getEthereumNonce());
existingEntity.setStakePeriodStart(existingEntityStakePeriodStart2.getStakePeriodStart());
assertThat(entityRepository.findAll()).containsExactly(existingEntity);
Entity existingEntityNonce3 = existingEntity.toEntityId().toEntity();
existingEntityNonce3.setEthereumNonce(102L);
existingEntityNonce3.setTimestampRange(null);
Entity existingEntityStakePeriodStart3 = existingEntity.toEntityId().toEntity();
existingEntityStakePeriodStart3.setStakePeriodStart(10L);
existingEntityStakePeriodStart3.setTimestampRange(null);
Entity nonExistingEntityNonce3 = domainBuilder.entityId(EntityType.ACCOUNT).toEntity();
nonExistingEntityNonce3.setEthereumNonce(202L);
nonExistingEntityNonce3.setTimestampRange(null);
Entity nonExistingEntityStakePeriodStart3 = domainBuilder.entityId(EntityType.ACCOUNT).toEntity();
nonExistingEntityStakePeriodStart3.setStakePeriodStart(12L);
nonExistingEntityStakePeriodStart3.setTimestampRange(null);
sqlEntityListener.onEntity(existingEntityNonce3);
sqlEntityListener.onEntity(existingEntityStakePeriodStart3);
sqlEntityListener.onEntity(nonExistingEntityNonce3);
sqlEntityListener.onEntity(nonExistingEntityStakePeriodStart3);
completeFileAndCommit();
// then
existingEntity.setEthereumNonce(existingEntityNonce3.getEthereumNonce());
existingEntity.setStakePeriodStart(existingEntityStakePeriodStart3.getStakePeriodStart());
assertThat(entityRepository.findAll()).containsExactly(existingEntity);
assertThat(findHistory(Entity.class)).isEmpty();
}
use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class SqlEntityListenerTest method onEntity.
@Test
void onEntity() {
// given
Entity entity1 = domainBuilder.entity().get();
Entity entity2 = domainBuilder.entity().get();
// when
sqlEntityListener.onEntity(entity1);
sqlEntityListener.onEntity(entity2);
completeFileAndCommit();
// then
assertThat(contractRepository.count()).isZero();
assertThat(entityRepository.findAll()).containsExactlyInAnyOrder(entity1, entity2);
assertThat(findHistory(Entity.class)).isEmpty();
}
Aggregations