use of com.swirlds.common.io.SelfSerializable in project hedera-services by hashgraph.
the class RecordStreamFileParsingTest method parseV5.
void parseV5(final String dir, final Hash expectedStartHash) throws Exception {
final File out = new File(dir + "/out.log");
// these files are generated with initial Hash be an empty Hash
final File recordsDir = new File(dir);
Iterator<SelfSerializable> iterator = LinkedObjectStreamUtilities.parseStreamDirOrFile(recordsDir, Release023xStreamType.RELEASE_023x_STREAM_TYPE);
Hash startHash = null;
int recordsCount = 0;
Hash endHash = null;
try (BufferedWriter writer = new BufferedWriter(new FileWriter(out))) {
while (iterator.hasNext()) {
SelfSerializable object = iterator.next();
if (startHash == null) {
startHash = (Hash) object;
writer.write(startHash.toString());
writer.write("\n");
} else if (!iterator.hasNext()) {
endHash = (Hash) object;
writer.write(endHash.toString());
writer.write("\n");
break;
} else {
assertTrue(object instanceof RecordStreamObject);
RecordStreamObject recordStreamObject = (RecordStreamObject) object;
writer.write(recordStreamObject.toShortString());
writer.write("\n");
assertNotNull(recordStreamObject.getTimestamp());
recordsCount++;
}
}
}
// the record streams are generated with an empty startHash
assertEquals(expectedStartHash, startHash);
assertNotEquals(0, recordsCount);
assertNotEquals(startHash, endHash);
}
Aggregations