]> git.immae.eu Git - github/fretlink/hmacaroons.git/blobdiff - test/Crypto/Macaroon/Serializer/Base64/Tests.hs
Add quickchecked serialization properties
[github/fretlink/hmacaroons.git] / test / Crypto / Macaroon / Serializer / Base64 / Tests.hs
index 9c49e9677ac8ece0a01e4722526c8a15635bc8e3..fe5352e85053e1d445f48de7f2032ca8b35b6966 100644 (file)
@@ -15,17 +15,23 @@ module Crypto.Macaroon.Serializer.Base64.Tests where
 import qualified Data.ByteString.Char8 as B8
 import Test.Tasty
 import Test.Tasty.HUnit
+import           Test.Tasty.QuickCheck
 
 import           Crypto.Macaroon
 import           Crypto.Macaroon.Serializer.Base64
 
+import Crypto.Macaroon.Instances
+
 tests :: TestTree
 tests = testGroup "Crypto.Macaroon.Serializer.Base64" [ basic
+                                                      , basicQC
                                                       , minted
                                                       , minted2
                                                       -- , minted3
                                                       ]
 
+basicQC = testProperty "Reversibility" $
+    forAll (macaroon <$> arbitrary) (\m -> deserialize (serialize m) == Right m)
 
 m :: Macaroon
 m = create secret key loc