package co.electriccoin.lightwallet.client.fixture import androidx.annotation.VisibleForTesting import co.electriccoin.lightwallet.client.model.BlockHeightUnsafe import co.electriccoin.lightwallet.client.model.CompactBlockUnsafe import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.asFlow /** * Used for getting mocked blocks list for processing and persisting compact blocks purposes. */ @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE) object ListOfCompactBlocksFixture { val DEFAULT_FILE_BLOCK_RANGE = FileBlockRangeFixture.new() @Suppress("MaxLineLength") fun newSequence(blocksHeightRange: ClosedRange = DEFAULT_FILE_BLOCK_RANGE): Sequence { val blocks = mutableListOf() for (blockHeight in blocksHeightRange.start.value..blocksHeightRange.endInclusive.value) { blocks.add( SingleCompactBlockFixture.new(height = blockHeight) ) } return blocks.asSequence() } @Suppress("MaxLineLength") fun newFlow(blocksHeightRange: ClosedRange = DEFAULT_FILE_BLOCK_RANGE): Flow { return newSequence(blocksHeightRange).asFlow() } }