Skip to content

Commit

Permalink
Test that consensus emits valid CBOR (#479)
Browse files Browse the repository at this point in the history
Fixes IntersectMBO/ouroboros-network#3099

Sadly some CBOR validity tests need to be skipped due to:

- IntersectMBO/cardano-ledger#3800
- IntersectMBO/cardano-ledger#3741
- IntersectMBO/cardano-ledger#3740

This patch introduces an ad-hoc filtering mechanism to fix problems with
legacy encoders.
  • Loading branch information
Damian Nadales authored Nov 13, 2023
2 parents 6d0427f + 55f49e6 commit d490501
Show file tree
Hide file tree
Showing 5 changed files with 237 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ jobs:
if [ -f baseline-mempool-benchmarks.csv ]; then
cabal new-run ouroboros-consensus:mempool-bench -- \
--timeout=60 --baseline baseline-mempool-benchmarks.csv \
--fail-if-slower 20 \
--fail-if-slower 100 \
+RTS -T
else
echo "No baseline benchmarks found. This likely happened when adding a new GHC version to the build matrix."
Expand Down
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 d490501

Please sign in to comment.