Search in sources :

Example 1 with RecordFile

use of com.hedera.mirror.common.domain.transaction.RecordFile in project hedera-mirror-node by hashgraph.

the class SqlEntityListenerTest method completeFileAndCommit.

private void completeFileAndCommit() {
    RecordFile recordFile = domainBuilder.recordFile().persist();
    transactionTemplate.executeWithoutResult(status -> sqlEntityListener.onEnd(recordFile));
    assertThat(recordFileRepository.findAll()).contains(recordFile);
}
Also used : RecordFile(com.hedera.mirror.common.domain.transaction.RecordFile)

Example 2 with RecordFile

use of com.hedera.mirror.common.domain.transaction.RecordFile in project hedera-mirror-node by hashgraph.

the class PerformanceIntegrationTest method parse.

void parse() throws Exception {
    for (Resource resource : testFiles) {
        RecordFile recordFile = recordFileReader.read(StreamFileData.from(resource.getFile()));
        recordFileParser.parse(recordFile);
    }
}
Also used : RecordFile(com.hedera.mirror.common.domain.transaction.RecordFile) Resource(org.springframework.core.io.Resource)

Example 3 with RecordFile

use of com.hedera.mirror.common.domain.transaction.RecordFile in project hedera-mirror-node by hashgraph.

the class RecordFileParserIntegrationTest method before.

@BeforeEach
void before() {
    RecordFile recordFile1 = recordFile(recordFilePath1.toFile(), 0L);
    RecordFile recordFile2 = recordFile(recordFilePath2.toFile(), 1L);
    recordFileDescriptor1 = new RecordFileDescriptor(93, 8, recordFile1);
    recordFileDescriptor2 = new RecordFileDescriptor(75, 5, recordFile2);
}
Also used : RecordFile(com.hedera.mirror.common.domain.transaction.RecordFile) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with RecordFile

use of com.hedera.mirror.common.domain.transaction.RecordFile in project hedera-mirror-node by hashgraph.

the class RecordFileParserTest method endDate.

@ParameterizedTest(name = "endDate with offset {0}ns")
@CsvSource({ "-1", "0", "1" })
void endDate(long offset) {
    // given
    RecordFile recordFile = (RecordFile) getStreamFile();
    RecordItem firstItem = recordFile.getItems().blockFirst();
    long end = recordFile.getConsensusStart() + offset;
    DateRangeFilter filter = new DateRangeFilter(Instant.EPOCH, Instant.ofEpochSecond(0, end));
    doReturn(filter).when(mirrorDateRangePropertiesProcessor).getDateRangeFilter(parserProperties.getStreamType());
    // when
    parser.parse(recordFile);
    // then
    verify(recordStreamFileListener).onStart();
    if (offset >= 0) {
        verify(recordItemListener).onItem(firstItem);
    }
    verify(recordStreamFileListener).onEnd(recordFile);
    assertPostParseStreamFile(recordFile, true);
}
Also used : RecordFile(com.hedera.mirror.common.domain.transaction.RecordFile) DateRangeFilter(com.hedera.mirror.importer.config.MirrorDateRangePropertiesProcessor.DateRangeFilter) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with RecordFile

use of com.hedera.mirror.common.domain.transaction.RecordFile in project hedera-mirror-node by hashgraph.

the class RecordFileParserTest method startDate.

@ParameterizedTest(name = "startDate with offset {0}ns")
@CsvSource({ "-1", "0", "1" })
void startDate(long offset) {
    // given
    RecordFile recordFile = (RecordFile) getStreamFile();
    RecordItem firstItem = recordFile.getItems().blockFirst();
    long start = recordFile.getConsensusStart() + offset;
    DateRangeFilter filter = new DateRangeFilter(Instant.ofEpochSecond(0, start), null);
    doReturn(filter).when(mirrorDateRangePropertiesProcessor).getDateRangeFilter(parserProperties.getStreamType());
    // when
    parser.parse(recordFile);
    // then
    verify(recordStreamFileListener).onStart();
    if (offset < 0) {
        verify(recordItemListener).onItem(firstItem);
    }
    verify(recordStreamFileListener).onEnd(recordFile);
    assertPostParseStreamFile(recordFile, true);
}
Also used : RecordFile(com.hedera.mirror.common.domain.transaction.RecordFile) DateRangeFilter(com.hedera.mirror.importer.config.MirrorDateRangePropertiesProcessor.DateRangeFilter) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

RecordFile (com.hedera.mirror.common.domain.transaction.RecordFile)33 Test (org.junit.jupiter.api.Test)9 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)8 Instant (java.time.Instant)5 ByteString (com.google.protobuf.ByteString)4 IntegrationTest (com.hedera.mirror.importer.IntegrationTest)4 EntityId (com.hedera.mirror.common.domain.entity.EntityId)3 StreamFileData (com.hedera.mirror.importer.domain.StreamFileData)3 StreamFileReaderException (com.hedera.mirror.importer.exception.StreamFileReaderException)3 IOException (java.io.IOException)3 Path (java.nio.file.Path)3 ArrayList (java.util.ArrayList)3 Collectors (java.util.stream.Collectors)3 RequiredArgsConstructor (lombok.RequiredArgsConstructor)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 TestFactory (org.junit.jupiter.api.TestFactory)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 MirrorProperties (com.hedera.mirror.importer.MirrorProperties)2 PREVIEWNET (com.hedera.mirror.importer.MirrorProperties.HederaNetwork.PREVIEWNET)2 TESTNET (com.hedera.mirror.importer.MirrorProperties.HederaNetwork.TESTNET)2