Search in sources :

Example 1 with AccountInfo

use of com.hederahashgraph.api.proto.java.CryptoGetInfoResponse.AccountInfo in project hedera-mirror-node by hashgraph.

the class HistoricalAccountInfoMigrationTest method update.

@Test
void update() {
    createEntity(ACCOUNT_ID1, EntityType.ACCOUNT, false);
    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));
}
Also used : AbstractEntity(com.hedera.mirror.common.domain.entity.AbstractEntity) Entity(com.hedera.mirror.common.domain.entity.Entity) ByteString(com.google.protobuf.ByteString) AccountInfo(com.hederahashgraph.api.proto.java.CryptoGetInfoResponse.AccountInfo) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest)

Example 2 with AccountInfo

use of com.hederahashgraph.api.proto.java.CryptoGetInfoResponse.AccountInfo in project hedera-mirror-node by hashgraph.

the class HistoricalAccountInfoMigrationTest method skipExisting.

@Test
void skipExisting() {
    AccountInfo.Builder accountInfo = accountInfo();
    Entity entity = createEntity(ACCOUNT_ID1, EntityType.ACCOUNT, true);
    assertThat(historicalAccountInfoMigration.process(accountInfo.build())).isFalse();
    assertThat(entityRepository.findAll()).hasSize(1).containsExactly(entity);
}
Also used : AbstractEntity(com.hedera.mirror.common.domain.entity.AbstractEntity) Entity(com.hedera.mirror.common.domain.entity.Entity) AccountInfo(com.hederahashgraph.api.proto.java.CryptoGetInfoResponse.AccountInfo) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest)

Example 3 with AccountInfo

use of com.hederahashgraph.api.proto.java.CryptoGetInfoResponse.AccountInfo 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));
}
Also used : AbstractEntity(com.hedera.mirror.common.domain.entity.AbstractEntity) Entity(com.hedera.mirror.common.domain.entity.Entity) ByteString(com.google.protobuf.ByteString) AccountInfo(com.hederahashgraph.api.proto.java.CryptoGetInfoResponse.AccountInfo) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest)

Example 4 with AccountInfo

use of com.hederahashgraph.api.proto.java.CryptoGetInfoResponse.AccountInfo 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));
}
Also used : AbstractEntity(com.hedera.mirror.common.domain.entity.AbstractEntity) Entity(com.hedera.mirror.common.domain.entity.Entity) AccountID(com.hederahashgraph.api.proto.java.AccountID) AccountInfo(com.hederahashgraph.api.proto.java.CryptoGetInfoResponse.AccountInfo) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest)

Aggregations

AbstractEntity (com.hedera.mirror.common.domain.entity.AbstractEntity)4 Entity (com.hedera.mirror.common.domain.entity.Entity)4 IntegrationTest (com.hedera.mirror.importer.IntegrationTest)4 AccountInfo (com.hederahashgraph.api.proto.java.CryptoGetInfoResponse.AccountInfo)4 Test (org.junit.jupiter.api.Test)4 ByteString (com.google.protobuf.ByteString)2 AccountID (com.hederahashgraph.api.proto.java.AccountID)1