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