Search in sources :

Example 1 with FcCustomFee

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

the class MerkleTokenTest method liveFireSerdeWorks.

@Test
void liveFireSerdeWorks() throws IOException, ConstructableRegistryException {
    final var baos = new ByteArrayOutputStream();
    final var dos = new SerializableDataOutputStream(baos);
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(FcCustomFee.class, FcCustomFee::new));
    ConstructableRegistry.registerConstructable(new ClassConstructorPair(EntityId.class, EntityId::new));
    MerkleToken.serdes = new DomainSerdes();
    subject.serialize(dos);
    dos.flush();
    final var bytes = baos.toByteArray();
    final var bais = new ByteArrayInputStream(bytes);
    final var din = new SerializableDataInputStream(bais);
    final var newSubject = new MerkleToken();
    newSubject.deserialize(din, MerkleToken.CURRENT_VERSION);
    assertEquals(subject, newSubject);
}
Also used : EntityId(com.hedera.services.state.submerkle.EntityId) ByteArrayInputStream(java.io.ByteArrayInputStream) FcCustomFee(com.hedera.services.state.submerkle.FcCustomFee) SerializableDataOutputStream(com.swirlds.common.io.SerializableDataOutputStream) SerializableDataInputStream(com.swirlds.common.io.SerializableDataInputStream) DomainSerdes(com.hedera.services.state.serdes.DomainSerdes) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ClassConstructorPair(com.swirlds.common.constructable.ClassConstructorPair) Test(org.junit.jupiter.api.Test)

Example 2 with FcCustomFee

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

the class FixedFeeAssessorTest method delegatesToHtsWhenDenomIsNonNull.

@Test
void delegatesToHtsWhenDenomIsNonNull() {
    FcCustomFee htsFee = FcCustomFee.fixedFee(1, feeDenom, otherCollector);
    given(htsFeeAssessor.assess(payer, chargingToken, htsFee, changeManager, mockAccum)).willReturn(OK);
    // when:
    final var result = subject.assess(payer, chargingToken, htsFee, changeManager, mockAccum);
    // then:
    Assertions.assertEquals(OK, result);
}
Also used : FcCustomFee(com.hedera.services.state.submerkle.FcCustomFee) Test(org.junit.jupiter.api.Test)

Example 3 with FcCustomFee

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

the class MerkleTokenTest method v0160DeserializeWorks.

@Test
void v0160DeserializeWorks() throws IOException {
    final var fin = mock(SerializableDataInputStream.class);
    given(serdes.readNullableSerializable(any())).willReturn(autoRenewAccount);
    given(serdes.deserializeKey(fin)).willReturn(adminKey);
    given(serdes.readNullable(argThat(fin::equals), any(IoReadingFunction.class))).willReturn(adminKey).willReturn(freezeKey).willReturn(kycKey).willReturn(supplyKey).willReturn(wipeKey).willReturn(feeScheduleKey);
    given(fin.readNormalisedString(anyInt())).willReturn(symbol).willReturn(name).willReturn(memo);
    given(fin.readLong()).willReturn(subject.expiry()).willReturn(subject.autoRenewPeriod()).willReturn(subject.totalSupply()).willReturn(subject.maxSupply()).willReturn(subject.getLastUsedSerialNumber());
    given(fin.readInt()).willReturn(subject.decimals()).willReturn(subject.tokenType().ordinal()).willReturn(subject.supplyType().ordinal());
    given(fin.readBoolean()).willReturn(isDeleted).willReturn(subject.accountsAreFrozenByDefault());
    given(fin.readSerializable()).willReturn(subject.treasury());
    given(fin.<FcCustomFee>readSerializableList(eq(Integer.MAX_VALUE), eq(true), any())).willReturn(feeSchedule);
    final var read = new MerkleToken();
    read.deserialize(fin, MerkleToken.RELEASE_0160_VERSION);
    // and when:
    read.setKey(new EntityNum(number));
    // expect:
    assertEquals(subject, read);
}
Also used : FcCustomFee(com.hedera.services.state.submerkle.FcCustomFee) EntityNum(com.hedera.services.utils.EntityNum) Test(org.junit.jupiter.api.Test)

Aggregations

FcCustomFee (com.hedera.services.state.submerkle.FcCustomFee)3 Test (org.junit.jupiter.api.Test)3 DomainSerdes (com.hedera.services.state.serdes.DomainSerdes)1 EntityId (com.hedera.services.state.submerkle.EntityId)1 EntityNum (com.hedera.services.utils.EntityNum)1 ClassConstructorPair (com.swirlds.common.constructable.ClassConstructorPair)1 SerializableDataInputStream (com.swirlds.common.io.SerializableDataInputStream)1 SerializableDataOutputStream (com.swirlds.common.io.SerializableDataOutputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1