Skip to content

Commit 7e83e51

Browse files
committed
Expand genOperationalCertificateWithCounter to also test stake pool extended keys
1 parent 1835032 commit 7e83e51

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
@@ -187,9 +187,6 @@ import Hedgehog (Gen, MonadGen, Range)
187187
import qualified Hedgehog.Gen as Gen
188188
import qualified Hedgehog.Gen.QuickCheck as Q
189189
import qualified Hedgehog.Range as Range
190-
import Data.Bifunctor (first)
191-
192-
193190

194191
genAddressByron :: Gen (Address ByronAddr)
195192
genAddressByron =
@@ -561,18 +558,30 @@ genOperationalCertificateWithCounter
561558
genOperationalCertificateWithCounter = 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

Comments
 (0)