-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cbor round trip tests for Block
for each era
#4869
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,46 @@ | ||||||||||||||||||||||||||||||||||||||||||
{-# LANGUAGE AllowAmbiguousTypes #-} | ||||||||||||||||||||||||||||||||||||||||||
{-# LANGUAGE DataKinds #-} | ||||||||||||||||||||||||||||||||||||||||||
{-# LANGUAGE FlexibleContexts #-} | ||||||||||||||||||||||||||||||||||||||||||
{-# LANGUAGE ScopedTypeVariables #-} | ||||||||||||||||||||||||||||||||||||||||||
{-# LANGUAGE TypeApplications #-} | ||||||||||||||||||||||||||||||||||||||||||
{-# LANGUAGE TypeFamilies #-} | ||||||||||||||||||||||||||||||||||||||||||
{-# OPTIONS_GHC -Wno-orphans #-} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
module Test.Cardano.Protocol.Binary.RoundTrip (spec) where | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
import Cardano.Ledger.Allegra (AllegraEra) | ||||||||||||||||||||||||||||||||||||||||||
import Cardano.Ledger.Alonzo (AlonzoEra) | ||||||||||||||||||||||||||||||||||||||||||
import Cardano.Ledger.Babbage (BabbageEra) | ||||||||||||||||||||||||||||||||||||||||||
import Cardano.Ledger.Block (Block) | ||||||||||||||||||||||||||||||||||||||||||
import Cardano.Ledger.Conway (ConwayEra) | ||||||||||||||||||||||||||||||||||||||||||
import Cardano.Ledger.Core | ||||||||||||||||||||||||||||||||||||||||||
import Cardano.Ledger.Mary (MaryEra) | ||||||||||||||||||||||||||||||||||||||||||
import Cardano.Ledger.Shelley (ShelleyEra) | ||||||||||||||||||||||||||||||||||||||||||
import Cardano.Protocol.Crypto (StandardCrypto) | ||||||||||||||||||||||||||||||||||||||||||
import Cardano.Protocol.TPraos.BHeader (BHeader) | ||||||||||||||||||||||||||||||||||||||||||
import Data.Typeable | ||||||||||||||||||||||||||||||||||||||||||
import Test.Cardano.Ledger.Common | ||||||||||||||||||||||||||||||||||||||||||
import Test.Cardano.Ledger.Conway.Arbitrary () | ||||||||||||||||||||||||||||||||||||||||||
import Test.Cardano.Ledger.Core.Binary.RoundTrip | ||||||||||||||||||||||||||||||||||||||||||
import Test.Cardano.Protocol.TPraos.Arbitrary () | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
spec :: Spec | ||||||||||||||||||||||||||||||||||||||||||
spec = do | ||||||||||||||||||||||||||||||||||||||||||
describe "RoundTrip" $ do | ||||||||||||||||||||||||||||||||||||||||||
roundTripBlock @ShelleyEra | ||||||||||||||||||||||||||||||||||||||||||
roundTripBlock @AllegraEra | ||||||||||||||||||||||||||||||||||||||||||
roundTripBlock @MaryEra | ||||||||||||||||||||||||||||||||||||||||||
roundTripBlock @AlonzoEra | ||||||||||||||||||||||||||||||||||||||||||
roundTripBlock @BabbageEra | ||||||||||||||||||||||||||||||||||||||||||
roundTripBlock @ConwayEra | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
roundTripBlock :: | ||||||||||||||||||||||||||||||||||||||||||
forall era. | ||||||||||||||||||||||||||||||||||||||||||
( EraSegWits era | ||||||||||||||||||||||||||||||||||||||||||
, Arbitrary (Tx era) | ||||||||||||||||||||||||||||||||||||||||||
) => | ||||||||||||||||||||||||||||||||||||||||||
Spec | ||||||||||||||||||||||||||||||||||||||||||
roundTripBlock = | ||||||||||||||||||||||||||||||||||||||||||
prop (show (typeRep $ Proxy @(Block (BHeader StandardCrypto) era))) $ | ||||||||||||||||||||||||||||||||||||||||||
withMaxSuccess 3 $ | ||||||||||||||||||||||||||||||||||||||||||
roundTripAnnEraExpectation @era @(Block (BHeader StandardCrypto) era) | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+37
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is better to add this funciton to the testlib, so it can be used in consensus as well. For this it needs to be parameterized by block header
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure! good point, thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These do not make sense, because block header as defined in this package is never used with Babbage onwards
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I wondered about whether it brings any value at all like this, but I agree, no point testing unrealistic stuff.
I will try adding for TxSeq instead!