]> Git — Sourcephile - majurity.git/blob - hjugement-protocol/tests/QuickCheck/Trustee.hs
protocol: add Trustee.Indispensable
[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 import Voting.Protocol.Trustee.Indispensable
8
9 import Utils
10 import QuickCheck.Election ()
11
12 quickcheck :: TestTree
13 quickcheck =
14 testGroup "Trustee"
15 [ testGroup "verifyIndispensableTrusteePublicKey" $
16 [ testIndispensableTrusteePublicKey @WeakParams
17 , testIndispensableTrusteePublicKey @BeleniosParams
18 ]
19 ]
20
21 testIndispensableTrusteePublicKey :: forall q. Params q => TestTree
22 testIndispensableTrusteePublicKey =
23 testGroup (paramsName @q)
24 [ testProperty "Right" $ \seed ->
25 isRight $ runExcept $
26 (`evalStateT` mkStdGen seed) $ do
27 trusteeSecKey :: SecretKey q <- randomSecretKey
28 trusteePubKey <- proveIndispensableTrusteePublicKey trusteeSecKey
29 lift $ verifyIndispensableTrusteePublicKey trusteePubKey
30 ]
31
32 instance SubGroup q => Arbitrary (TrusteePublicKey q) where
33 arbitrary = do
34 trustee_PublicKey <- arbitrary
35 trustee_SecretKeyProof <- arbitrary
36 return TrusteePublicKey{..}