diff --git a/factors/test/Main.hs b/factors/test/Main.hs index 1500ab3..7eff9cd 100644 --- a/factors/test/Main.hs +++ b/factors/test/Main.hs @@ -8,23 +8,20 @@ import Test.QuickCheck import ZK.Factors (Factors (..), Fr, factors) main :: IO () -main = do +main = hspec $ do let circuit = factorsCircuit $ factors @Fr vars = factorsVars $ factors @Fr - print circuit - print vars - hspec $ do - describe "Factors" $ do - it "should accept valid factors" $ do - property $ - \x y -> - let inputs = assignInputs vars $ Map.fromList [("n", x * y), ("a", x), ("b", y)] + describe "Factors" $ do + it "should accept valid factors" $ do + property $ + \x y -> + let inputs = assignInputs vars $ Map.fromList [("n", x * y), ("a", x), ("b", y)] + w = solve vars circuit inputs + in lookupVar vars "out" w === Just 1 + it "shouldn't accept invalid factors" $ do + property $ + \x y z -> + (x * y /= z) ==> + let inputs = assignInputs vars $ Map.fromList [("n", z), ("a", x), ("b", y)] w = solve vars circuit inputs - in lookupVar vars "out" w === Just 1 - it "shouldn't accept invalid factors" $ do - property $ - \x y z -> - (x * y /= z) ==> - let inputs = assignInputs vars $ Map.fromList [("n", z), ("a", x), ("b", y)] - w = solve vars circuit inputs - in lookupVar vars "out" w == Just 0 + in lookupVar vars "out" w == Just 0