use of com.swirlds.common.constructable.ClassConstructorPair in project hedera-services by hashgraph.
the class ExpirableTxnRecordSerdeTest method registerRecordConstructables.
public static void registerRecordConstructables() throws ConstructableRegistryException {
ConstructableRegistry.registerConstructable(new ClassConstructorPair(TxnId.class, TxnId::new));
ConstructableRegistry.registerConstructable(new ClassConstructorPair(EntityId.class, EntityId::new));
ConstructableRegistry.registerConstructable(new ClassConstructorPair(FcTokenAllowance.class, FcTokenAllowance::new));
ConstructableRegistry.registerConstructable(new ClassConstructorPair(FcTokenAllowanceId.class, FcTokenAllowanceId::new));
}
use of com.swirlds.common.constructable.ClassConstructorPair in project hedera-services by hashgraph.
the class FcAssessedCustomFeeTest method liveFireSerdeWorksForHbarFeeCurrentVersion.
@Test
void liveFireSerdeWorksForHbarFeeCurrentVersion() throws IOException, ConstructableRegistryException {
// setup:
final var account = new EntityId(1, 2, 3);
final var amount = 345L;
final var subject = new FcAssessedCustomFee(account, amount, effectivePayers);
// 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.CURRENT_VERSION);
// then:
assertEquals(subject, newSubject);
}
use of com.swirlds.common.constructable.ClassConstructorPair 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.swirlds.common.constructable.ClassConstructorPair in project hedera-services by hashgraph.
the class FcAssessedCustomFeeTest method liveFireSerdeWorksForHtsFeeCurrentVersion.
@Test
void liveFireSerdeWorksForHtsFeeCurrentVersion() 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, effectivePayers);
// 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.CURRENT_VERSION);
// then:
assertEquals(subject, newSubject);
}
use of com.swirlds.common.constructable.ClassConstructorPair 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));
}
Aggregations