From 8e50729a926d70b100ef3fd7f9155ea7f1af5a5e Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone <exarkun@twistedmatrix.com> Date: Wed, 10 May 2023 12:44:05 -0400 Subject: [PATCH] Some nice comments --- test/Spec.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/Spec.hs b/test/Spec.hs index c41d9d3..98914dd 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -32,6 +32,9 @@ tests = mapM_ knownCorrectRoundTrip [0 :: Int .. 9] ] +{- | Load a known-correct SDMF bucket and assert that bytes in the slot it + contains deserializes to a Share and then serializes back to the same bytes +-} knownCorrectRoundTrip :: Show a => a -> IO () knownCorrectRoundTrip n = do -- The files are in "bucket" format. We need to extract the @@ -51,6 +54,7 @@ knownCorrectRoundTrip n = do let encoded = (Binary.encode :: Share -> LB.ByteString) <$> decoded assertEqual "original /= encoded" (Right shareData) encoded +-- | Like `Binary.Binary.decodeOrFail` but only return the decoded value. decode' :: Binary.Binary b => LB.ByteString -> Either (LB.ByteString, ByteOffset, String) b decode' = ((\(_, _, a) -> a) <$>) . Binary.decodeOrFail -- GitLab