11{-# LANGUAGE DataKinds #-}
2+ {-# LANGUAGE EmptyCase #-}
23{-# LANGUAGE FlexibleContexts #-}
34{-# LANGUAGE GADTs #-}
45{-# LANGUAGE NamedFieldPuns #-}
@@ -161,9 +162,14 @@ import Cardano.Api.Parser.Text qualified as P
161162import Cardano.Api.Tx qualified as A
162163
163164import Cardano.Binary qualified as CBOR
165+ import Cardano.Chain.UTxO qualified as Byron
166+ import Cardano.Crypto.DSIGN.Class qualified as Crypto
164167import Cardano.Crypto.Hash qualified as Crypto
165168import Cardano.Crypto.Hash.Class qualified as CRYPTO
169+ import Cardano.Crypto.Hashing qualified as ByronCrypto
170+ import Cardano.Crypto.ProtocolMagic qualified as Byron
166171import Cardano.Crypto.Seed qualified as Crypto
172+ import Cardano.Crypto.Signing qualified as Crypto
167173import Cardano.Ledger.Alonzo.Scripts qualified as Alonzo
168174import Cardano.Ledger.BaseTypes qualified as Ledger
169175import Cardano.Ledger.Core qualified as Ledger
@@ -181,6 +187,7 @@ import Data.Int (Int64)
181187import Data.Maybe
182188import Data.Ratio (Ratio , (%) )
183189import Data.String
190+ import Data.Text (Text )
184191import Data.Typeable
185192import Data.Word (Word16 , Word32 , Word64 )
186193import GHC.Exts (IsList (.. ))
@@ -192,7 +199,6 @@ import Test.Gen.Cardano.Api.Hardcoded
192199import Test.Gen.Cardano.Api.Metadata (genTxMetadata )
193200import Test.Gen.Cardano.Api.Orphans (obtainArbitraryConstraints )
194201
195- import Test.Cardano.Chain.UTxO.Gen (genVKWitness )
196202import Test.Cardano.Crypto.Gen (genProtocolMagicId )
197203
198204import Hedgehog (Gen , MonadGen , Range )
@@ -216,9 +222,6 @@ genAddressShelley =
216222genAddressInEra :: ShelleyBasedEra era -> Gen (AddressInEra era )
217223genAddressInEra sbe = shelleyAddressInEra sbe <$> genAddressShelley
218224
219- _genAddressInEraByron :: Gen (AddressInEra era )
220- _genAddressInEraByron = byronAddressInEra <$> genAddressByron
221-
222225genKESPeriod :: Gen KESPeriod
223226genKESPeriod = KESPeriod <$> Gen. word Range. constantBounded
224227
@@ -1185,6 +1188,47 @@ genVerificationKeyHash
11851188genVerificationKeyHash roletoken =
11861189 verificationKeyHash <$> genVerificationKey roletoken
11871190
1191+ genVKWitness :: Byron. ProtocolMagicId -> Gen Byron. TxInWitness
1192+ genVKWitness pm = Byron. VKWitness <$> genByronVerificationKey <*> genTxSig pm
1193+
1194+ genTxSig :: Byron. ProtocolMagicId -> Gen Byron. TxSig
1195+ genTxSig pm = Crypto. sign pm <$> genSignTag <*> genByronSigningKey <*> genTxSigData
1196+
1197+ genTxSigData :: Gen Byron. TxSigData
1198+ genTxSigData = Byron. TxSigData <$> genTxHash
1199+
1200+ genTxHash :: Gen (ByronCrypto. Hash Byron. Tx )
1201+ genTxHash = coerce <$> genTextHash
1202+
1203+ genTextHash :: Gen (ByronCrypto. Hash Text )
1204+ genTextHash = ByronCrypto. serializeCborHash <$> Gen. text (Range. linear 0 10 ) Gen. alphaNum
1205+
1206+ genSignTag :: Gen Crypto. SignTag
1207+ genSignTag =
1208+ Gen. choice
1209+ [ pure Crypto. SignForTestingOnly
1210+ , pure Crypto. SignTx
1211+ , pure Crypto. SignRedeemTx
1212+ , pure Crypto. SignVssCert
1213+ , pure Crypto. SignUSProposal
1214+ , pure Crypto. SignCommitment
1215+ , pure Crypto. SignUSVote
1216+ , Crypto. SignBlock <$> genByronVerificationKey
1217+ , pure Crypto. SignCertificate
1218+ ]
1219+
1220+ genByronVerificationKey :: Gen Crypto. VerificationKey
1221+ genByronVerificationKey = fst <$> genKeypair
1222+
1223+ genByronSigningKey :: Gen Crypto. SigningKey
1224+ genByronSigningKey = snd <$> genKeypair
1225+
1226+ genKeypair :: Gen (Crypto. VerificationKey , Crypto. SigningKey )
1227+ genKeypair = Crypto. deterministicKeyGen <$> gen32Bytes
1228+
1229+ gen32Bytes :: Gen ByteString
1230+ gen32Bytes = Gen. bytes (Range. singleton 32 )
1231+
11881232genByronKeyWitness :: Gen (KeyWitness ByronEra )
11891233genByronKeyWitness = do
11901234 pmId <- genProtocolMagicId
@@ -1599,12 +1643,18 @@ genAnyPlutusScriptVersion = do
15991643
16001644plutusScriptLangaugeInEra
16011645 :: Exp. Era era -> PlutusScriptVersion lang -> ScriptLanguageInEra lang era
1646+ plutusScriptLangaugeInEra Exp. DijkstraEra l =
1647+ case l of
1648+ PlutusScriptV1 -> PlutusScriptV1InDijkstra
1649+ PlutusScriptV2 -> PlutusScriptV2InDijkstra
1650+ PlutusScriptV3 -> PlutusScriptV3InDijkstra
1651+ PlutusScriptV4 -> PlutusScriptV4InDijkstra
16021652plutusScriptLangaugeInEra Exp. ConwayEra l =
16031653 case l of
16041654 PlutusScriptV1 -> PlutusScriptV1InConway
16051655 PlutusScriptV2 -> PlutusScriptV2InConway
16061656 PlutusScriptV3 -> PlutusScriptV3InConway
1607- PlutusScriptV4 -> error " plutusScriptLangaugeInEra: PlutusScriptV4 not supported yet "
1657+ PlutusScriptV4 -> case undefined :: ScriptLanguageInEra PlutusScriptV4 ConwayEra of {}
16081658
16091659genApiPlutusScriptWitness
16101660 :: WitCtx witctx -> Exp. Era era -> Gen (Api. ScriptWitness witctx era )
0 commit comments