Skip to content

Commit

Permalink
Merge pull request #3292 from input-output-hk/lehins/relax-generator-…
Browse files Browse the repository at this point in the history
…speedup-tests

Relax generator and speedup tests
  • Loading branch information
lehins committed Feb 10, 2023
2 parents 1c2f8aa + 4cddd20 commit 3dfed13
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ instance
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> scale (`div` 15) arbitrary
<*> arbitrary
<*> genMintValues @(EraCrypto era)
<*> arbitrary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ tests =
roundTripCborExpectation @(AlonzoUtxosPredFailure Alonzo)
, testProperty "Script" $
roundTripAnnRangeExpectation @(Script Alonzo)
(eraProtVerLow @Alonzo)
(eraProtVerHigh @Alonzo)
, testProperty "alonzo/Tx" $
roundTripAnnRangeExpectation @(Tx Alonzo)
(eraProtVerLow @Alonzo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ instance
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> scale (`div` 15) arbitrary
<*> arbitrary
<*> genMintValues
<*> arbitrary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,41 @@ tests =
testGroup
"Babbage CBOR round-trip"
[ testProperty "babbage/Script" $
roundTripAnnExpectation @(Script Babbage)
roundTripAnnRangeExpectation @(Script Babbage)
(eraProtVerLow @Babbage)
(eraProtVerHigh @Babbage)
, testProperty "babbage/Metadata" $
roundTripAnnExpectation @(TxAuxData Babbage)
roundTripAnnRangeExpectation @(TxAuxData Babbage)
(eraProtVerLow @Babbage)
(eraProtVerHigh @Babbage)
, testProperty "babbage/TxOut" $
roundTripCborExpectation @(TxOut Babbage)
, testProperty "babbage/TxBody" $
roundTripAnnExpectation @(TxBody Babbage)
roundTripAnnRangeExpectation @(TxBody Babbage)
(eraProtVerLow @Babbage)
(eraProtVerHigh @Babbage)
, testProperty "babbage/CostModel" $
roundTripCborExpectation @CostModels
, testProperty "babbage/PParams" $
roundTripCborExpectation @(PParams Babbage)
, testProperty "babbage/PParamsUpdate" $
roundTripCborExpectation @(PParamsUpdate Babbage)
, testProperty "babbage/AuxiliaryData" $
roundTripAnnExpectation @(TxAuxData Babbage)
roundTripAnnRangeExpectation @(TxAuxData Babbage)
(eraProtVerLow @Babbage)
(eraProtVerHigh @Babbage)
, testProperty "Script" $
roundTripAnnExpectation @(Script Babbage)
roundTripAnnRangeExpectation @(Script Babbage)
(eraProtVerLow @Babbage)
(eraProtVerHigh @Babbage)
, testProperty "babbage/Tx" $
roundTripAnnExpectation @(Tx Babbage)
roundTripAnnRangeExpectation @(Tx Babbage)
(eraProtVerLow @Babbage)
(eraProtVerHigh @Babbage)
, testProperty "babbage/BabbageUtxoPredFailure" $
roundTripCborExpectation @(BabbageUtxoPredFailure Babbage)
, testProperty "babbage/Block" $
roundTripAnnExpectation @(Block (BHeader StandardCrypto) Babbage)
roundTripAnnRangeExpectation @(Block (BHeader StandardCrypto) Babbage)
(eraProtVerLow @Babbage)
(eraProtVerHigh @Babbage)
]
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import Test.QuickCheck (
listOf,
oneof,
resize,
scale,
shrink,
vectorOf,
)
Expand Down Expand Up @@ -151,7 +152,7 @@ instance
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> scale (`div` 15) arbitrary
<*> arbitrary

{-------------------------------------------------------------------------------
Expand All @@ -170,7 +171,7 @@ instance
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> scale (`div` 15) arbitrary
<*> arbitrary
<*> genMintValues

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Test.Cardano.Ledger.ShelleyMA.Serialisation.Roundtrip where

import Cardano.Ledger.Allegra (Allegra)
import Cardano.Ledger.Binary (FromCBOR, ToCBOR)
import qualified Cardano.Ledger.Core as Core
import Cardano.Ledger.Core
import Cardano.Ledger.Mary (Mary)
import Cardano.Ledger.Shelley (Shelley)
import Cardano.Ledger.Shelley.API (ApplyTx, ApplyTxError)
Expand All @@ -18,7 +18,7 @@ import Data.Proxy (Proxy (Proxy))
import Data.Typeable (typeRep)
import Test.Cardano.Ledger.Binary.RoundTrip (
cborTrip,
roundTripAnnExpectation,
roundTripAnnRangeExpectation,
roundTripCborExpectation,
roundTripExpectation,
)
Expand All @@ -32,22 +32,31 @@ import Test.Tasty.QuickCheck (testProperty)
eraRoundTripProps ::
forall e.
( ApplyTx e
, Arbitrary (Core.TxBody e)
, Arbitrary (Core.TxAuxData e)
, Arbitrary (Core.Value e)
, Arbitrary (Core.Script e)
, Arbitrary (TxBody e)
, Arbitrary (TxAuxData e)
, Arbitrary (Value e)
, Arbitrary (Script e)
, Arbitrary (ApplyTxError e)
, ToCBOR (PredicateFailure (Core.EraRule "LEDGER" e))
, FromCBOR (PredicateFailure (Core.EraRule "LEDGER" e))
, ToCBOR (PredicateFailure (EraRule "LEDGER" e))
, FromCBOR (PredicateFailure (EraRule "LEDGER" e))
) =>
TestTree
eraRoundTripProps =
testGroup
(show $ typeRep (Proxy @e))
[ testProperty "TxBody" $ roundTripAnnExpectation @(Core.TxBody e)
, testProperty "Metadata" $ roundTripAnnExpectation @(Core.TxAuxData e)
, testProperty "Value" $ roundTripExpectation @(Core.Value e) cborTrip
, testProperty "Script" $ roundTripAnnExpectation @(Core.Script e)
[ testProperty "TxBody" $
roundTripAnnRangeExpectation @(TxBody e)
(eraProtVerLow @e)
(eraProtVerHigh @e)
, testProperty "Metadata" $
roundTripAnnRangeExpectation @(TxAuxData e)
(eraProtVerLow @e)
(eraProtVerHigh @e)
, testProperty "Value" $ roundTripExpectation @(Value e) cborTrip
, testProperty "Script" $
roundTripAnnRangeExpectation @(Script e)
(eraProtVerLow @e)
(eraProtVerHigh @e)
, testProperty "ApplyTxError" $ roundTripCborExpectation @(ApplyTxError e)
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import qualified Cardano.Ledger.Shelley.Rules as STS
import Generic.Random (genericArbitraryU)
import Test.Cardano.Ledger.Shelley.ConcreteCryptoTypes (Mock)
import Test.Cardano.Ledger.Shelley.Serialisation.EraIndepGenerators ()
import Test.QuickCheck (Arbitrary (..))
import Test.QuickCheck (Arbitrary (..), scale)

{-------------------------------------------------------------------------------
ShelleyEra Generators
Expand All @@ -40,7 +40,7 @@ instance
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> scale (`div` 15) arbitrary
<*> arbitrary

instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Cardano.Ledger.Binary (
fromNotSharedCBOR,
)
import Cardano.Ledger.Compactible (Compactible (..))
import Cardano.Ledger.Core
import Cardano.Ledger.Crypto (StandardCrypto)
import Cardano.Ledger.Shelley (Shelley)
import Cardano.Ledger.Shelley.API as Ledger
Expand Down Expand Up @@ -79,11 +80,17 @@ tests =
testGroup
"Serialisation roundtrip Property Tests"
$ [ testProperty "Block" $
roundTripAnnExpectation @(Block (TP.BHeader StandardCrypto) Shelley)
roundTripAnnRangeExpectation @(Block (TP.BHeader StandardCrypto) Shelley)
(eraProtVerLow @Shelley)
(eraProtVerHigh @Shelley)
, testProperty "TxBody" $
roundTripAnnExpectation @(ShelleyTxBody Shelley)
roundTripAnnRangeExpectation @(ShelleyTxBody Shelley)
(eraProtVerLow @Shelley)
(eraProtVerHigh @Shelley)
, testProperty "Tx" $
roundTripAnnExpectation @(ShelleyTx Shelley)
roundTripAnnRangeExpectation @(ShelleyTx Shelley)
(eraProtVerLow @Shelley)
(eraProtVerHigh @Shelley)
, testProperty "TxOut" $
roundTripExpectation @(ShelleyTxOut Shelley) cborTrip
, testProperty "LEDGER Predicate Failures" $
Expand All @@ -95,9 +102,13 @@ tests =
, testProperty "NewEpoch State" $
roundTripExpectation @(NewEpochState Shelley) cborTrip
, testProperty "MultiSig" $
roundTripAnnExpectation @(MultiSig Shelley)
roundTripAnnRangeExpectation @(MultiSig Shelley)
(eraProtVerLow @Shelley)
(eraProtVerHigh @Shelley)
, testProperty "TxAuxData" $
roundTripAnnExpectation @(ShelleyTxAuxData Shelley)
roundTripAnnRangeExpectation @(ShelleyTxAuxData Shelley)
(eraProtVerLow @Shelley)
(eraProtVerHigh @Shelley)
, testProperty "Shelley Genesis" $
roundTripExpectation @(ShelleyGenesis StandardCrypto) cborTrip
, testProperty "NominalDiffTimeMicro" $
Expand Down

0 comments on commit 3dfed13

Please sign in to comment.