Search in sources :

Example 6 with DateRangeFilter

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);
}
Also used : StreamType(com.hedera.mirror.common.domain.StreamType) Instant(java.time.Instant) DateRangeFilter(com.hedera.mirror.importer.config.MirrorDateRangePropertiesProcessor.DateRangeFilter) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with DateRangeFilter

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);
}
Also used : StreamType(com.hedera.mirror.common.domain.StreamType) Instant(java.time.Instant) DateRangeFilter(com.hedera.mirror.importer.config.MirrorDateRangePropertiesProcessor.DateRangeFilter) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with DateRangeFilter

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);
}
Also used : StreamType(com.hedera.mirror.common.domain.StreamType) Instant(java.time.Instant) DateRangeFilter(com.hedera.mirror.importer.config.MirrorDateRangePropertiesProcessor.DateRangeFilter) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 9 with DateRangeFilter

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);
    }
}
Also used : StreamType(com.hedera.mirror.common.domain.StreamType) Instant(java.time.Instant) DateRangeFilter(com.hedera.mirror.importer.config.MirrorDateRangePropertiesProcessor.DateRangeFilter) StreamFile(com.hedera.mirror.common.domain.StreamFile) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 10 with DateRangeFilter

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();
}
Also used : DateRangeFilter(com.hedera.mirror.importer.config.MirrorDateRangePropertiesProcessor.DateRangeFilter) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

DateRangeFilter (com.hedera.mirror.importer.config.MirrorDateRangePropertiesProcessor.DateRangeFilter)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)11 StreamType (com.hedera.mirror.common.domain.StreamType)8 Instant (java.time.Instant)8 Test (org.junit.jupiter.api.Test)5 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)4 CsvSource (org.junit.jupiter.params.provider.CsvSource)3 ValueSource (org.junit.jupiter.params.provider.ValueSource)3 RecordFile (com.hedera.mirror.common.domain.transaction.RecordFile)2 StreamFile (com.hedera.mirror.common.domain.StreamFile)1 AccountBalance (com.hedera.mirror.common.domain.balance.AccountBalance)1 AccountBalanceFile (com.hedera.mirror.common.domain.balance.AccountBalanceFile)1 TokenBalance (com.hedera.mirror.common.domain.balance.TokenBalance)1 MirrorDateRangePropertiesProcessor (com.hedera.mirror.importer.config.MirrorDateRangePropertiesProcessor)1 FileOperationException (com.hedera.mirror.importer.exception.FileOperationException)1 Leader (com.hedera.mirror.importer.leader.Leader)1 AbstractStreamFileParser (com.hedera.mirror.importer.parser.AbstractStreamFileParser)1 BatchPersister (com.hedera.mirror.importer.parser.batch.BatchPersister)1 ValidatedDataInputStream (com.hedera.mirror.importer.reader.ValidatedDataInputStream)1 StreamFileRepository (com.hedera.mirror.importer.repository.StreamFileRepository)1