1414module Test.ThreadNet.AllegraMary (tests ) where
1515
1616import qualified Cardano.Ledger.Api.Transition as L
17- import Cardano.Ledger.BaseTypes (nonZero , unNonZero )
17+ import Cardano.Ledger.BaseTypes (unNonZero )
1818import qualified Cardano.Ledger.BaseTypes as SL
1919import qualified Cardano.Ledger.Shelley.Core as SL
2020import qualified Cardano.Protocol.TPraos.OCert as SL
@@ -29,18 +29,12 @@ import Data.Set (Set)
2929import qualified Data.Set as Set
3030import Data.Word (Word64 )
3131import Lens.Micro ((^.) )
32- import Ouroboros.Consensus.BlockchainTime
3332import Ouroboros.Consensus.Cardano.Condense ()
3433import Ouroboros.Consensus.Cardano.Node (TriggerHardFork (.. ))
3534import Ouroboros.Consensus.Config.SecurityParam
36- import Ouroboros.Consensus.HardFork.Combinator.Serialisation.Common
37- ( isHardForkNodeToNodeEnabled
38- )
3935import Ouroboros.Consensus.Ledger.SupportsMempool (extractTxs )
40- import Ouroboros.Consensus.Node.NetworkProtocolVersion
4136import Ouroboros.Consensus.Node.ProtocolInfo
4237import Ouroboros.Consensus.NodeId
43- import Ouroboros.Consensus.Protocol.TPraos (TPraos )
4438import Ouroboros.Consensus.Shelley.Eras
4539import Ouroboros.Consensus.Shelley.Ledger.SupportsProtocol ()
4640import Ouroboros.Consensus.Shelley.Node
@@ -51,6 +45,7 @@ import Test.Consensus.Shelley.MockCrypto (MockCrypto)
5145import Test.QuickCheck
5246import Test.Tasty
5347import Test.Tasty.QuickCheck
48+ import Test.ThreadNet.EraCrossingInfra (DualBlock , TestSetup (.. ))
5449import Test.ThreadNet.General
5550import qualified Test.ThreadNet.Infra.Shelley as Shelley
5651import Test.ThreadNet.Infra.ShelleyBasedHardFork
@@ -65,87 +60,13 @@ import Test.ThreadNet.TxGen.Mary ()
6560import Test.ThreadNet.Util.Expectations (NumBlocks (.. ))
6661import Test.ThreadNet.Util.NodeJoinPlan (trivialNodeJoinPlan )
6762import Test.ThreadNet.Util.NodeRestarts (noRestarts )
68- import Test.ThreadNet.Util.NodeToNodeVersion (genVersionFiltered )
6963import Test.ThreadNet.Util.Seed (runGen )
7064import qualified Test.Util.BoolProps as BoolProps
7165import Test.Util.HardFork.Future (EraSize (.. ), Future (.. ))
7266import Test.Util.Orphans.Arbitrary ()
7367import Test.Util.Slots (NumSlots (.. ))
7468import Test.Util.TestEnv
7569
76- type AllegraMaryBlock =
77- ShelleyBasedHardForkBlock (TPraos MockCrypto ) AllegraEra (TPraos MockCrypto ) MaryEra
78-
79- -- | The varying data of this test
80- --
81- -- Note: The Shelley nodes in this test all join, propose an update, and endorse
82- -- it literally as soon as possible. Therefore, if the test reaches the end of
83- -- the first epoch, the proposal will be adopted.
84- data TestSetup = TestSetup
85- { setupD :: Shelley. DecentralizationParam
86- , setupHardFork :: Bool
87- -- ^ whether the proposal should trigger a hard fork or not
88- , setupInitialNonce :: SL. Nonce
89- -- ^ the initial Shelley 'SL.ticknStateEpochNonce'
90- --
91- -- We vary it to ensure we explore different leader schedules.
92- , setupK :: SecurityParam
93- , setupPartition :: Partition
94- , setupSlotLength :: SlotLength
95- , setupTestConfig :: TestConfig
96- , setupVersion :: (NodeToNodeVersion , BlockNodeToNodeVersion AllegraMaryBlock )
97- }
98- deriving Show
99-
100- instance Arbitrary TestSetup where
101- arbitrary = do
102- setupD <-
103- arbitrary
104- -- The decentralization parameter cannot be 0 in the first
105- -- Shelley epoch, since stake pools can only be created and
106- -- delegated to via Shelley transactions.
107- `suchThat` ((/= 0 ) . Shelley. decentralizationParamToRational)
108- setupK <- SecurityParam <$> choose (8 , 10 ) `suchThatMap` nonZero
109- -- If k < 8, common prefix violations become too likely in
110- -- Praos mode for thin overlay schedules (ie low d), even for
111- -- f=0.2.
112-
113- setupInitialNonce <- genNonce
114-
115- setupSlotLength <- arbitrary
116-
117- let epochSize = EpochSize $ shelleyEpochSize setupK
118- setupTestConfig <-
119- genTestConfig
120- setupK
121- (epochSize, epochSize)
122- let TestConfig {numCoreNodes, numSlots} = setupTestConfig
123-
124- setupHardFork <- frequency [(49 , pure True ), (1 , pure False )]
125-
126- -- TODO How reliable is the Byron-based partition duration logic when
127- -- reused for Shelley?
128- setupPartition <- genPartition numCoreNodes numSlots setupK
129-
130- setupVersion <-
131- genVersionFiltered
132- isHardForkNodeToNodeEnabled
133- (Proxy @ AllegraMaryBlock )
134-
135- pure
136- TestSetup
137- { setupD
138- , setupHardFork
139- , setupInitialNonce
140- , setupK
141- , setupPartition
142- , setupSlotLength
143- , setupTestConfig
144- , setupVersion
145- }
146-
147- -- TODO shrink
148-
14970tests :: TestTree
15071tests =
15172 testGroup
@@ -158,7 +79,7 @@ tests =
15879 Nightly -> tree
15980 _ -> adjustQuickCheckTests (`div` 10 ) tree
16081
161- prop_simple_allegraMary_convergence :: TestSetup -> Property
82+ prop_simple_allegraMary_convergence :: TestSetup AllegraEra MaryEra -> Property
16283prop_simple_allegraMary_convergence
16384 TestSetup
16485 { setupD
@@ -235,7 +156,7 @@ prop_simple_allegraMary_convergence
235156 , version = setupVersion
236157 }
237158
238- testOutput :: TestOutput AllegraMaryBlock
159+ testOutput :: TestOutput ( DualBlock AllegraEra MaryEra )
239160 testOutput =
240161 runTestNetwork
241162 setupTestConfig
0 commit comments