Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,11 @@ tests: true
benchmarks: true

import: ./asserts.cabal

-- This can be removed once this fix is released https://github.com/well-typed/cborg/pull/325
source-repository-package
type: git
location: https://github.com/well-typed/cborg.git
tag: c8013b3474d876f4da56c869d57e3f3ac7f42dc6
--sha256: 1rahq47qm977fawkq3d3718bz7fvd7hvy0s9qnbhlzafkqhqnqzj
subdir: cborg
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ import qualified Test.Cardano.Chain.Genesis.Dummy as CC
import qualified Test.Cardano.Chain.Update.Example as CC
import qualified Test.Cardano.Chain.UTxO.Example as CC
import Test.ThreadNet.Infra.Byron.ProtocolInfo (mkLeaderCredentials)
import qualified Test.Util.Serialisation.Golden as Golden
import Test.Util.Serialisation.Golden (Labelled, labelled, unlabelled)
import Test.Util.Serialisation.Roundtrip (SomeResult (..))
import qualified Test.Util.Serialisation.Examples as Examples
import Test.Util.Serialisation.Examples (Examples (Examples),
Labelled, labelled, unlabelled)
import Test.Util.Serialisation.SomeResult (SomeResult (..))

{-------------------------------------------------------------------------------
Setup
Expand Down Expand Up @@ -89,8 +90,8 @@ leaderCredentials =
Examples
-------------------------------------------------------------------------------}

examples :: Golden.Examples ByronBlock
examples = Golden.Examples {
examples :: Examples ByronBlock
examples = Examples {
exampleBlock = regularAndEBB exampleBlock exampleEBB
, exampleSerialisedBlock = regularAndEBB exampleSerialisedBlock exampleSerialisedEBB
, exampleHeader = regularAndEBB exampleHeader exampleEBBHeader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ import Test.QuickCheck hiding (Result)
import Test.QuickCheck.Hedgehog (hedgehog)
import Test.Util.Orphans.Arbitrary ()
import Test.Util.Serialisation.Roundtrip (Coherent (..),
SomeResult (..), WithVersion (..))
WithVersion (..))
import Test.Util.Serialisation.SomeResult (SomeResult (..))

{-------------------------------------------------------------------------------
Generators
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ import Ouroboros.Consensus.TypeFamilyWrappers
import Ouroboros.Network.Block (Serialised (..))
import qualified Test.Consensus.Byron.Examples as Byron
import qualified Test.Consensus.Shelley.Examples as Shelley
import qualified Test.Util.Serialisation.Golden as Golden
import Test.Util.Serialisation.Golden (Examples, Labelled, labelled)
import Test.Util.Serialisation.Roundtrip (SomeResult (..))
import Test.Util.Serialisation.Examples (Examples (..), Labelled,
labelled, prefixExamples)
import Test.Util.Serialisation.SomeResult (SomeResult (..))

type Crypto = StandardCrypto

Expand Down Expand Up @@ -91,7 +91,7 @@ combineEras = mconcat . hcollapse . hap eraInjections
-> Examples blk
-> Examples (CardanoBlock Crypto)
injExamples eraName idx =
Golden.prefixExamples eraName
prefixExamples eraName
. inject exampleStartBounds idx

{-------------------------------------------------------------------------------
Expand All @@ -108,7 +108,7 @@ instance Inject SomeResult where
SomeResult (QueryIfCurrent (injectQuery idx q)) (Right r)

instance Inject Examples where
inject startBounds (idx :: Index xs x) Golden.Examples {..} = Golden.Examples {
inject startBounds (idx :: Index xs x) Examples {..} = Examples {
exampleBlock = inj (Proxy @I) exampleBlock
, exampleSerialisedBlock = inj (Proxy @Serialised) exampleSerialisedBlock
, exampleHeader = inj (Proxy @Header) exampleHeader
Expand Down Expand Up @@ -240,7 +240,7 @@ summary =
(State.TransitionKnown shelleyTransitionEpoch)
(hardForkLedgerStatePerEra (ledgerStateByron byronLedger))
where
(_, byronLedger) = head $ Golden.exampleLedgerState Byron.examples
(_, byronLedger) = head $ exampleLedgerState Byron.examples

eraInfoByron :: SingleEraInfo ByronBlock
eraInfoByron = singleEraInfo (Proxy @ByronBlock)
Expand Down Expand Up @@ -277,16 +277,16 @@ ledgerStateByron stByron =
-- | Multi-era examples, e.g., applying a transaction to the wrong era.
multiEraExamples :: Examples (CardanoBlock Crypto)
multiEraExamples = mempty {
Golden.exampleApplyTxErr = labelled [
exampleApplyTxErr = labelled [
("WrongEraByron", exampleApplyTxErrWrongEraByron)
, ("WrongEraShelley", exampleApplyTxErrWrongEraShelley)
]
, Golden.exampleQuery = labelled [
, exampleQuery = labelled [
("AnytimeByron", exampleQueryAnytimeByron)
, ("AnytimeShelley", exampleQueryAnytimeShelley)
, ("HardFork", exampleQueryHardFork)
]
, Golden.exampleResult = labelled [
, exampleResult = labelled [
("EraMismatchByron", exampleResultEraMismatchByron)
, ("EraMismatchShelley", exampleResultEraMismatchShelley)
, ("AnytimeByron", exampleResultAnytimeByron)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ import Test.Cardano.Ledger.Shelley.Examples.Consensus
(ShelleyLedgerExamples (..), ShelleyResultExamples (..),
ledgerExamplesShelley, testShelleyGenesis)
import Test.Util.Orphans.Arbitrary ()
import qualified Test.Util.Serialisation.Golden as Golden
import Test.Util.Serialisation.Golden (labelled, unlabelled)
import Test.Util.Serialisation.Roundtrip (SomeResult (..))
import Test.Util.Serialisation.Examples (Examples (..), labelled,
unlabelled)
import Test.Util.Serialisation.SomeResult (SomeResult (..))


{-------------------------------------------------------------------------------
Expand All @@ -74,11 +74,11 @@ codecConfig = ShelleyCodecConfig
fromShelleyLedgerExamples
:: ShelleyCompatible (TPraos (EraCrypto era)) era
=> ShelleyLedgerExamples era
-> Golden.Examples (ShelleyBlock (TPraos (EraCrypto era)) era)
-> Examples (ShelleyBlock (TPraos (EraCrypto era)) era)
fromShelleyLedgerExamples ShelleyLedgerExamples {
sleResultExamples = ShelleyResultExamples{..}
, ..} =
Golden.Examples {
Examples {
exampleBlock = unlabelled blk
, exampleSerialisedBlock = unlabelled serialisedBlock
, exampleHeader = unlabelled $ getHeader blk
Expand Down Expand Up @@ -148,11 +148,11 @@ fromShelleyLedgerExamplesPraos ::
TranslateProto (TPraos (EraCrypto era)) (Praos (EraCrypto era))
)
=> ShelleyLedgerExamples era
-> Golden.Examples (ShelleyBlock (Praos (EraCrypto era)) era)
-> Examples (ShelleyBlock (Praos (EraCrypto era)) era)
fromShelleyLedgerExamplesPraos ShelleyLedgerExamples {
sleResultExamples = ShelleyResultExamples{..}
, ..} =
Golden.Examples {
Examples {
exampleBlock = unlabelled blk
, exampleSerialisedBlock = unlabelled serialisedBlock
, exampleHeader = unlabelled $ getHeader blk
Expand Down Expand Up @@ -237,20 +237,20 @@ fromShelleyLedgerExamplesPraos ShelleyLedgerExamples {



examplesShelley :: Golden.Examples StandardShelleyBlock
examplesShelley :: Examples StandardShelleyBlock
examplesShelley = fromShelleyLedgerExamples ledgerExamplesShelley

examplesAllegra :: Golden.Examples StandardAllegraBlock
examplesAllegra :: Examples StandardAllegraBlock
examplesAllegra = fromShelleyLedgerExamples ledgerExamplesAllegra

examplesMary :: Golden.Examples StandardMaryBlock
examplesMary :: Examples StandardMaryBlock
examplesMary = fromShelleyLedgerExamples ledgerExamplesMary

examplesAlonzo :: Golden.Examples StandardAlonzoBlock
examplesAlonzo :: Examples StandardAlonzoBlock
examplesAlonzo = fromShelleyLedgerExamples ledgerExamplesAlonzo

examplesBabbage :: Golden.Examples StandardBabbageBlock
examplesBabbage :: Examples StandardBabbageBlock
examplesBabbage = fromShelleyLedgerExamplesPraos ledgerExamplesBabbage

examplesConway :: Golden.Examples StandardConwayBlock
examplesConway :: Examples StandardConwayBlock
examplesConway = fromShelleyLedgerExamplesPraos ledgerExamplesConway
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ import Test.Consensus.Shelley.MockCrypto (CanMock)
import Test.QuickCheck hiding (Result)
import Test.Util.Orphans.Arbitrary ()
import Test.Util.Serialisation.Roundtrip (Coherent (..),
SomeResult (..), WithVersion (..))
WithVersion (..))
import Test.Util.Serialisation.SomeResult (SomeResult (..))

{-------------------------------------------------------------------------------
Generators
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ import Test.Util.Serialisation.Roundtrip
tests :: TestTree
tests = testGroup "Byron"
[ roundtrip_all testCodecCfg dictNestedHdr

, testProperty "BinaryBlockInfo sanity check" prop_byronBinaryBlockInfo

, testGroup "Integrity"
[ testProperty "detect corruption in RegularBlock" prop_detectCorruption_RegularBlock
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import Test.Tasty
import Test.Tasty.QuickCheck
import Test.Util.Orphans.Arbitrary ()
import Test.Util.Serialisation.Roundtrip
import Test.Util.Serialisation.SomeResult (SomeResult (..))

tests :: TestTree
tests = adjustOption reduceTests $
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
Expand All @@ -19,16 +20,18 @@ 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 testCodecCfg dictNestedHdr
, testProperty "BinaryBlockInfo sanity check" prop_CardanoBinaryBlockInfo
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,10 @@ import Test.Util.Serialisation.Roundtrip
tests :: TestTree
tests = testGroup "Shelley"
[ roundtrip_all testCodecCfg dictNestedHdr

-- Test for real crypto too
, testProperty "hashSize real crypto" $ prop_hashSize pReal
, testProperty "ConvertRawHash real crypto" $ roundtrip_ConvertRawHash pReal

, testProperty "BinaryBlockInfo sanity check" prop_shelleyBinaryBlockInfo

, testGroup "Integrity"
[ testProperty "generate non-corrupt blocks" prop_blockIntegrity
, testProperty "generate non-corrupt headers" prop_headerIntegrity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import Ouroboros.Consensus.Protocol.BFT
import Test.QuickCheck
import Test.Util.Orphans.Arbitrary ()
import Test.Util.Serialisation.Roundtrip
import Test.Util.Serialisation.SomeResult (SomeResult (..))

{-------------------------------------------------------------------------------
General instances
Expand Down
5 changes: 5 additions & 0 deletions ouroboros-consensus/ouroboros-consensus.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,10 @@ library unstable-consensus-testlib
Test.Util.Range
Test.Util.RefEnv
Test.Util.Schedule
Test.Util.Serialisation.Examples
Test.Util.Serialisation.Golden
Test.Util.Serialisation.Roundtrip
Test.Util.Serialisation.SomeResult
Test.Util.Shrink
Test.Util.Slots
Test.Util.SOP
Expand Down Expand Up @@ -349,6 +351,7 @@ library unstable-consensus-testlib
, ouroboros-consensus
, ouroboros-network-api
, ouroboros-network-mock
, pretty-simple
, QuickCheck
, quickcheck-state-machine
, quiet
Expand All @@ -358,9 +361,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