@@ -318,16 +318,28 @@ builderSh = "declare -xpexport > $out"
318318spec :: Spec
319319spec = do
320320 describe " Remote store protocol" $ do
321- describe " Direct" $ makeProtoSpec withNixDaemon
322- describe " MITM" $ makeProtoSpec withManInTheMiddleNixDaemon
321+ describe " Direct"
322+ $ makeProtoSpec
323+ withNixDaemon
324+ SpecFlavor_Direct
325+ describe " MITM"
326+ $ makeProtoSpec
327+ withManInTheMiddleNixDaemon
328+ SpecFlavor_MITM
329+
330+ data SpecFlavor
331+ = SpecFlavor_Direct
332+ | SpecFlavor_MITM
333+ deriving (Eq , Ord , Show )
323334
324335makeProtoSpec
325336 :: (ActionWith
326337 (RemoteStoreT IO () -> Run IO () )
327338 -> IO ()
328339 )
340+ -> SpecFlavor
329341 -> Spec
330- makeProtoSpec f = around f $ do
342+ makeProtoSpec f flavor = around f $ do
331343 context " syncWithGC" $
332344 itRights " syncs with garbage collector" syncWithGC
333345
@@ -394,11 +406,24 @@ makeProtoSpec f = around f $ do
394406 buildPaths (toDerivedPathSet path) BuildMode_Repair
395407
396408 context " roots" $ context " findRoots" $ do
397- itRights " empty roots" (findRoots `shouldReturn` mempty )
398-
399- itRights " path added as a temp root" $ withPath $ \ _ -> do
400- roots <- findRoots
401- roots `shouldSatisfy` ((== 1 ) . Data.Map. size)
409+ itRights " empty roots" (findRoots `shouldReturn` mempty )
410+
411+ itRights " path added as a temp root" $ withPath $ \ _ -> do
412+ let expectRoots =
413+ if flavor == SpecFlavor_MITM
414+ then 0 -- nested client closes its connection so temp root gets removed
415+ else 1
416+ roots <- findRoots
417+ roots `shouldSatisfy` ((== expectRoots) . Data.Map. size)
418+
419+ itRights " indirect root" $ withPath $ \ path -> do
420+ let expectRoots =
421+ if flavor == SpecFlavor_MITM
422+ then 1 -- nested client closes its connection so temp root gets removed
423+ else 2
424+ addIndirectRoot path
425+ roots <- findRoots
426+ roots `shouldSatisfy` ((== expectRoots) . Data.Map. size)
402427
403428 context " optimiseStore" $ itRights " optimises" optimiseStore
404429
0 commit comments