]> Git — Sourcephile - majurity.git/blob - hjugement-protocol/tests/QuickCheck/Trustee.hs
protocol: change: bump cabal version
[majurity.git] / hjugement-protocol / tests / QuickCheck / Trustee.hs
1 {-# OPTIONS -fno-warn-orphans #-}
2 {-# LANGUAGE UndecidableInstances #-} -- for Reifies instances
3 module QuickCheck.Trustee where
4
5 import Test.Tasty.QuickCheck
6 import qualified Data.Text as Text
7
8 import Voting.Protocol
9
10 import Utils
11 import QuickCheck.Election ()
12
13 quickcheck :: TestTree
14 quickcheck =
15 testGroup "Trustee"
16 [ testGroup "verifyIndispensableTrusteePublicKey" $
17 [ testIndispensableTrusteePublicKey weakFFC
18 , testIndispensableTrusteePublicKey beleniosFFC
19 ]
20 ]
21
22 testIndispensableTrusteePublicKey :: FFC -> TestTree
23 testIndispensableTrusteePublicKey ffc =
24 reify ffc $ \(Proxy::Proxy c) ->
25 testGroup (Text.unpack $ ffc_name ffc)
26 [ testProperty "Right" $ \seed ->
27 isRight $ runExcept $
28 (`evalStateT` mkStdGen seed) $ do
29 trusteeSecKey :: SecretKey c <- randomSecretKey
30 trusteePubKey <- proveIndispensableTrusteePublicKey trusteeSecKey
31 lift $ verifyIndispensableTrusteePublicKey trusteePubKey
32 ]
33
34 instance Reifies c FFC => Arbitrary (TrusteePublicKey c) where
35 arbitrary = do
36 trustee_PublicKey <- arbitrary
37 trustee_SecretKeyProof <- arbitrary
38 return TrusteePublicKey{..}