@@ -196,9 +196,6 @@ import Hedgehog (Gen, MonadGen, Range)
196196import qualified Hedgehog.Gen as Gen
197197import qualified Hedgehog.Gen.QuickCheck as Q
198198import qualified Hedgehog.Range as Range
199- import Data.Bifunctor (first )
200-
201-
202199
203200genAddressByron :: Gen (Address ByronAddr )
204201genAddressByron =
@@ -573,18 +570,30 @@ genOperationalCertificateWithCounter
573570genOperationalCertificateWithCounter = do
574571 kesVKey <- genVerificationKey AsKesKey
575572 stkPoolOrGenDelExtSign <-
576- Gen. either (genSigningKey AsStakePoolKey ) (genSigningKey AsGenesisDelegateExtendedKey )
573+ Gen. either (Gen. choice [ AnyStakePoolNormalSigningKey <$> genSigningKey AsStakePoolKey
574+ , AnyStakePoolExtendedSigningKey <$> genSigningKey AsStakePoolExtendedKey
575+ ])
576+ (genSigningKey AsGenesisDelegateExtendedKey )
577577 kesP <- genKESPeriod
578578 c <- Gen. integral $ Range. linear 0 1000
579- let stakePoolVer = either getVerificationKey (convert' . getVerificationKey) stkPoolOrGenDelExtSign
579+ let stakePoolVer = either castAnyStakePoolSigningKeyToNormalVerificationKey (convert' . getVerificationKey) stkPoolOrGenDelExtSign
580580 iCounter = OperationalCertificateIssueCounter c stakePoolVer
581581
582- case issueOperationalCertificate kesVKey (first AnyStakePoolNormalSigningKey stkPoolOrGenDelExtSign) kesP iCounter of
582+ case issueOperationalCertificate kesVKey stkPoolOrGenDelExtSign kesP iCounter of
583583 -- This case should be impossible as we clearly derive the verification
584584 -- key from the generated signing key.
585585 Left err -> error $ docToString $ prettyError err
586586 Right pair -> return pair
587587 where
588+ castAnyStakePoolSigningKeyToNormalVerificationKey
589+ :: AnyStakePoolSigningKey
590+ -> VerificationKey StakePoolKey
591+ castAnyStakePoolSigningKeyToNormalVerificationKey anyStakePoolSKey =
592+ case anyStakePoolSigningKeyToVerificationKey anyStakePoolSKey of
593+ AnyStakePoolNormalVerificationKey normalStakePoolVKey -> normalStakePoolVKey
594+ AnyStakePoolExtendedVerificationKey extendedStakePoolVKey ->
595+ castVerificationKey extendedStakePoolVKey
596+
588597 convert'
589598 :: VerificationKey GenesisDelegateExtendedKey
590599 -> VerificationKey StakePoolKey
0 commit comments