use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class HistoricalAccountInfoMigrationTest method create.
@Test
void create() {
AccountInfo.Builder accountInfo = accountInfo();
String publicKey = DomainUtils.getPublicKey(accountInfo.getKey().toByteArray());
assertThat(historicalAccountInfoMigration.process(accountInfo.build())).isTrue();
assertThat(entityRepository.findById(ACCOUNT_ID1)).get().returns(accountInfo.getAutoRenewPeriod().getSeconds(), from(Entity::getAutoRenewPeriod)).returns(accountInfo.getDeleted(), from(Entity::getDeleted)).returns(publicKey, from(Entity::getPublicKey)).returns(DomainUtils.timeStampInNanos(accountInfo.getExpirationTime()), from(Entity::getExpirationTimestamp)).returns(accountInfo.getKey().toByteArray(), from(Entity::getKey)).returns(accountInfo.getMemo(), from(Entity::getMemo)).returns(EntityId.of(accountInfo.getProxyAccountID()), from(Entity::getProxyAccountId));
}
use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class HistoricalAccountInfoMigrationTest method existingEntitiesWrongType.
@Test
void existingEntitiesWrongType() throws Exception {
Entity entity1 = createEntity(ACCOUNT_ID1, EntityType.ACCOUNT, true);
Entity entity2 = createEntity(ACCOUNT_ID2, EntityType.ACCOUNT, true);
Entity entity3 = createEntity(ACCOUNT_ID3, EntityType.ACCOUNT, true);
Entity entity4 = createEntity(CONTRACT_ID1, EntityType.ACCOUNT, true);
historicalAccountInfoMigration.doMigrate();
assertThat(contractRepository.findAll()).hasSize(CONTRACT_COUNT).first().returns(EntityType.CONTRACT, Contract::getType).returns(entity4.getNum(), Contract::getNum);
assertThat(entityRepository.findAll()).containsExactlyInAnyOrder(entity1, entity2, entity3);
}
use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class HistoricalAccountInfoMigrationTest method emptyValues.
@Test
void emptyValues() {
AccountID accountId = AccountID.newBuilder().setAccountNum(ACCOUNT_ID1).build();
AccountInfo.Builder accountInfo = accountInfo().clear().setAccountID(accountId);
assertThat(historicalAccountInfoMigration.process(accountInfo.build())).isTrue();
assertThat(entityRepository.findById(ACCOUNT_ID1)).get().returns(null, from(Entity::getAutoRenewPeriod)).returns(false, from(Entity::getDeleted)).returns(null, from(Entity::getPublicKey)).returns(null, from(Entity::getExpirationTimestamp)).returns(null, from(Entity::getKey)).returns("", from(Entity::getMemo)).returns(null, from(Entity::getProxyAccountId));
}
use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class RemoveInvalidEntityMigrationTest method verifyEntityTypeMigrationInvalidEntities.
@Test
void verifyEntityTypeMigrationInvalidEntities() throws Exception {
EntityId typeMismatchedAccountEntityId = entityId(1, EntityType.TOPIC);
EntityId typeMismatchedContractEntityId = entityId(2, EntityType.TOKEN);
EntityId typeMismatchedFileEntityId = entityId(3, EntityType.CONTRACT);
EntityId typeMismatchedTopicEntityId = entityId(4, EntityType.ACCOUNT);
EntityId typeMismatchedTokenEntityId = entityId(5, EntityType.FILE);
insertEntity(typeMismatchedAccountEntityId);
insertEntity(typeMismatchedContractEntityId);
insertEntity(typeMismatchedFileEntityId);
insertEntity(typeMismatchedTopicEntityId);
insertEntity(typeMismatchedTokenEntityId);
List<Transaction> transactionList = new ArrayList<>();
transactionList.add(transaction(1, 1, EntityType.ACCOUNT, ResponseCodeEnum.SUCCESS, TransactionType.CRYPTOCREATEACCOUNT));
transactionList.add(transaction(20, 2, EntityType.CONTRACT, ResponseCodeEnum.SUCCESS, TransactionType.CONTRACTCREATEINSTANCE));
transactionList.add(transaction(30, 3, EntityType.FILE, ResponseCodeEnum.SUCCESS, TransactionType.FILECREATE));
transactionList.add(transaction(40, 4, EntityType.TOPIC, ResponseCodeEnum.SUCCESS, TransactionType.CONSENSUSCREATETOPIC));
transactionList.add(transaction(50, 5, EntityType.TOKEN, ResponseCodeEnum.SUCCESS, TransactionType.TOKENCREATION));
transactionList.add(transaction(70, 50, EntityType.TOPIC, ResponseCodeEnum.INVALID_TOPIC_ID, TransactionType.CONSENSUSSUBMITMESSAGE));
transactionList.add(transaction(80, 100, EntityType.TOPIC, ResponseCodeEnum.TOPIC_EXPIRED, TransactionType.CONSENSUSSUBMITMESSAGE));
transactionList.forEach(this::insertTransaction);
// migration
migrate();
assertEquals(5, getEntityCount());
assertEquals(7, transactionRepository.count());
assertAll(() -> assertThat(findEntityById(typeMismatchedAccountEntityId.getId())).extracting(Entity::getType).isEqualTo(EntityType.ACCOUNT), () -> assertThat(findEntityById(typeMismatchedContractEntityId.getId())).extracting(Entity::getType).isEqualTo(EntityType.CONTRACT), () -> assertThat(findEntityById(typeMismatchedFileEntityId.getId())).extracting(Entity::getType).isEqualTo(EntityType.FILE), () -> assertThat(findEntityById(typeMismatchedTopicEntityId.getId())).extracting(Entity::getType).isEqualTo(EntityType.TOPIC), () -> assertThat(findEntityById(typeMismatchedTokenEntityId.getId())).extracting(Entity::getType).isEqualTo(EntityType.TOKEN));
}
use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class CleanupEntityMigrationTest method entity.
private Entity entity(long id, EntityType entityType) {
Entity entity = new Entity();
entity.setId(id);
entity.setNum(id);
entity.setRealm(0L);
entity.setShard(0L);
entity.setType(entityType);
entity.setAutoRenewAccountId(EntityIdEndec.encode(1, 2, 3));
entity.setProxyAccountId(EntityId.of("4.5.6", EntityType.ACCOUNT));
return entity;
}
Aggregations