diff options
| author | Dan Engelbrecht <[email protected]> | 2026-03-16 14:27:26 +0100 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2026-03-16 14:27:26 +0100 |
| commit | 7b32b6756d2e42a05ddb9b94494f0eccf8cca15f (patch) | |
| tree | c045771f417c7c04ca098ad9e2401d6640c63021 /src/zenremotestore/projectstore/remoteprojectstore.cpp | |
| parent | comment cleanup (diff) | |
| download | zen-de/loadoplog-refactor.tar.xz zen-de/loadoplog-refactor.zip | |
added one more testde/loadoplog-refactor
Diffstat (limited to 'src/zenremotestore/projectstore/remoteprojectstore.cpp')
| -rw-r--r-- | src/zenremotestore/projectstore/remoteprojectstore.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/zenremotestore/projectstore/remoteprojectstore.cpp b/src/zenremotestore/projectstore/remoteprojectstore.cpp index 6bce132c3..8ba2397ff 100644 --- a/src/zenremotestore/projectstore/remoteprojectstore.cpp +++ b/src/zenremotestore/projectstore/remoteprojectstore.cpp @@ -7285,6 +7285,43 @@ TEST_CASE("buildcontainer.context_progress_reporting") CHECK(!Ctx.ProgressMessages.empty()); } +TEST_CASE("getblocksfromoplog.filtered") +{ + // GetBlocksFromOplog(ContainerObject, IncludeBlockHashes) returns only the requested blocks. + using namespace projectstore_testutils; + + ScopedTemporaryDirectory TempDir; + ScopedTemporaryDirectory ExportDir; + + GcManager Gc; + CidStore CidStore(Gc); + std::unique_ptr<ProjectStore> ProjectStoreDummy; + Ref<ProjectStore::Project> Project = MakeTestProject(CidStore, Gc, TempDir.Path(), ProjectStoreDummy); + + TestWorkerPools Pools; + WorkerThreadPool& NetworkPool = Pools.NetworkPool; + WorkerThreadPool& WorkerPool = Pools.WorkerPool; + + std::shared_ptr<RemoteProjectStore> RemoteStore = SetupExportStore(CidStore, *Project, NetworkPool, WorkerPool, ExportDir.Path()); + + RemoteProjectStore::LoadContainerResult ContainerResult = RemoteStore->LoadContainer(); + REQUIRE(ContainerResult.ErrorCode == 0); + + std::vector<IoHash> AllBlockHashes = GetBlockHashesFromOplog(ContainerResult.ContainerObject); + REQUIRE(!AllBlockHashes.empty()); + + // Filter to the first block only. + std::vector<IoHash> Subset = {AllBlockHashes[0]}; + std::vector<ThinChunkBlockDescription> Filtered = GetBlocksFromOplog(ContainerResult.ContainerObject, Subset); + CHECK(Filtered.size() == 1); + CHECK(Filtered[0].BlockHash == AllBlockHashes[0]); + CHECK(!Filtered[0].ChunkRawHashes.empty()); + + // Empty include set returns empty result (exercises the no-match branch). + std::vector<ThinChunkBlockDescription> Empty = GetBlocksFromOplog(ContainerResult.ContainerObject, std::span<const IoHash>{}); + CHECK(Empty.empty()); +} + // --------------------------------------------------------------------------- // SaveOplog-focused tests // --------------------------------------------------------------------------- |