use of com.hedera.mirror.importer.config.MirrorDateRangePropertiesProcessor.DateRangeFilter in project hedera-mirror-node by hashgraph.
the class MirrorDateRangePropertiesProcessorTest method notSetAndDemoNetworkAndDatabaseNotEmpty.
@Test
void notSetAndDemoNetworkAndDatabaseNotEmpty() {
mirrorProperties.setNetwork(MirrorProperties.HederaNetwork.DEMO);
Instant past = STARTUP_TIME.minusSeconds(100);
doReturn(streamFile(StreamType.BALANCE, past)).when(accountBalanceFileRepository).findLatest();
doReturn(streamFile(StreamType.EVENT, past)).when(eventFileRepository).findLatest();
doReturn(streamFile(StreamType.RECORD, past)).when(recordFileRepository).findLatest();
for (var downloaderProperties : downloaderPropertiesList) {
StreamType streamType = downloaderProperties.getStreamType();
assertThat(mirrorDateRangePropertiesProcessor.getLastStreamFile(streamType)).matches(s -> matches(s, past));
assertThat(mirrorDateRangePropertiesProcessor.getDateRangeFilter(streamType)).isEqualTo(new DateRangeFilter(past, Utility.MAX_INSTANT_LONG));
}
assertThat(mirrorProperties.getVerifyHashAfter()).isEqualTo(Instant.EPOCH);
}
use of com.hedera.mirror.importer.config.MirrorDateRangePropertiesProcessor.DateRangeFilter in project hedera-mirror-node by hashgraph.
the class MirrorDateRangePropertiesProcessorTest method startDateNotAfterDatabase.
@ParameterizedTest(name = "startDate {0}ns before application status, endDate")
@ValueSource(longs = { 0, 1 })
void startDateNotAfterDatabase(long nanos) {
Instant past = STARTUP_TIME.minusSeconds(100);
mirrorProperties.setStartDate(past.minusNanos(nanos));
doReturn(streamFile(StreamType.BALANCE, past)).when(accountBalanceFileRepository).findLatest();
doReturn(streamFile(StreamType.EVENT, past)).when(eventFileRepository).findLatest();
doReturn(streamFile(StreamType.RECORD, past)).when(recordFileRepository).findLatest();
for (var downloaderProperties : downloaderPropertiesList) {
StreamType streamType = downloaderProperties.getStreamType();
assertThat(mirrorDateRangePropertiesProcessor.getLastStreamFile(streamType)).matches(s -> matches(s, past));
assertThat(mirrorDateRangePropertiesProcessor.getDateRangeFilter(streamType)).isEqualTo(new DateRangeFilter(past, null));
}
assertThat(mirrorProperties.getVerifyHashAfter()).isEqualTo(Instant.EPOCH);
}
use of com.hedera.mirror.importer.config.MirrorDateRangePropertiesProcessor.DateRangeFilter in project hedera-mirror-node by hashgraph.
the class MirrorDateRangePropertiesProcessorTest method notSetAndDatabaseNotEmpty.
@Test
void notSetAndDatabaseNotEmpty() {
Instant past = STARTUP_TIME.minusSeconds(100);
doReturn(streamFile(StreamType.BALANCE, past)).when(accountBalanceFileRepository).findLatest();
doReturn(streamFile(StreamType.EVENT, past)).when(eventFileRepository).findLatest();
doReturn(streamFile(StreamType.RECORD, past)).when(recordFileRepository).findLatest();
for (var downloaderProperties : downloaderPropertiesList) {
StreamType streamType = downloaderProperties.getStreamType();
assertThat(mirrorDateRangePropertiesProcessor.getLastStreamFile(streamType)).matches(s -> matches(s, past));
assertThat(mirrorDateRangePropertiesProcessor.getDateRangeFilter(streamType)).isEqualTo(new DateRangeFilter(past, Utility.MAX_INSTANT_LONG));
}
assertThat(mirrorProperties.getVerifyHashAfter()).isEqualTo(Instant.EPOCH);
}
use of com.hedera.mirror.importer.config.MirrorDateRangePropertiesProcessor.DateRangeFilter 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.importer.config.MirrorDateRangePropertiesProcessor.DateRangeFilter in project hedera-mirror-node by hashgraph.
the class MirrorDateRangePropertiesProcessorTest method emptyFilter.
@ParameterizedTest(name = "timestamp {0} does not pass empty filter")
@ValueSource(longs = { -10L, 0L, 1L, 10L, 8L, 100L })
void emptyFilter(long timestamp) {
DateRangeFilter filter = DateRangeFilter.empty();
assertThat(filter.filter(timestamp)).isFalse();
}
Aggregations