]> Git — Sourcephile - majurity.git/blob - hjugement-protocol/tests/QuickCheck/Trustee.hs
protocol: using ReaderT is not easier than Reifies
[majurity.git] / hjugement-protocol / tests / QuickCheck / Trustee.hs
1 {-# OPTIONS -fno-warn-orphans #-}
2 module QuickCheck.Trustee where
3
4 import Test.Tasty.QuickCheck
5
6 import Voting.Protocol
7
8 import Utils
9 import QuickCheck.Election ()
10
11 quickcheck :: TestTree
12 quickcheck =
13 testGroup "Trustee"
14 [ testGroup "verifyIndispensableTrusteePublicKey" $
15 [ testIndispensableTrusteePublicKey @WeakParams
16 , testIndispensableTrusteePublicKey @BeleniosParams
17 ]
18 ]
19
20 testIndispensableTrusteePublicKey :: forall q. Params q => TestTree
21 testIndispensableTrusteePublicKey =
22 testGroup (paramsName @q)
23 [ testProperty "Right" $ \seed ->
24 isRight $ runExcept $
25 (`evalStateT` mkStdGen seed) $ do
26 trusteeSecKey :: SecretKey q <- randomSecretKey
27 trusteePubKey <- proveIndispensableTrusteePublicKey trusteeSecKey
28 lift $ verifyIndispensableTrusteePublicKey trusteePubKey
29 ]
30
31 instance SubGroup q => Arbitrary (TrusteePublicKey q) where
32 arbitrary = do
33 trustee_PublicKey <- arbitrary
34 trustee_SecretKeyProof <- arbitrary
35 return TrusteePublicKey{..}