protocol: fix JSON error name
[majurity.git] / hjugement-protocol / tests / QuickCheck / Election.hs
index 07d4352e4d3752a93988cc8a03cce7cbd352eac8..9b039edb40f8edb8e9a4a70ed590b0cea4625c6c 100644 (file)
@@ -27,19 +27,19 @@ maxArbitraryQuestions = 2
 quickcheck :: Reifies v Version => Proxy v -> TestTree
 quickcheck v =
        testGroup "Election"
-        [ testGroup "verifyBallot" $
-                [ quickcheckElection v weakFFC
-                , quickcheckElection v beleniosFFC
+        [ testGroup "verifyBallot" $ 
+                [ reify weakFFC $ quickcheckElection v
+                , reify beleniosFFC $ quickcheckElection v
                 ]
         ]
 
 quickcheckElection ::
- ReifyCrypto crypto =>
Reifies v Version => Proxy v ->
- crypto -> TestTree
-quickcheckElection (_v::Proxy v) crypto =
-       reifyCrypto crypto $ \(Proxy::Proxy c) ->
-       testGroup (Text.unpack $ cryptoName crypto)
+ Reifies v Version => 
CryptoParams crypto c =>
+ Key crypto => JSON.ToJSON crypto => Show crypto =>
+ Proxy v -> Proxy c -> TestTree
+quickcheckElection (_v::Proxy v) (c::Proxy c) =
+       testGroup (Text.unpack $ cryptoName (reflect c))
         [ testProperty "verifyBallot" $ \(seed, (elec::Election crypto v c) :> votes) ->
                isRight $ runExcept $
                        (`evalStateT` mkStdGen seed) $ do
@@ -53,19 +53,11 @@ quickcheckElection (_v::Proxy v) crypto =
 instance Reifies c FFC => Arbitrary (F c) where
        arbitrary = F <$> choose (zero, fromJust $ fieldCharac @c `minusNaturalMaybe` one)
 -}
-instance
- ( Reifies c crypto
- , Group crypto
- , Multiplicative (G crypto c)
- , Invertible (G crypto c)
- ) => Arbitrary (G crypto c) where
+instance CryptoParams crypto c => Arbitrary (G crypto c) where
        arbitrary = do
                m <- arbitrary
                return (groupGen ^ m)
-instance
- ( Reifies c crypto
- , Group crypto
- ) => Arbitrary (E crypto c) where
+instance CryptoParams crypto c => Arbitrary (E crypto c) where
        arbitrary = E <$> choose (zero, fromJust $ groupOrder @crypto (Proxy @c) `minusNaturalMaybe` one)
 instance Arbitrary UUID where
        arbitrary = do
@@ -74,7 +66,7 @@ instance Arbitrary UUID where
                        randomUUID
 instance
  ( Reifies v Version
- , Reifies c crypto
+ , CryptoParams crypto c
  , Arbitrary (E crypto c)
  ) => Arbitrary (Proof crypto v c) where
        arbitrary = do
@@ -98,13 +90,9 @@ instance Reifies v Version => Arbitrary (Question v) where
                ]
 instance
  ( Reifies v Version
- , Reifies c crypto
- , Group crypto
+ , CryptoParams crypto c
  , Key crypto
- , Multiplicative (G crypto c)
- , Invertible (G crypto c)
  , JSON.ToJSON crypto
- , JSON.ToJSON (G crypto c)
  ) => Arbitrary (Election crypto v c) where
        arbitrary = do
                let election_name = "election"
@@ -150,13 +138,9 @@ instance Reifies v Version => Arbitrary (Question v :> [Bool]) where
                ]
 instance
  ( Reifies v Version
- , Reifies c crypto
- , Group crypto
+ , CryptoParams crypto c
  , Key crypto
  , JSON.ToJSON crypto
- , JSON.ToJSON (G crypto c)
- , Multiplicative (G crypto c)
- , Invertible (G crypto c)
  ) => Arbitrary (Election crypto v c :> [[Bool]]) where
        arbitrary = do
                elec@Election{..} <- arbitrary