@@ -187,9 +187,6 @@ import Hedgehog (Gen, MonadGen, Range)
187187import qualified Hedgehog.Gen as Gen
188188import qualified Hedgehog.Gen.QuickCheck as Q
189189import qualified Hedgehog.Range as Range
190- import Data.Bifunctor (first )
191-
192-
193190
194191genAddressByron :: Gen (Address ByronAddr )
195192genAddressByron =
@@ -561,18 +558,30 @@ genOperationalCertificateWithCounter
561558genOperationalCertificateWithCounter = do
562559 kesVKey <- genVerificationKey AsKesKey
563560 stkPoolOrGenDelExtSign <-
564- Gen. either (genSigningKey AsStakePoolKey ) (genSigningKey AsGenesisDelegateExtendedKey )
561+ Gen. either (Gen. choice [ AnyStakePoolNormalSigningKey <$> genSigningKey AsStakePoolKey
562+ , AnyStakePoolExtendedSigningKey <$> genSigningKey AsStakePoolExtendedKey
563+ ])
564+ (genSigningKey AsGenesisDelegateExtendedKey )
565565 kesP <- genKESPeriod
566566 c <- Gen. integral $ Range. linear 0 1000
567- let stakePoolVer = either getVerificationKey (convert' . getVerificationKey) stkPoolOrGenDelExtSign
567+ let stakePoolVer = either castAnyStakePoolSigningKeyToNormalVerificationKey (convert' . getVerificationKey) stkPoolOrGenDelExtSign
568568 iCounter = OperationalCertificateIssueCounter c stakePoolVer
569569
570- case issueOperationalCertificate kesVKey (first AnyStakePoolNormalSigningKey stkPoolOrGenDelExtSign) kesP iCounter of
570+ case issueOperationalCertificate kesVKey stkPoolOrGenDelExtSign kesP iCounter of
571571 -- This case should be impossible as we clearly derive the verification
572572 -- key from the generated signing key.
573573 Left err -> error $ docToString $ prettyError err
574574 Right pair -> return pair
575575 where
576+ castAnyStakePoolSigningKeyToNormalVerificationKey
577+ :: AnyStakePoolSigningKey
578+ -> VerificationKey StakePoolKey
579+ castAnyStakePoolSigningKeyToNormalVerificationKey anyStakePoolSKey =
580+ case anyStakePoolSigningKeyToVerificationKey anyStakePoolSKey of
581+ AnyStakePoolNormalVerificationKey normalStakePoolVKey -> normalStakePoolVKey
582+ AnyStakePoolExtendedVerificationKey extendedStakePoolVKey ->
583+ castVerificationKey extendedStakePoolVKey
584+
576585 convert'
577586 :: VerificationKey GenesisDelegateExtendedKey
578587 -> VerificationKey StakePoolKey
0 commit comments