Skip to content

Commit a47eeb8

Browse files
committed
Expand genOperationalCertificateWithCounter to also test stake pool extended keys
1 parent 1f415a4 commit a47eeb8

File tree

1 file changed

+15
-6
lines changed
  • cardano-api/gen/Test/Gen/Cardano/Api

1 file changed

+15
-6
lines changed

cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,6 @@ import Hedgehog (Gen, MonadGen, Range)
196196
import qualified Hedgehog.Gen as Gen
197197
import qualified Hedgehog.Gen.QuickCheck as Q
198198
import qualified Hedgehog.Range as Range
199-
import Data.Bifunctor (first)
200-
201-
202199

203200
genAddressByron :: Gen (Address ByronAddr)
204201
genAddressByron =
@@ -573,18 +570,30 @@ genOperationalCertificateWithCounter
573570
genOperationalCertificateWithCounter = 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

Comments
 (0)