@@ -187,9 +187,6 @@ import Hedgehog (Gen, MonadGen, Range)
187
187
import qualified Hedgehog.Gen as Gen
188
188
import qualified Hedgehog.Gen.QuickCheck as Q
189
189
import qualified Hedgehog.Range as Range
190
- import Data.Bifunctor (first )
191
-
192
-
193
190
194
191
genAddressByron :: Gen (Address ByronAddr )
195
192
genAddressByron =
@@ -561,18 +558,30 @@ genOperationalCertificateWithCounter
561
558
genOperationalCertificateWithCounter = do
562
559
kesVKey <- genVerificationKey AsKesKey
563
560
stkPoolOrGenDelExtSign <-
564
- Gen. either (genSigningKey AsStakePoolKey ) (genSigningKey AsGenesisDelegateExtendedKey )
561
+ Gen. either (Gen. choice [ AnyStakePoolNormalSigningKey <$> genSigningKey AsStakePoolKey
562
+ , AnyStakePoolExtendedSigningKey <$> genSigningKey AsStakePoolExtendedKey
563
+ ])
564
+ (genSigningKey AsGenesisDelegateExtendedKey )
565
565
kesP <- genKESPeriod
566
566
c <- Gen. integral $ Range. linear 0 1000
567
- let stakePoolVer = either getVerificationKey (convert' . getVerificationKey) stkPoolOrGenDelExtSign
567
+ let stakePoolVer = either castAnyStakePoolSigningKeyToNormalVerificationKey (convert' . getVerificationKey) stkPoolOrGenDelExtSign
568
568
iCounter = OperationalCertificateIssueCounter c stakePoolVer
569
569
570
- case issueOperationalCertificate kesVKey (first AnyStakePoolNormalSigningKey stkPoolOrGenDelExtSign) kesP iCounter of
570
+ case issueOperationalCertificate kesVKey stkPoolOrGenDelExtSign kesP iCounter of
571
571
-- This case should be impossible as we clearly derive the verification
572
572
-- key from the generated signing key.
573
573
Left err -> error $ docToString $ prettyError err
574
574
Right pair -> return pair
575
575
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
+
576
585
convert'
577
586
:: VerificationKey GenesisDelegateExtendedKey
578
587
-> VerificationKey StakePoolKey
0 commit comments