Search in sources :

Example 41 with StreamFileData

use of com.hedera.mirror.importer.domain.StreamFileData in project hedera-mirror-node by hashgraph.

the class EventFileReaderV3Test method readInvalidFileWithInvalidPrevHashMarker.

@Test
void readInvalidFileWithInvalidPrevHashMarker() {
    StreamFileData invalidFile = createEventFile(EventFileReaderV3.EVENT_STREAM_FILE_VERSION_3, (byte) 0x0, PREVIOUS_HASH, CONTENT);
    assertThrows(InvalidEventFileException.class, () -> eventFileReader.read(invalidFile));
}
Also used : StreamFileData(com.hedera.mirror.importer.domain.StreamFileData) Test(org.junit.jupiter.api.Test)

Example 42 with StreamFileData

use of com.hedera.mirror.importer.domain.StreamFileData in project hedera-mirror-node by hashgraph.

the class EventFileReaderV3Test method readInvalidFileWithInvalidVersion4.

@Test
void readInvalidFileWithInvalidVersion4() {
    StreamFileData invalidFile = createEventFile(4, EventFileReaderV3.EVENT_TYPE_PREV_HASH, PREVIOUS_HASH, CONTENT);
    assertThrows(InvalidEventFileException.class, () -> eventFileReader.read(invalidFile));
}
Also used : StreamFileData(com.hedera.mirror.importer.domain.StreamFileData) Test(org.junit.jupiter.api.Test)

Example 43 with StreamFileData

use of com.hedera.mirror.importer.domain.StreamFileData in project hedera-mirror-node by hashgraph.

the class EventFileReaderV3Test method readInvalidFileWithInvalidVersion1.

@Test
void readInvalidFileWithInvalidVersion1() {
    StreamFileData invalidFile = createEventFile(1, EventFileReaderV3.EVENT_TYPE_PREV_HASH, PREVIOUS_HASH, CONTENT);
    assertThrows(InvalidEventFileException.class, () -> eventFileReader.read(invalidFile));
}
Also used : StreamFileData(com.hedera.mirror.importer.domain.StreamFileData) Test(org.junit.jupiter.api.Test)

Example 44 with StreamFileData

use of com.hedera.mirror.importer.domain.StreamFileData in project hedera-mirror-node by hashgraph.

the class AbstractRecordFileReaderTest method readIncompatibleFile.

@TestFactory
Stream<DynamicTest> readIncompatibleFile() {
    String template = "read incompatible version %d file %s";
    return DynamicTest.stream(getFilteredFiles(true), (recordFile) -> String.format(template, recordFile.getVersion(), recordFile.getName()), (recordFile) -> {
        // given
        Path testFile = getTestFile(recordFile);
        StreamFileData streamFileData = StreamFileData.from(testFile.toFile());
        // when
        assertThrows(InvalidStreamFileException.class, () -> recordFileReader.read(streamFileData));
    });
}
Also used : Path(java.nio.file.Path) StreamFileData(com.hedera.mirror.importer.domain.StreamFileData) TestFactory(org.junit.jupiter.api.TestFactory)

Example 45 with StreamFileData

use of com.hedera.mirror.importer.domain.StreamFileData in project hedera-mirror-node by hashgraph.

the class RecordFileReaderImplV5Test method verifyRecordItemLinksInEthTransactionValidFile.

@SneakyThrows
@TestFactory
Stream<DynamicTest> verifyRecordItemLinksInEthTransactionValidFile() {
    String template = "read file %s containing eth transactions";
    var resourceResolver = new PathMatchingResourcePatternResolver();
    return DynamicTest.stream(Arrays.stream(resourceResolver.getResources("classpath:data/recordstreams/eth-0.26.0/record0.0.3/*" + ".rcd")), (recordFile) -> String.format(template, recordFile.getFilename()), (recordFile) -> {
        // given
        StreamFileData streamFileData = StreamFileData.from(recordFile.getFile());
        // when
        RecordFile actual = recordFileReader.read(streamFileData);
        // then
        RecordItem previousItem = null;
        RecordItem lastParentItem = null;
        for (var item : actual.getItems().collectList().block()) {
            // assert previous link points to previous item
            assertThat(item.getPrevious()).isEqualTo(previousItem);
            // confirm if child that parent is populated
            if (item.isChild()) {
                assertThat(item.getParent()).isEqualTo(lastParentItem);
            } else {
                lastParentItem = item;
            }
            previousItem = item;
        }
    });
}
Also used : RecordFile(com.hedera.mirror.common.domain.transaction.RecordFile) StreamFileData(com.hedera.mirror.importer.domain.StreamFileData) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) TestFactory(org.junit.jupiter.api.TestFactory) SneakyThrows(lombok.SneakyThrows)

Aggregations

StreamFileData (com.hedera.mirror.importer.domain.StreamFileData)51 Test (org.junit.jupiter.api.Test)40 AccountBalanceFile (com.hedera.mirror.common.domain.balance.AccountBalanceFile)8 Path (java.nio.file.Path)6 TestFactory (org.junit.jupiter.api.TestFactory)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 FileStreamSignature (com.hedera.mirror.importer.domain.FileStreamSignature)4 AllAccountBalances (com.hedera.services.stream.proto.AllAccountBalances)4 UnknownFieldSet (com.google.protobuf.UnknownFieldSet)3 RecordFile (com.hedera.mirror.common.domain.transaction.RecordFile)3 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)3 InvalidStreamFileException (com.hedera.mirror.importer.exception.InvalidStreamFileException)3 Instant (java.time.Instant)3 ValueSource (org.junit.jupiter.params.provider.ValueSource)3 AccountBalance (com.hedera.mirror.common.domain.balance.AccountBalance)2 TokenBalance (com.hedera.mirror.common.domain.balance.TokenBalance)2 EntityId (com.hedera.mirror.common.domain.entity.EntityId)2 EventFile (com.hedera.mirror.common.domain.event.EventFile)2 DomainUtils (com.hedera.mirror.common.util.DomainUtils)2 StreamFilename (com.hedera.mirror.importer.domain.StreamFilename)2