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);
}
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);
}
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);
}
Aggregations