Skip to content

Commit

Permalink
Exclude byron version from roundtrip testing. Update changelog.
Browse files Browse the repository at this point in the history
  • Loading branch information
lehins committed Dec 20, 2022
1 parent 4296509 commit 7236776
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -230,6 +230,8 @@ in the naming of release branches.

### Removed

- Deprecated `Cardano.Ledger.CompactAddress` module in favor of `Cardano.Ledger.Address`: #3218
- Removed deprecated `Cardano.Ledger.Shelley.CompactAddr`: #3218
- Removed depracted type synonyms: `ValidatedTx`, `TxOut`, `TxBody`, `TxSeq`, `Script`,
`Value`, `PParamDelta`. #3205
- Removed unused `deserialiseAddrStakeRef` function from `Address` module: #3174
Expand Down
Expand Up @@ -10,7 +10,6 @@ import Cardano.Ledger.Babbage (Babbage)
import Cardano.Ledger.Babbage.Rules (BabbageUtxoPredFailure)
import Cardano.Ledger.Block (Block)
import Cardano.Ledger.Core
import Cardano.Ledger.Shelley.TxAuxData (ShelleyTxAuxData)
import Cardano.Protocol.TPraos.BHeader (BHeader)
import Test.Cardano.Ledger.Babbage.Serialisation.Generators ()
import Test.Cardano.Ledger.Binary.RoundTrip
Expand All @@ -26,7 +25,7 @@ tests =
[ testProperty "babbage/Script" $
roundTripAnnExpectation @(Script Babbage),
testProperty "babbage/Metadata" $
roundTripAnnExpectation @(ShelleyTxAuxData Babbage),
roundTripAnnExpectation @(TxAuxData Babbage),
testProperty "babbage/TxOut" $
roundTripCborExpectation @(TxOut Babbage),
testProperty "babbage/TxBody" $
Expand Down
Expand Up @@ -45,11 +45,10 @@ timelockTests :: TestTree
timelockTests =
testGroup
"Timelock tests"
[ testCase "s1" $ roundTripAnnExpectation (eraProtVerHigh @Allegra) s1,
testCase "s2" $ roundTripAnnExpectation (eraProtVerHigh @Allegra) s2,
testCase "s3" $ roundTripAnnExpectation (eraProtVerHigh @Allegra) s3,
testProperty "roundtripTimelock" $
roundTripAnnExpectation @(Timelock Shelley) (eraProtVerHigh @Allegra),
[ testCase "s1" $ roundTripAnnExpectation s1,
testCase "s2" $ roundTripAnnExpectation s2,
testCase "s3" $ roundTripAnnExpectation s3,
testProperty "roundtripTimelock" $ roundTripAnnExpectation @(Timelock Shelley),
testProperty "MultiSig deserialises as Timelock" $
embedTripAnnExpectation @(MultiSig Shelley)
@(Timelock Allegra)
Expand Down
@@ -1,4 +1,5 @@
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
Expand Down Expand Up @@ -49,7 +50,8 @@ import Test.QuickCheck hiding (label)

-- =====================================================================

-- | Tests the roundtrip property using QuickCheck generators fro all possible versions
-- | Tests the roundtrip property using QuickCheck generators for all possible versions
-- starting with `shelleyProtVer`.
roundTripSpec ::
forall t.
(Show t, Eq t, Typeable t, Arbitrary t) =>
Expand Down Expand Up @@ -82,7 +84,8 @@ roundTripFailureExpectation version x =
expectationFailure $
"Should not have deserialized: " ++ showExpr (CBORBytes (serialize' version x))

-- | Verify that round triping through the binary form holds fro all possible versions
-- | Verify that round triping through the binary form holds for all versions starting
-- with `shelleyProtVer`.
--
-- In other words check that:
--
Expand All @@ -94,7 +97,7 @@ roundTripExpectation ::
t ->
Expectation
roundTripExpectation trip t =
forM_ [minBound .. maxBound] $ \version ->
forM_ [natVersion @2 .. maxBound] $ \version ->
case roundTrip version trip t of
Left err -> expectationFailure $ "Failed to deserialize encoded: " ++ show err
Right tDecoded -> tDecoded `shouldBe` t
Expand All @@ -108,13 +111,13 @@ roundTripCborExpectation = roundTripExpectation (cborTrip @t)

roundTripAnnExpectation ::
(Show t, Eq t, ToCBOR t, FromCBOR (Annotator t), HasCallStack) =>
Version ->
t ->
Expectation
roundTripAnnExpectation version t =
case roundTripAnn version t of
Left err -> expectationFailure $ "Failed to deserialize encoded: " ++ show err
Right tDecoded -> tDecoded `shouldBe` t
roundTripAnnExpectation t =
forM_ [natVersion @2 .. maxBound] $ \version ->
case roundTripAnn version t of
Left err -> expectationFailure $ "Failed to deserialize encoded: " ++ show err
Right tDecoded -> tDecoded `shouldBe` t

roundTripTwiddledProperty ::
(Show t, Eq t, Twiddle t, FromCBOR t) => Version -> t -> Property
Expand Down
4 changes: 2 additions & 2 deletions libs/cardano-ledger-core/src/Cardano/Ledger/Address.hs
Expand Up @@ -206,9 +206,9 @@ instance Crypto c => FromJSON (RewardAcnt c) where
Aeson.withObject "RewardAcnt" $ \obj ->
RewardAcnt
<$> obj
.: "network"
.: "network"
<*> obj
.: "credential"
.: "credential"

instance NoThunks (RewardAcnt c)

Expand Down
Expand Up @@ -5,6 +5,9 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}

-- | This module contains previous implementations for Addr and CoompactAddr
-- deserialization. This is used as an alternative implementation for testing and as a
-- perforance reference for benchmarking.
module Test.Cardano.Ledger.Core.Address
( deserialiseAddrOld,
deserialiseRewardAcntOld,
Expand Down

0 comments on commit 7236776

Please sign in to comment.