Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 8ba1df2

Browse files
author
Michael Hueschen
committed
[CDEC-416] Sinbin Test.Pos.Infra.Arbitrary.Slotting
Since this is a module of `infra-test`, we create a new `sinbin-test` package. Imports of the sinbinned module in `update` are modified accordingly.
1 parent 606cd0f commit 8ba1df2

File tree

10 files changed

+83
-28
lines changed

10 files changed

+83
-28
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,3 @@
1-
{-# LANGUAGE NoImplicitPrelude #-}
2-
3-
{-# OPTIONS_GHC -fno-warn-orphans #-}
4-
5-
-- | Arbitrary instances for Pos.Slotting types (infra package)
6-
71
module Test.Pos.Infra.Arbitrary.Slotting () where
82

9-
import Universum
10-
11-
import Test.QuickCheck (Arbitrary (..), arbitrary, oneof)
12-
import Test.QuickCheck.Arbitrary.Generic (genericArbitrary,
13-
genericShrink)
14-
15-
import Pos.Infra.Slotting.Types (EpochSlottingData (..), SlottingData,
16-
createInitSlottingData)
17-
18-
import Test.Pos.Core.Arbitrary ()
19-
20-
instance Arbitrary EpochSlottingData where
21-
arbitrary = genericArbitrary
22-
shrink = genericShrink
23-
24-
instance Arbitrary SlottingData where
25-
-- Fixed instance since it's impossible to create and instance
26-
-- where one creates @SlottingData@ without at least two parameters.
27-
arbitrary = oneof [ createInitSlottingData <$> arbitrary <*> arbitrary ]
3+
import Test.Pos.Sinbin.Arbitrary.Slotting ()

infra/test/cardano-sl-infra-test.cabal

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ library
2626
, cardano-sl-core-test
2727
, cardano-sl-crypto
2828
, cardano-sl-infra
29+
, cardano-sl-sinbin-test
2930
, cardano-sl-util-test
3031
, containers
3132
, generic-arbitrary

sinbin/test/LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2018 IOHK
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included
12+
in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

sinbin/test/Setup.hs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Distribution.Simple
2+
main = defaultMain
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{-# OPTIONS_GHC -fno-warn-orphans #-}
2+
3+
-- | Arbitrary instances for Pos.Slotting types (sinbin package)
4+
5+
module Test.Pos.Sinbin.Arbitrary.Slotting () where
6+
7+
import Universum
8+
9+
import Test.QuickCheck (Arbitrary (..), arbitrary, oneof)
10+
import Test.QuickCheck.Arbitrary.Generic (genericArbitrary,
11+
genericShrink)
12+
13+
import Pos.Sinbin.Slotting.Types (EpochSlottingData (..),
14+
SlottingData, createInitSlottingData)
15+
16+
import Test.Pos.Core.Arbitrary ()
17+
18+
instance Arbitrary EpochSlottingData where
19+
arbitrary = genericArbitrary
20+
shrink = genericShrink
21+
22+
instance Arbitrary SlottingData where
23+
-- Fixed instance since it's impossible to create and instance
24+
-- where one creates @SlottingData@ without at least two parameters.
25+
arbitrary = oneof [ createInitSlottingData <$> arbitrary <*> arbitrary ]
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: cardano-sl-sinbin-test
2+
version: 1.3.0
3+
synopsis: Cardano SL - generators for cardano-sl-sinbin
4+
description: This package contains generators for the data types temporarily held in sinbin.
5+
license: MIT
6+
license-file: LICENSE
7+
author: IOHK Engineering Team
8+
maintainer: [email protected]
9+
copyright: 2018 IOHK
10+
category: Currency
11+
build-type: Simple
12+
cabal-version: >=1.10
13+
14+
library
15+
exposed-modules:
16+
Test.Pos.Sinbin.Arbitrary.Slotting
17+
18+
build-depends: QuickCheck
19+
, base
20+
, cardano-sl-core-test
21+
, cardano-sl-sinbin
22+
, generic-arbitrary
23+
, universum
24+
25+
default-language: Haskell2010
26+
27+
default-extensions: NoImplicitPrelude
28+
29+
ghc-options: -Wall
30+
-O2

stack.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ packages:
2525
- lrc
2626
- lrc/test
2727
- sinbin
28+
- sinbin/test
2829
- infra
2930
- infra/test
3031
- ssc

update/test/Test/Pos/Update/Arbitrary/Core.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import Pos.Update.Poll.Types (VoteState (..))
3030
import Test.Pos.Core.Arbitrary ()
3131
import Test.Pos.Crypto.Arbitrary ()
3232
import Test.Pos.Crypto.Dummy (dummyProtocolMagic)
33-
import Test.Pos.Infra.Arbitrary.Slotting ()
33+
import Test.Pos.Sinbin.Arbitrary.Slotting ()
3434

3535
instance Arbitrary BlockVersionModifier where
3636
arbitrary = genericArbitrary

update/test/Test/Pos/Update/Arbitrary/Poll.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import Pos.Update.Poll.Types (BlockVersionState (..),
2525
UndecidedProposalState (..), UpsExtra (..))
2626

2727
import Test.Pos.Core.Arbitrary ()
28-
import Test.Pos.Infra.Arbitrary.Slotting ()
28+
import Test.Pos.Sinbin.Arbitrary.Slotting ()
2929
import Test.Pos.Update.Arbitrary.Core ()
3030
import Test.Pos.Util.Modifier ()
3131

update/test/cardano-sl-update-test.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ library
2929
, cardano-sl-crypto
3030
, cardano-sl-crypto-test
3131
, cardano-sl-infra
32-
, cardano-sl-infra-test
32+
, cardano-sl-sinbin-test
3333
, cardano-sl-update
3434
, cardano-sl-util-test
3535
, containers

0 commit comments

Comments
 (0)