Skip to content

Commit

Permalink
Test that Consensus emits valid CBOR
Browse files Browse the repository at this point in the history
This commits also add a filtering mechanism to skip CBOR validity
tests of legacy encoders.
  • Loading branch information
dnadales committed Nov 13, 2023
1 parent 0a0bf04 commit 55f49e6
Show file tree
Hide file tree
Showing 4 changed files with 236 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ tests = adjustOption reduceTests $
, testGroup "SerialiseNodeToNode" $
roundtrip_SerialiseNodeToNode byronToCardanoCodeConfig
, testGroup "SerialiseNodeToClient" $
roundtrip_SerialiseNodeToClient byronToCardanoCodeConfig
roundtrip_SerialiseNodeToClient (const CheckCBORValidity) byronToCardanoCodeConfig
]
, testGroup "Cardano to Byron" [
testProperty "roundtrip block" $
Expand All @@ -71,7 +71,7 @@ tests = adjustOption reduceTests $
, testGroup "SerialiseNodeToNode" $
roundtrip_SerialiseNodeToNode cardanoToByronCodeConfig
, testGroup "SerialiseNodeToClient" $
roundtrip_SerialiseNodeToClient cardanoToByronCodeConfig
roundtrip_SerialiseNodeToClient (const CheckCBORValidity) cardanoToByronCodeConfig
]
]
where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,24 @@ import Ouroboros.Consensus.Shelley.Node ()
import Ouroboros.Consensus.Storage.Serialisation
import Ouroboros.Consensus.Util (Dict (..))
import Ouroboros.Network.Block (Serialised (..))
import qualified Test.Consensus.Cardano.Examples as Cardano.Examples
import Test.Consensus.Cardano.Generators (epochSlots)
import Test.Consensus.Cardano.MockCrypto (MockCryptoCompatByron)
import Test.Tasty
import Test.Tasty.QuickCheck
import Test.Tasty.QuickCheck (Property, testProperty, (===))
import Test.Util.Orphans.Arbitrary ()
import Test.Util.Serialisation.Roundtrip

tests :: TestTree
tests = testGroup "Cardano"
[ roundtrip_all testCodecCfg dictNestedHdr
[ testGroup "Examples roundtrip" $ examplesRoundtrip Cardano.Examples.codecConfig Cardano.Examples.examples
, roundtrip_all_skipping result testCodecCfg dictNestedHdr
, testProperty "BinaryBlockInfo sanity check" prop_CardanoBinaryBlockInfo
]
where
-- See https://github.com/input-output-hk/cardano-ledger/issues/3800
result "roundtrip Result" = DoNotCheckCBORValidity
result _ = CheckCBORValidity

testCodecCfg :: CardanoCodecConfig MockCryptoCompatByron
testCodecCfg =
Expand Down
3 changes: 3 additions & 0 deletions ouroboros-consensus/ouroboros-consensus.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ library unstable-consensus-testlib
, ouroboros-consensus
, ouroboros-network-api
, ouroboros-network-mock
, pretty-simple
, QuickCheck
, quickcheck-state-machine
, quiet
Expand All @@ -368,9 +369,11 @@ library unstable-consensus-testlib
, sop-extras
, strict-sop-core
, tasty
, tasty-expected-failure
, tasty-golden
, tasty-quickcheck
, template-haskell
, text
, time
, tree-diff
, utf8-string
Expand Down
Loading

0 comments on commit 55f49e6

Please sign in to comment.