@@ -10,7 +10,8 @@ import Pos.Chain.Block (BlockConfiguration (BlockConfiguration))
10
10
import Pos.Chain.Delegation (DlgConfiguration (DlgConfiguration ))
11
11
import Pos.Chain.Genesis (StaticConfig (GCSrc ))
12
12
import Pos.Chain.Ssc (SscConfiguration (SscConfiguration ))
13
- import Pos.Chain.Txp (TxpConfiguration (TxpConfiguration ))
13
+ import Pos.Chain.Txp (TxpConfiguration (TxpConfiguration ), TxValidationRules (TxValidationRules ))
14
+ import Pos.Core.Slotting (EpochOrSlot (EpochOrSlot ), EpochIndex (EpochIndex ), SlotId (SlotId ), LocalSlotIndex (UnsafeLocalSlotIndex ))
14
15
import Pos.Chain.Update (UpdateConfiguration (UpdateConfiguration ))
15
16
import Pos.Configuration (NodeConfiguration (NodeConfiguration ))
16
17
import Pos.Crypto.Configuration
@@ -25,12 +26,27 @@ import Test.Pos.Chain.Update.Gen (genApplicationName, genBlockVersion,
25
26
-- TODO, move a lot of the chain specific generators into cardano-sl-chain
26
27
27
28
genConfiguration :: Gen Configuration
28
- genConfiguration = Configuration <$> genGenesis <*> genNtp <*> genUpdate <*> genSsc <*> genDlg <*> genTxp <*> genBlock <*> genNode <*> genWallet <*> genReqNetMagic
29
+ genConfiguration = Configuration <$> genGenesis <*> genNtp <*> genUpdate <*> genSsc <*> genDlg <*> genTxp <*> genBlock <*> genNode <*> genWallet <*> genReqNetMagic <*> genTxValidationRules
29
30
30
31
genGenesis :: Gen StaticConfig
31
32
-- TODO, GCSpec not covered
32
33
genGenesis = GCSrc <$> genstring <*> (pure $ unsafeMkAbstractHash mempty )
33
34
35
+ genTxValidationRules :: Gen TxValidationRules
36
+ genTxValidationRules = TxValidationRules <$> genEpochOrSlot <*> genEpochOrSlot <*> Gen. integral (Range. constant 1 1000 ) <*> Gen. integral (Range. constant 1 1000 )
37
+
38
+ -- TODO, move these into cardano-sl-core
39
+ genEpochOrSlot :: Gen EpochOrSlot
40
+ genEpochOrSlot = Gen. choice [ genEpoch, genSlot ]
41
+ where
42
+ genEpoch = do
43
+ epoch <- Gen. integral (Range. constant 1 1000 )
44
+ pure $ EpochOrSlot $ Left $ EpochIndex epoch
45
+ genSlot = do
46
+ epoch <- Gen. integral (Range. constant 1 1000 )
47
+ slot <- Gen. integral (Range. constant 1 1000 )
48
+ pure $ EpochOrSlot $ Right $ SlotId epoch (UnsafeLocalSlotIndex slot)
49
+
34
50
genNtp :: Gen NtpConfiguration
35
51
genNtp = NtpConfiguration <$> Gen. list (Range. constant 1 4 ) genstring <*> Gen. integral (Range. constant 1 1000 ) <*> Gen. integral (Range. constant 1 1000 )
36
52
0 commit comments