@@ -13,6 +13,7 @@ module Test.Pos.Core.CborSpec
13
13
import Universum
14
14
15
15
import Test.Hspec (Spec , describe , runIO )
16
+ import Test.Hspec.QuickCheck (modifyMaxSuccess )
16
17
import Test.QuickCheck (Arbitrary (.. ), generate )
17
18
import Test.QuickCheck.Arbitrary.Generic (genericArbitrary , genericShrink )
18
19
@@ -29,7 +30,7 @@ import Pos.Merkle (MerkleTree)
29
30
import Test.Pos.Binary.Helpers (binaryTest )
30
31
import Test.Pos.Core.Arbitrary ()
31
32
import Test.Pos.Core.Chrono ()
32
- import Test.Pos.Crypto.Arbitrary ()
33
+ import Test.Pos.Crypto.Arbitrary (genProtocolMagicUniformWithRNM )
33
34
34
35
35
36
data MyScript = MyScript
@@ -77,50 +78,56 @@ instance Bi (Attributes X2) where
77
78
78
79
----------------------------------------
79
80
81
+ -- We run the tests this number of times, with different `ProtocolMagics`, to get increased
82
+ -- coverage. We should really do this inside of the `prop`, but it is difficult to do that
83
+ -- without significant rewriting of the testsuite.
84
+ testMultiple :: Int
85
+ testMultiple = 3
80
86
81
87
spec :: Spec
82
88
spec = do
83
89
runWithMagic NMMustBeNothing
84
90
runWithMagic NMMustBeJust
85
91
86
92
runWithMagic :: RequiresNetworkMagic -> Spec
87
- runWithMagic rnm = do
88
- pm <- (\ ident -> ProtocolMagic ident rnm) <$> runIO (generate arbitrary)
89
- describe (" (requiresNetworkMagic=" ++ show rnm ++ " )" ) $
90
- withGenesisSpec 0 (defaultCoreConfiguration pm) $ \ _ ->
91
- describe " Cbor Bi instances" $ do
92
- describe " Core.Address" $ do
93
- binaryTest @ Address
94
- binaryTest @ Address'
95
- binaryTest @ AddrType
96
- binaryTest @ AddrStakeDistribution
97
- binaryTest @ AddrSpendingData
98
- describe " Core.Types" $ do
99
- binaryTest @ Timestamp
100
- binaryTest @ TimeDiff
101
- binaryTest @ EpochIndex
102
- binaryTest @ Coin
103
- binaryTest @ CoinPortion
104
- binaryTest @ LocalSlotIndex
105
- binaryTest @ SlotId
106
- binaryTest @ EpochOrSlot
107
- binaryTest @ SharedSeed
108
- binaryTest @ ChainDifficulty
109
- binaryTest @ SoftforkRule
110
- binaryTest @ BlockVersionData
111
- binaryTest @ (Attributes () )
112
- binaryTest @ (Attributes AddrAttributes )
113
- describe " Core.Fee" $ do
114
- binaryTest @ Coeff
115
- binaryTest @ TxSizeLinear
116
- binaryTest @ TxFeePolicy
117
- describe " Core.Script" $ do
118
- binaryTest @ Script
119
- describe " Core.Vss" $ do
120
- binaryTest @ VssCertificate
121
- describe " Core.Version" $ do
122
- binaryTest @ ApplicationName
123
- binaryTest @ SoftwareVersion
124
- binaryTest @ BlockVersion
125
- describe " Merkle" $ do
126
- binaryTest @ (MerkleTree Int32 )
93
+ runWithMagic rnm = replicateM_ testMultiple $
94
+ modifyMaxSuccess (`div` testMultiple) $ do
95
+ pm <- runIO (generate (genProtocolMagicUniformWithRNM rnm))
96
+ describe (" (requiresNetworkMagic=" ++ show rnm ++ " )" ) $
97
+ withGenesisSpec 0 (defaultCoreConfiguration pm) $ \ _ ->
98
+ describe " Cbor Bi instances" $ do
99
+ describe " Core.Address" $ do
100
+ binaryTest @ Address
101
+ binaryTest @ Address'
102
+ binaryTest @ AddrType
103
+ binaryTest @ AddrStakeDistribution
104
+ binaryTest @ AddrSpendingData
105
+ describe " Core.Types" $ do
106
+ binaryTest @ Timestamp
107
+ binaryTest @ TimeDiff
108
+ binaryTest @ EpochIndex
109
+ binaryTest @ Coin
110
+ binaryTest @ CoinPortion
111
+ binaryTest @ LocalSlotIndex
112
+ binaryTest @ SlotId
113
+ binaryTest @ EpochOrSlot
114
+ binaryTest @ SharedSeed
115
+ binaryTest @ ChainDifficulty
116
+ binaryTest @ SoftforkRule
117
+ binaryTest @ BlockVersionData
118
+ binaryTest @ (Attributes () )
119
+ binaryTest @ (Attributes AddrAttributes )
120
+ describe " Core.Fee" $ do
121
+ binaryTest @ Coeff
122
+ binaryTest @ TxSizeLinear
123
+ binaryTest @ TxFeePolicy
124
+ describe " Core.Script" $ do
125
+ binaryTest @ Script
126
+ describe " Core.Vss" $ do
127
+ binaryTest @ VssCertificate
128
+ describe " Core.Version" $ do
129
+ binaryTest @ ApplicationName
130
+ binaryTest @ SoftwareVersion
131
+ binaryTest @ BlockVersion
132
+ describe " Merkle" $ do
133
+ binaryTest @ (MerkleTree Int32 )
0 commit comments