From bdfd89d936ccefaee744a7ce905ec917fb618e2c Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone <exarkun@twistedmatrix.com> Date: Wed, 31 May 2023 20:33:30 -0400 Subject: [PATCH] fix mutable share placement in the tests --- test/Spec.hs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/test/Spec.hs b/test/Spec.hs index 69fffcd..6104525 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -285,7 +285,7 @@ tests = (shares, cap) <- liftIO $ Tahoe.CHK.encode key params ciphertext -- Distribute the shares. - liftIO $ placeShares cap (Binary.encode <$> shares) perServerShareCount servers 0 + liftIO $ placeShares (storageIndex . verifier $ cap) (Binary.encode <$> shares) perServerShareCount servers 0 let serverMap = Map.fromList $ zip (Set.toList serverIDs') servers lookupServer = someServers serverMap @@ -330,7 +330,7 @@ tests = (shares, writeCap) <- liftIO $ SDMF.encode keypair sequenceNumber required total ciphertext let readCap = SDMF.writerReader writeCap -- Distribute the shares. - liftIO $ placeMutable writeCap (Binary.encode <$> shares) perServerShareCount servers 0 + liftIO $ placeShares (SDMF.Keys.unStorageIndex . SDMF.verifierStorageIndex . SDMF.readerVerifier . SDMF.writerReader $ writeCap) (Binary.encode <$> shares) perServerShareCount servers 0 let serverMap = Map.fromList $ zip (Set.toList serverIDs') servers lookupServer = someServers serverMap @@ -371,14 +371,11 @@ tests = -- Exactly match the nonsense makeAnn spits out parseURL = T.take 2 . T.drop 5 - placeMutable :: SDMF.Writer -> [BL.ByteString] -> [Int] -> [StorageServer] -> Int -> IO () - placeMutable = undefined - --- PHILOSOFY -- We wish that share numbers were an opaque type instead of a -- numeric/integral type. This is not the place to argue the point -- though. - placeShares :: Reader -> [BL.ByteString] -> [Int] -> [StorageServer] -> Int -> IO () + placeShares :: B.ByteString -> [BL.ByteString] -> [Int] -> [StorageServer] -> Int -> IO () -- Out of shares, done. placeShares _ [] _ _ _ = pure () -- Out of placement info but not out of shares is a programming error. @@ -386,14 +383,14 @@ tests = -- Out of servers but not out of shares is a programming error. placeShares _ _ _ [] _ = throwIO RanOutOfServers -- Having some of all three means we can make progress. - placeShares cap shares (n : ns) (s : ss) sharesSoFar = do + placeShares si shares (n : ns) (s : ss) sharesSoFar = do -- write the right number of shares to this server zipWithM_ - (\shnum share -> storageServerWrite s (storageIndex . verifier $ cap) shnum 0 share) + (\shnum share -> storageServerWrite s si shnum 0 share) [fromIntegral sharesSoFar ..] (BL.toStrict <$> take n shares) -- recurse to write the rest - placeShares cap (drop n shares) ns ss (sharesSoFar + n) + placeShares si (drop n shares) ns ss (sharesSoFar + n) -- Make up a distinct (but nonsense) announcement for a given storage -- server identifier. -- GitLab