use of com.swirlds.common.io.SerializableDataInputStream in project hedera-services by hashgraph.
the class MerkleUniqueTokenTest method liveFireSerdeWorks.
@Test
void liveFireSerdeWorks() throws IOException, ConstructableRegistryException {
// setup:
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final var dos = new SerializableDataOutputStream(baos);
ConstructableRegistry.registerConstructable(new ClassConstructorPair(MerkleUniqueToken.class, MerkleUniqueToken::new));
ConstructableRegistry.registerConstructable(new ClassConstructorPair(EntityId.class, EntityId::new));
// 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 MerkleUniqueToken();
newSubject.deserialize(din, MerkleToken.CURRENT_VERSION);
// then:
assertEquals(subject, newSubject);
}
Aggregations