use of com.hedera.mirror.common.domain.StreamFile in project hedera-mirror-node by hashgraph.
the class AbstractStreamFileParserTest method parse.
@Test
void parse() {
// given
StreamFile streamFile = getStreamFile();
// when
parser.parse(streamFile);
// then
assertParsed(streamFile, true, false);
assertPostParseStreamFile(streamFile, true);
}
use of com.hedera.mirror.common.domain.StreamFile in project hedera-mirror-node by hashgraph.
the class AbstractStreamFileParserTest method disabled.
@Test
void disabled() {
// given
parserProperties.setEnabled(false);
StreamFile streamFile = getStreamFile();
// when
parser.parse(streamFile);
// then
assertParsed(streamFile, false, false);
assertPostParseStreamFile(streamFile, true);
}
use of com.hedera.mirror.common.domain.StreamFile in project hedera-mirror-node by hashgraph.
the class MirrorDateRangePropertiesProcessorTest method startDateAfterDatabase.
@ParameterizedTest(name = "startDate is {0}ns after application status")
@ValueSource(longs = { 1, 2_000_000_000L, 200_000_000_000L })
void startDateAfterDatabase(long diffNanos) {
Instant lastFileInstant = Instant.now().minusSeconds(200);
doReturn(streamFile(StreamType.BALANCE, lastFileInstant)).when(accountBalanceFileRepository).findLatest();
doReturn(streamFile(StreamType.EVENT, lastFileInstant)).when(eventFileRepository).findLatest();
doReturn(streamFile(StreamType.RECORD, lastFileInstant)).when(recordFileRepository).findLatest();
Instant startDate = lastFileInstant.plusNanos(diffNanos);
mirrorProperties.setStartDate(startDate);
Instant effectiveStartDate = max(startDate, lastFileInstant);
DateRangeFilter expectedFilter = new DateRangeFilter(startDate, null);
for (var downloaderProperties : downloaderPropertiesList) {
StreamType streamType = downloaderProperties.getStreamType();
Optional<StreamFile> streamFile = streamFile(streamType, effectiveStartDate);
assertThat(mirrorDateRangePropertiesProcessor.getLastStreamFile(streamType)).isEqualTo(streamFile);
assertThat(mirrorDateRangePropertiesProcessor.getDateRangeFilter(downloaderProperties.getStreamType())).isEqualTo(expectedFilter);
}
}
use of com.hedera.mirror.common.domain.StreamFile in project hedera-mirror-node by hashgraph.
the class MirrorDateRangePropertiesProcessorTest method streamFile.
private Optional<StreamFile> streamFile(StreamType streamType, Instant instant) {
StreamFile streamFile = (StreamFile) ReflectUtils.newInstance(streamType.getStreamFileClass());
streamFile.setConsensusStart(DomainUtils.convertToNanosMax(instant));
streamFile.setName(StreamFilename.getFilename(streamType, DATA, instant));
return Optional.of(streamFile);
}
use of com.hedera.mirror.common.domain.StreamFile in project hedera-mirror-node by hashgraph.
the class AbstractDownloaderTest method expectLastStreamFile.
/**
* Sets the expected last stream file. If the precondition is there is no stream files in db, pass in a null index.
*
* @param hash hash of the StreamFile
* @param index the index of the StreamFile
* @param instant the instant of the StreamFile
*/
protected void expectLastStreamFile(String hash, Long index, Instant instant) {
StreamFile streamFile = (StreamFile) ReflectUtils.newInstance(streamType.getStreamFileClass());
streamFile.setName(StreamFilename.getFilename(streamType, DATA, instant));
streamFile.setConsensusStart(DomainUtils.convertToNanosMax(instant));
streamFile.setHash(hash);
streamFile.setIndex(index);
if (hash != null) {
downloaderProperties.getMirrorProperties().setVerifyHashAfter(instant);
}
firstIndex = index == null ? 0L : index + 1;
doReturn(Optional.of(streamFile)).when(dateRangeProcessor).getLastStreamFile(streamType);
}
Aggregations