Skip to content

Commit 6c49e83

Browse files
committed
Move Arbitrary instances to cardano-crypto-class
1 parent 06d7192 commit 6c49e83

File tree

3 files changed

+2
-37
lines changed

3 files changed

+2
-37
lines changed

libs/cardano-ledger-binary/cardano-ledger-binary.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ test-suite tests
174174
QuickCheck,
175175
base,
176176
bytestring,
177-
cardano-crypto-class,
177+
cardano-crypto-class:{cardano-crypto-class, testlib},
178178
cardano-crypto-praos,
179179
cardano-ledger-binary,
180180
cardano-prelude-test,

libs/cardano-ledger-binary/test/Test/Cardano/Ledger/Binary/RoundTripSpec.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ import Numeric.Natural
7777
import Test.Cardano.Ledger.Binary.Arbitrary ()
7878
import Test.Cardano.Ledger.Binary.RoundTrip
7979
import Test.Cardano.StrictContainers.Instances ()
80+
import Test.Crypto.Instances ()
8081
import Test.Hspec
8182
import Test.QuickCheck
8283

libs/cardano-ledger-binary/testlib/Test/Cardano/Ledger/Binary/Arbitrary.hs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
{-# LANGUAGE CPP #-}
22
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
3-
{-# LANGUAGE LambdaCase #-}
43
{-# LANGUAGE MultiParamTypeClasses #-}
54
{-# LANGUAGE ScopedTypeVariables #-}
65
{-# LANGUAGE StandaloneDeriving #-}
7-
{-# LANGUAGE TypeApplications #-}
86
{-# LANGUAGE TypeFamilies #-}
9-
{-# LANGUAGE TypeOperators #-}
107
{-# OPTIONS_GHC -Wno-orphans #-}
118

129
module Test.Cardano.Ledger.Binary.Arbitrary (
@@ -17,9 +14,6 @@ module Test.Cardano.Ledger.Binary.Arbitrary (
1714
genShortByteString,
1815
) where
1916

20-
import Cardano.Crypto.DSIGN.Class hiding (Signable)
21-
import Cardano.Crypto.Util
22-
import Cardano.Crypto.VRF.Class
2317
import Cardano.Ledger.Binary.Version
2418
import Codec.CBOR.ByteArray (ByteArray (..))
2519
import Codec.CBOR.ByteArray.Sliced (SlicedByteArray (..))
@@ -148,36 +142,6 @@ instance
148142
arbitrary = VMap.fromMap <$> arbitrary
149143
shrink = fmap VMap.fromList . shrink . VMap.toList
150144

151-
instance DSIGNAlgorithm v => Arbitrary (VerKeyDSIGN v) where
152-
arbitrary = deriveVerKeyDSIGN <$> arbitrary
153-
154-
errorInvalidSize :: HasCallStack => Int -> Maybe a -> Gen a
155-
errorInvalidSize n = maybe (error $ "Impossible: Invalid size " ++ show n) pure
156-
157-
instance DSIGNAlgorithm v => Arbitrary (SignKeyDSIGN v) where
158-
arbitrary = do
159-
let n = fromIntegral (signKeySizeDSIGN (Proxy @v))
160-
bs <- genByteString n
161-
errorInvalidSize n $ rawDeserialiseSignKeyDSIGN bs
162-
163-
instance DSIGNAlgorithm v => Arbitrary (SigDSIGN v) where
164-
arbitrary = do
165-
let n = fromIntegral (sigSizeDSIGN (Proxy @v))
166-
bs <- genByteString n
167-
errorInvalidSize n $ rawDeserialiseSigDSIGN bs
168-
169-
instance DSIGNAlgorithm v => Arbitrary (SignedDSIGN v a) where
170-
arbitrary = SignedDSIGN <$> arbitrary
171-
172-
instance
173-
(ContextVRF v ~ (), Signable v ~ SignableRepresentation, VRFAlgorithm v) =>
174-
Arbitrary (CertifiedVRF v a)
175-
where
176-
arbitrary = CertifiedVRF <$> arbitrary <*> genCertVRF
177-
where
178-
genCertVRF :: Gen (CertVRF v)
179-
genCertVRF = arbitrary
180-
181145
instance Arbitrary Version where
182146
arbitrary = genVersion minBound maxBound
183147

0 commit comments

Comments
 (0)