@@ -196,9 +196,6 @@ import Hedgehog (Gen, MonadGen, Range)
196
196
import qualified Hedgehog.Gen as Gen
197
197
import qualified Hedgehog.Gen.QuickCheck as Q
198
198
import qualified Hedgehog.Range as Range
199
- import Data.Bifunctor (first )
200
-
201
-
202
199
203
200
genAddressByron :: Gen (Address ByronAddr )
204
201
genAddressByron =
@@ -573,18 +570,30 @@ genOperationalCertificateWithCounter
573
570
genOperationalCertificateWithCounter = do
574
571
kesVKey <- genVerificationKey AsKesKey
575
572
stkPoolOrGenDelExtSign <-
576
- Gen. either (genSigningKey AsStakePoolKey ) (genSigningKey AsGenesisDelegateExtendedKey )
573
+ Gen. either (Gen. choice [ AnyStakePoolNormalSigningKey <$> genSigningKey AsStakePoolKey
574
+ , AnyStakePoolExtendedSigningKey <$> genSigningKey AsStakePoolExtendedKey
575
+ ])
576
+ (genSigningKey AsGenesisDelegateExtendedKey )
577
577
kesP <- genKESPeriod
578
578
c <- Gen. integral $ Range. linear 0 1000
579
- let stakePoolVer = either getVerificationKey (convert' . getVerificationKey) stkPoolOrGenDelExtSign
579
+ let stakePoolVer = either castAnyStakePoolSigningKeyToNormalVerificationKey (convert' . getVerificationKey) stkPoolOrGenDelExtSign
580
580
iCounter = OperationalCertificateIssueCounter c stakePoolVer
581
581
582
- case issueOperationalCertificate kesVKey (first AnyStakePoolNormalSigningKey stkPoolOrGenDelExtSign) kesP iCounter of
582
+ case issueOperationalCertificate kesVKey stkPoolOrGenDelExtSign kesP iCounter of
583
583
-- This case should be impossible as we clearly derive the verification
584
584
-- key from the generated signing key.
585
585
Left err -> error $ docToString $ prettyError err
586
586
Right pair -> return pair
587
587
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
+
588
597
convert'
589
598
:: VerificationKey GenesisDelegateExtendedKey
590
599
-> VerificationKey StakePoolKey
0 commit comments