use of com.swirlds.common.io.SerializableDataInputStream in project hedera-services by hashgraph.
the class FcAssessedCustomFeeTest method liveFireSerdeWorksForHtsFee0170Version.
@Test
void liveFireSerdeWorksForHtsFee0170Version() throws IOException, ConstructableRegistryException {
// setup:
final var account = new EntityId(1, 2, 3);
final var token = new EntityId(2, 3, 4);
final var amount = 345L;
final var subject = new FcAssessedCustomFee(account, token, amount, FcAssessedCustomFee.UNKNOWN_EFFECTIVE_PAYER_ACCOUNT_NUMS);
// and:
ConstructableRegistry.registerConstructable(new ClassConstructorPair(EntityId.class, EntityId::new));
// and:
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final var dos = new SerializableDataOutputStream(baos);
// given:
subject.serialize(dos);
dos.flush();
// and:
final var bytes = baos.toByteArray();
final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
final var din = new SerializableDataInputStream(bais);
// when:
final var newSubject = new FcAssessedCustomFee();
newSubject.deserialize(din, FcAssessedCustomFee.RELEASE_0170_VERSION);
// then:
assertEquals(subject, newSubject);
}
use of com.swirlds.common.io.SerializableDataInputStream in project hedera-services by hashgraph.
the class FcCustomFeeTest method liveFireSerdesWorkForRoyaltyWithFallback.
@Test
void liveFireSerdesWorkForRoyaltyWithFallback() throws IOException {
final var subject = FcCustomFee.royaltyFee(validNumerator, validDenominator, new FixedFeeSpec(123, denom), feeCollector);
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final var dos = new SerializableDataOutputStream(baos);
subject.serialize(dos);
dos.flush();
final var bytes = baos.toByteArray();
final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
final var din = new SerializableDataInputStream(bais);
final var newSubject = new FcCustomFee();
newSubject.deserialize(din, FcCustomFee.CURRENT_VERSION);
assertEquals(subject.getRoyaltyFeeSpec(), newSubject.getRoyaltyFeeSpec());
assertEquals(subject.getFeeCollector(), newSubject.getFeeCollector());
}
use of com.swirlds.common.io.SerializableDataInputStream in project hedera-services by hashgraph.
the class FcCustomFeeTest method liveFireSerdesWorkForFixed.
@Test
void liveFireSerdesWorkForFixed() throws IOException {
final var fixedSubject = FcCustomFee.fixedFee(fixedUnitsToCollect, denom, feeCollector);
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final var dos = new SerializableDataOutputStream(baos);
fixedSubject.serialize(dos);
dos.flush();
final var bytes = baos.toByteArray();
final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
final var din = new SerializableDataInputStream(bais);
final var newSubject = new FcCustomFee();
newSubject.deserialize(din, FcCustomFee.CURRENT_VERSION);
assertEquals(fixedSubject.getFixedFeeSpec(), newSubject.getFixedFeeSpec());
assertEquals(fixedSubject.getFeeCollector(), newSubject.getFeeCollector());
}
use of com.swirlds.common.io.SerializableDataInputStream in project hedera-services by hashgraph.
the class FcCustomFeeTest method liveFireSerdesWorkForFractional.
@Test
void liveFireSerdesWorkForFractional() throws IOException {
final var subject = FcCustomFee.fractionalFee(validNumerator, validDenominator, minimumUnitsToCollect, maximumUnitsToCollect, netOfTransfers, feeCollector);
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final var dos = new SerializableDataOutputStream(baos);
subject.serialize(dos);
dos.flush();
final var bytes = baos.toByteArray();
final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
final var din = new SerializableDataInputStream(bais);
final var newSubject = new FcCustomFee();
newSubject.deserialize(din, FcCustomFee.CURRENT_VERSION);
assertEquals(subject.getFractionalFeeSpec(), newSubject.getFractionalFeeSpec());
assertEquals(subject.getFeeCollector(), newSubject.getFeeCollector());
}
use of com.swirlds.common.io.SerializableDataInputStream in project hedera-services by hashgraph.
the class FcCustomFeeTest method liveFireSerdesWorkForRoyaltyNoFallback.
@Test
void liveFireSerdesWorkForRoyaltyNoFallback() throws IOException {
final var subject = FcCustomFee.royaltyFee(validNumerator, validDenominator, null, feeCollector);
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final var dos = new SerializableDataOutputStream(baos);
subject.serialize(dos);
dos.flush();
final var bytes = baos.toByteArray();
final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
final var din = new SerializableDataInputStream(bais);
final var newSubject = new FcCustomFee();
newSubject.deserialize(din, FcCustomFee.CURRENT_VERSION);
assertEquals(subject.getRoyaltyFeeSpec(), newSubject.getRoyaltyFeeSpec());
assertEquals(subject.getFeeCollector(), newSubject.getFeeCollector());
}
Aggregations