Search in sources :

Example 16 with EntityId

use of com.hedera.services.state.submerkle.EntityId in project hedera-services by hashgraph.

the class DomainSerdesTest method setupAll.

@BeforeAll
public static void setupAll() throws ConstructableRegistryException {
    /* Per Cody, this will be unnecessary at some point. */
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(ExpirableTxnRecord.class, ExpirableTxnRecord::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(EntityId.class, EntityId::new));
}
Also used : ExpirableTxnRecord(com.hedera.services.state.submerkle.ExpirableTxnRecord) EntityId(com.hedera.services.state.submerkle.EntityId) ClassConstructorPair(com.swirlds.common.constructable.ClassConstructorPair) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 17 with EntityId

use of com.hedera.services.state.submerkle.EntityId in project hedera-services by hashgraph.

the class DomainSerdesTest method readsExpectedForNonNullReadable.

@Test
void readsExpectedForNonNullReadable() throws IOException {
    // setup:
    var in = mock(SerializableDataInputStream.class);
    // and:
    var reader = (IoReadingFunction<EntityId>) mock(IoReadingFunction.class);
    var data = new EntityId(1L, 2L, 3L);
    given(in.readBoolean()).willReturn(true);
    given(reader.read(in)).willReturn(data);
    // when:
    EntityId dataIn = subject.readNullable(in, reader);
    // then:
    verify(in).readBoolean();
    assertEquals(data, dataIn);
}
Also used : EntityId(com.hedera.services.state.submerkle.EntityId) Test(org.junit.jupiter.api.Test)

Example 18 with EntityId

use of com.hedera.services.state.submerkle.EntityId in project hedera-services by hashgraph.

the class UpdateMerkleTopicResourceUsageTest method getFeeThrowsExceptionForBadKeys.

@Test
void getFeeThrowsExceptionForBadKeys() throws DecoderException, IllegalArgumentException {
    final var txnBody = makeTransactionBody(topicId, defaultMemo, JKey.mapJKey(adminKey), JKey.mapJKey(submitKey), IdUtils.asAccount("0.1.2"), null, null);
    final var merkleTopic = new MerkleTopic(defaultMemo, adminKey, submitKey, 0, new EntityId(0, 1, 2), new RichInstant(36_000, 0));
    given(topics.get(EntityNum.fromTopicId(topicId))).willReturn(merkleTopic);
    final var mockedJkey = mockStatic(JKey.class);
    mockedJkey.when(() -> JKey.mapJKey(any())).thenThrow(new DecoderException());
    assertThrows(InvalidTxBodyException.class, () -> subject.usageGiven(txnBody, sigValueObj, view));
    assertThat(logCaptor.warnLogs(), Matchers.contains(Matchers.startsWith("Usage estimation unexpectedly failed for")));
    mockedJkey.close();
}
Also used : EntityId(com.hedera.services.state.submerkle.EntityId) DecoderException(org.apache.commons.codec.DecoderException) MerkleTopic(com.hedera.services.state.merkle.MerkleTopic) RichInstant(com.hedera.services.state.submerkle.RichInstant) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 19 with EntityId

use of com.hedera.services.state.submerkle.EntityId in project hedera-services by hashgraph.

the class EntityExpiryMapFactoryTest method toKeyConversionWorks.

@Test
void toKeyConversionWorks() {
    // given:
    var expected = "/2/e3";
    // when:
    var actual = EntityExpiryMapFactory.toKeyString(new EntityId(0, 2, 3));
    // then:
    assertEquals(expected, actual);
}
Also used : EntityId(com.hedera.services.state.submerkle.EntityId) FeeCalcUtilsTest(com.hedera.services.fees.calculation.FeeCalcUtilsTest) Test(org.junit.jupiter.api.Test)

Example 20 with EntityId

use of com.hedera.services.state.submerkle.EntityId in project hedera-services by hashgraph.

the class TypedTokenStoreTest method setupToken.

private void setupToken() {
    merkleToken = new MerkleToken(expiry, tokenSupply, 0, symbol, name, freezeDefault, true, new EntityId(0, 0, treasuryAccountNum));
    merkleToken.setAutoRenewAccount(new EntityId(0, 0, autoRenewAccountNum));
    merkleToken.setSupplyKey(supplyKey);
    merkleToken.setKycKey(kycKey);
    merkleToken.setFreezeKey(freezeKey);
    merkleToken.setPauseKey(pauseKey);
    merkleToken.setPaused(false);
    token.setTreasury(treasuryAccount);
    token.setAutoRenewAccount(autoRenewAccount);
    token.setTotalSupply(tokenSupply);
    token.setKycKey(kycKey);
    token.setSupplyKey(supplyKey);
    token.setFreezeKey(freezeKey);
    token.setPauseKey(pauseKey);
    token.setFrozenByDefault(freezeDefault);
    token.setIsDeleted(false);
    token.setPaused(false);
    token.setExpiry(expiry);
}
Also used : EntityId(com.hedera.services.state.submerkle.EntityId) MerkleToken(com.hedera.services.state.merkle.MerkleToken)

Aggregations

EntityId (com.hedera.services.state.submerkle.EntityId)35 Test (org.junit.jupiter.api.Test)18 MerkleToken (com.hedera.services.state.merkle.MerkleToken)9 RichInstant (com.hedera.services.state.submerkle.RichInstant)6 MerkleAccount (com.hedera.services.state.merkle.MerkleAccount)5 ExpirableTxnRecord (com.hedera.services.state.submerkle.ExpirableTxnRecord)5 TxnId (com.hedera.services.state.submerkle.TxnId)4 EntityNum (com.hedera.services.utils.EntityNum)4 ClassConstructorPair (com.swirlds.common.constructable.ClassConstructorPair)4 TxnReceipt (com.hedera.services.legacy.core.jproto.TxnReceipt)3 MerkleAccountState (com.hedera.services.state.merkle.MerkleAccountState)3 MerkleTopic (com.hedera.services.state.merkle.MerkleTopic)3 CurrencyAdjustments (com.hedera.services.state.submerkle.CurrencyAdjustments)3 ScheduleStore (com.hedera.services.store.schedule.ScheduleStore)3 AccountID (com.hederahashgraph.api.proto.java.AccountID)3 ByteString (com.google.protobuf.ByteString)2 JKeyList (com.hedera.services.legacy.core.jproto.JKeyList)2 MerkleEntityId (com.hedera.services.state.merkle.MerkleEntityId)2 MerkleUniqueToken (com.hedera.services.state.merkle.MerkleUniqueToken)2 DomainSerdes (com.hedera.services.state.serdes.DomainSerdes)2