Skip to content

Commit 21ab8a5

Browse files
committed
Use StandardCrypto on block generation in Cardano and Shelley
1 parent 9fc4022 commit 21ab8a5

File tree

2 files changed

+25
-27
lines changed
  • ouroboros-consensus-cardano/src

2 files changed

+25
-27
lines changed

ouroboros-consensus-cardano/src/unstable-cardano-testlib/Test/Consensus/Cardano/Generators.hs

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ import Test.Cardano.Ledger.Alonzo.Arbitrary ()
5555
import Test.Cardano.Ledger.Alonzo.Serialisation.Generators ()
5656
import Test.Cardano.Ledger.Conway.Arbitrary ()
5757
import Test.Consensus.Byron.Generators ()
58-
import Test.Consensus.Cardano.MockCrypto
5958
import Test.Consensus.Protocol.Serialisation.Generators ()
6059
import Test.Consensus.Shelley.Generators
6160
import Test.Consensus.Shelley.MockCrypto (CanMock)
@@ -70,14 +69,14 @@ import Test.Util.Serialisation.Roundtrip
7069
Disk
7170
-------------------------------------------------------------------------------}
7271

73-
instance Arbitrary (CardanoBlock MockCryptoCompatByron) where
72+
instance Arbitrary (CardanoBlock StandardCrypto) where
7473
arbitrary =
7574
oneof $ catMaybes $ hcollapse generators
7675
where
7776
generators ::
7877
NP
79-
(K (Maybe (Gen (CardanoBlock MockCryptoCompatByron))))
80-
(CardanoEras MockCryptoCompatByron)
78+
(K (Maybe (Gen (CardanoBlock StandardCrypto))))
79+
(CardanoEras StandardCrypto)
8180
generators =
8281
mk BlockByron
8382
:* mk BlockShelley
@@ -91,18 +90,18 @@ instance Arbitrary (CardanoBlock MockCryptoCompatByron) where
9190
mk ::
9291
forall a x.
9392
Arbitrary a =>
94-
(a -> CardanoBlock MockCryptoCompatByron) ->
95-
K (Maybe (Gen (CardanoBlock MockCryptoCompatByron))) x
93+
(a -> CardanoBlock StandardCrypto) ->
94+
K (Maybe (Gen (CardanoBlock StandardCrypto))) x
9695
mk f = K $ Just $ f <$> arbitrary
9796

98-
instance Arbitrary (Coherent (CardanoBlock MockCryptoCompatByron)) where
97+
instance Arbitrary (Coherent (CardanoBlock StandardCrypto)) where
9998
arbitrary =
10099
fmap Coherent $ oneof $ catMaybes $ hcollapse generators
101100
where
102101
generators ::
103102
NP
104-
(K (Maybe (Gen (CardanoBlock MockCryptoCompatByron))))
105-
(CardanoEras MockCryptoCompatByron)
103+
(K (Maybe (Gen (CardanoBlock StandardCrypto))))
104+
(CardanoEras StandardCrypto)
106105
generators =
107106
mk BlockByron
108107
:* mk BlockShelley
@@ -116,11 +115,11 @@ instance Arbitrary (Coherent (CardanoBlock MockCryptoCompatByron)) where
116115
mk ::
117116
forall a x.
118117
Arbitrary (Coherent a) =>
119-
(a -> CardanoBlock MockCryptoCompatByron) ->
120-
K (Maybe (Gen (CardanoBlock MockCryptoCompatByron))) x
118+
(a -> CardanoBlock StandardCrypto) ->
119+
K (Maybe (Gen (CardanoBlock StandardCrypto))) x
121120
mk f = K $ Just $ f . getCoherent <$> arbitrary
122121

123-
instance Arbitrary (CardanoHeader MockCryptoCompatByron) where
122+
instance Arbitrary (CardanoHeader StandardCrypto) where
124123
arbitrary = getHeader <$> arbitrary
125124

126125
instance
@@ -139,7 +138,7 @@ instance
139138
aux = K . OneEraHash . toShortRawHash (Proxy @blk) . unwrapHeaderHash
140139

141140
instance
142-
(c ~ MockCryptoCompatByron, ShelleyBasedEra ShelleyEra) =>
141+
(c ~ StandardCrypto, ShelleyBasedEra ShelleyEra) =>
143142
Arbitrary (AnnTip (CardanoBlock c))
144143
where
145144
arbitrary =
@@ -344,7 +343,7 @@ arbitraryNodeToNode injByron injShelley injAllegra injMary injAlonzo injBabbage
344343
x
345344

346345
instance
347-
c ~ MockCryptoCompatByron =>
346+
c ~ StandardCrypto =>
348347
Arbitrary
349348
( WithVersion
350349
(HardForkNodeToNodeVersion (CardanoEras c))
@@ -362,7 +361,7 @@ instance
362361
injConway = mapSomeNestedCtxt (NCS . NCS . NCS . NCS . NCS . NCS . NCZ)
363362

364363
instance
365-
c ~ MockCryptoCompatByron =>
364+
c ~ StandardCrypto =>
366365
Arbitrary
367366
( WithVersion
368367
(HardForkNodeToNodeVersion (CardanoEras c))
@@ -380,7 +379,7 @@ instance
380379
BlockConway
381380

382381
instance
383-
c ~ MockCryptoCompatByron =>
382+
c ~ StandardCrypto =>
384383
Arbitrary
385384
( WithVersion
386385
(HardForkNodeToNodeVersion (CardanoEras c))
@@ -398,7 +397,7 @@ instance
398397
HeaderConway
399398

400399
instance
401-
c ~ MockCryptoCompatByron =>
400+
c ~ StandardCrypto =>
402401
Arbitrary
403402
( WithVersion
404403
(HardForkNodeToNodeVersion (CardanoEras c))
@@ -416,7 +415,7 @@ instance
416415
GenTxConway
417416

418417
instance
419-
c ~ MockCryptoCompatByron =>
418+
c ~ StandardCrypto =>
420419
Arbitrary
421420
( WithVersion
422421
(HardForkNodeToNodeVersion (CardanoEras c))
@@ -695,7 +694,7 @@ arbitraryNodeToClient injByron injShelley injAllegra injMary injAlonzo injBabbag
695694
]
696695

697696
instance
698-
c ~ MockCryptoCompatByron =>
697+
c ~ StandardCrypto =>
699698
Arbitrary
700699
( WithVersion
701700
(HardForkNodeToClientVersion (CardanoEras c))
@@ -713,7 +712,7 @@ instance
713712
BlockConway
714713

715714
instance
716-
c ~ MockCryptoCompatByron =>
715+
c ~ StandardCrypto =>
717716
Arbitrary
718717
( WithVersion
719718
(HardForkNodeToClientVersion (CardanoEras c))
@@ -731,7 +730,7 @@ instance
731730
GenTxConway
732731

733732
instance
734-
c ~ MockCryptoCompatByron =>
733+
c ~ StandardCrypto =>
735734
Arbitrary
736735
( WithVersion
737736
(HardForkNodeToClientVersion (CardanoEras c))
@@ -761,8 +760,8 @@ instance
761760
shrink = traverse aux
762761
where
763762
aux ::
764-
CardanoApplyTxErr MockCryptoCompatByron ->
765-
[CardanoApplyTxErr MockCryptoCompatByron]
763+
CardanoApplyTxErr StandardCrypto ->
764+
[CardanoApplyTxErr StandardCrypto]
766765
aux (HardForkApplyTxErrFromEra (OneEraApplyTxErr x)) =
767766
HardForkApplyTxErrFromEra . OneEraApplyTxErr <$> shrink x
768767
aux (HardForkApplyTxErrWrongEra x) =
@@ -796,7 +795,7 @@ instance
796795
]
797796

798797
instance
799-
c ~ MockCryptoCompatByron =>
798+
c ~ StandardCrypto =>
800799
Arbitrary
801800
( WithVersion
802801
(HardForkNodeToClientVersion (CardanoEras c))
@@ -916,7 +915,7 @@ instance Arbitrary (EraIndex (CardanoEras c)) where
916915
Just ns -> return $ eraIndexFromNS ns
917916

918917
instance
919-
c ~ MockCryptoCompatByron =>
918+
c ~ StandardCrypto =>
920919
Arbitrary
921920
( WithVersion
922921
(HardForkNodeToClientVersion (CardanoEras c))

ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/Consensus/Shelley/Generators.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ import Test.Cardano.Ledger.Shelley.Serialisation.EraIndepGenerators
5151
)
5252
import Test.Cardano.Ledger.Shelley.Serialisation.Generators ()
5353
import Test.Cardano.Ledger.ShelleyMA.Serialisation.Generators ()
54-
import Test.Cardano.Protocol.TPraos.Arbitrary (genBlock)
5554
import Test.Consensus.Protocol.Serialisation.Generators ()
5655
import Test.Consensus.Shelley.MockCrypto (CanMock)
5756
import Test.QuickCheck hiding (Result)
@@ -79,7 +78,7 @@ instance
7978
allPoolKeys <-
8079
replicateM (fromIntegral $ numCoreNodes defaultConstants) $
8180
genIssuerKeys defaultConstants
82-
mkShelleyBlock <$> genBlock allPoolKeys
81+
mkShelleyBlock <$> genCoherentBlock allPoolKeys
8382

8483
instance
8584
(Praos.PraosCrypto crypto, CanMock (Praos crypto) era) =>

0 commit comments

Comments
 (0)