use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class CryptoUpdateTransactionHandlerTest method updateTransactionDeclineReward.
@Test
void updateTransactionDeclineReward() {
RecordItem withDeclineValueSet = recordItemBuilder.cryptoUpdate().transactionBody(body -> body.clear().setDeclineReward(BoolValue.of(true))).build();
setupForCrytoUpdateTransactionTest(withDeclineValueSet, t -> assertThat(t).returns(true, Entity::isDeclineReward).returns(null, Entity::getStakedNodeId).returns(null, Entity::getStakedAccountId).extracting(Entity::getStakePeriodStart).isNotNull());
}
use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class CryptoUpdateTransactionHandlerTest method updateTransactionStakedAccountId.
@Test
void updateTransactionStakedAccountId() {
AccountID accountId = AccountID.newBuilder().setAccountNum(1L).build();
RecordItem withStakedNodeIdSet = recordItemBuilder.cryptoUpdate().transactionBody(body -> body.clear().setStakedAccountId(accountId)).build();
setupForCrytoUpdateTransactionTest(withStakedNodeIdSet, t -> assertThat(t).returns(1L, Entity::getStakedAccountId).returns(false, Entity::isDeclineReward).returns(-1L, Entity::getStakedNodeId).returns(Utility.getEpochDay(withStakedNodeIdSet.getConsensusTimestamp()), Entity::getStakePeriodStart));
}
use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class EntityRepositoryTest method nullCharacter.
@Test
void nullCharacter() {
Entity entity = domainBuilder.entity().customize(e -> e.memo("abc" + (char) 0)).persist();
assertThat(entityRepository.findById(entity.getId())).get().isEqualTo(entity);
}
use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class EntityRepositoryTest method findByAlias.
@Test
void findByAlias() {
Entity entity = domainBuilder.entity().persist();
byte[] alias = entity.getAlias();
assertThat(entityRepository.findByAlias(alias)).get().isEqualTo(entity.getId());
}
use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class EntityRepositoryTest method publicKeyUpdates.
@Test
void publicKeyUpdates() {
Entity entity = domainBuilder.entity().customize(b -> b.key(null)).persist();
// unset key should result in null public key
assertThat(entityRepository.findById(entity.getId())).get().extracting(Entity::getPublicKey).isNull();
// default proto key of single byte should result in empty public key
entity.setKey(Key.getDefaultInstance().toByteArray());
entityRepository.save(entity);
assertThat(entityRepository.findById(entity.getId())).get().extracting(Entity::getPublicKey).isEqualTo("");
// invalid key should be null
entity.setKey("123".getBytes());
entityRepository.save(entity);
assertThat(entityRepository.findById(entity.getId())).get().extracting(Entity::getPublicKey).isNull();
// valid key should not be null
entity.setKey(Key.newBuilder().setEd25519(ByteString.copyFromUtf8("123")).build().toByteArray());
entityRepository.save(entity);
assertThat(entityRepository.findById(entity.getId())).get().extracting(Entity::getPublicKey).isNotNull();
// null key like unset should result in null public key
entity.setKey(null);
entityRepository.save(entity);
assertThat(entityRepository.findById(entity.getId())).get().extracting(Entity::getPublicKey).isNull();
}
Aggregations