Skip to content

Commit

Permalink
Test strictly smaller sub lists and classify results
Browse files Browse the repository at this point in the history
sublistOf is also sometimes yielding the same list, so we discard same
length prefixes. Also, classifying empty lists helps in ensuring we have
actually non trivial cases.
  • Loading branch information
ch1bo committed Jul 11, 2023
1 parent ffa4c9e commit fbaa3eb
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions hydra-node/test/Hydra/CryptoSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import qualified Data.Map as Map
import Hydra.Party (Party (vkey), deriveParty)
import Test.Aeson.GenericSpecs (roundtripAndGoldenSpecs)
import Test.QuickCheck (
classify,
counterexample,
elements,
forAll,
Expand Down Expand Up @@ -104,11 +105,11 @@ specMultiSignature =
=/= Verified

prop "does not validate multisig if less keys given" $ \sks (msg :: ByteString) -> do
(length sks > 1)
==> forAll (sublistOf sks)
$ \prefix ->
let sigs = aggregate $ map (`sign` msg) (toList sks)
in verifyMultiSignature (map getVerificationKey prefix) sigs msg
=/= Verified
& counterexample ("Keys: " <> show prefix)
& counterexample ("Signature: " <> show sigs)
forAll (sublistOf sks) $ \prefix ->
(length prefix < length sks)
==> let sigs = aggregate $ map (`sign` msg) (toList sks)
in verifyMultiSignature (map getVerificationKey prefix) sigs msg
=/= Verified
& classify (null prefix) "empty"
& counterexample ("Keys: " <> show prefix)
& counterexample ("Signature: " <> show sigs)

0 comments on commit fbaa3eb

Please sign in to comment.