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

Commit ddecc53

Browse files
authored
Merge pull request #3600 from input-output-hk/ruhatch/CDEC-505
[CDEC-505] Move Pos.Core.Delegation to Pos.Chain.Delegation
2 parents 295647b + 8d5a138 commit ddecc53

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+279
-240
lines changed

auxx/src/Command/Proc.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import qualified Data.Map as Map
1515
import Formatting (build, int, sformat, stext, (%))
1616
import qualified Text.JSON.Canonical as CanonicalJSON
1717

18+
import Pos.Chain.Delegation (HeavyDlgIndex (..))
1819
import Pos.Chain.Genesis as Genesis (Config (..), configEpochSlots,
1920
configGeneratedSecretsThrow)
2021
import Pos.Chain.Genesis (gsSecretKeys)
@@ -26,7 +27,6 @@ import Pos.Core (AddrStakeDistribution (..), StakeholderId,
2627
addressHash, mkMultiKeyDistr, unsafeGetCoin)
2728
import Pos.Core.Common (AddrAttributes (..), AddrSpendingData (..),
2829
makeAddress)
29-
import Pos.Core.Delegation (HeavyDlgIndex (..))
3030
import Pos.Core.Update (SoftwareVersion (..))
3131
import Pos.Crypto (PublicKey, emptyPassphrase, encToPublic,
3232
fullPublicKeyF, hashHexF, noPassEncrypt, safeCreatePsk,

chain/bench/block-bench.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import Pos.Chain.Block (Body, BodyProof, ConsensusData, ExtraBodyData,
1515
MainBlockchain, _gbBody, _gbExtra, _gbHeader,
1616
_gbhBodyProof, _gbhConsensus, _gbhExtra, _mbDlgPayload,
1717
_mbSscPayload, _mbTxPayload, _mbUpdatePayload)
18+
import Pos.Chain.Delegation (DlgPayload)
1819
import Pos.Chain.Txp (TxPayload (..))
19-
import Pos.Core.Delegation (DlgPayload)
2020
import Pos.Core.Ssc (SscPayload)
2121
import Pos.Core.Update (UpdatePayload)
2222
import Pos.Crypto (ProtocolMagic (..))

chain/cardano-sl-chain.cabal

+7
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ library
5555
Pos.Chain.Delegation.Cede.Types
5656
Pos.Chain.Delegation.Class
5757
Pos.Chain.Delegation.Configuration
58+
Pos.Chain.Delegation.HeavyDlgIndex
59+
Pos.Chain.Delegation.LightDlgIndices
60+
Pos.Chain.Delegation.Payload
61+
Pos.Chain.Delegation.Proof
5862
Pos.Chain.Delegation.Types
5963

6064
-- Genesis
@@ -225,6 +229,9 @@ test-suite test
225229
Test.Pos.Chain.Block.Gen
226230
Test.Pos.Chain.Block.SafeCopySpec
227231
Test.Pos.Chain.Delegation.Arbitrary
232+
Test.Pos.Chain.Delegation.Bi
233+
Test.Pos.Chain.Delegation.Example
234+
Test.Pos.Chain.Delegation.Gen
228235
Test.Pos.Chain.Genesis.Dummy
229236
Test.Pos.Chain.Genesis.Example
230237
Test.Pos.Chain.Genesis.Gen

chain/src/Pos/Chain/Block/BHelpers.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ import Pos.Chain.Block.Union (Block, BlockHeader (..),
3030
BlockSignature (..), GenesisBlockchain, MainBlockchain,
3131
MainConsensusData (..), MainToSign (..),
3232
mainBlockEBDataProof)
33+
import Pos.Chain.Delegation (LightDlgIndices (..), checkDlgPayload)
3334
import Pos.Chain.Genesis as Genesis (Config (..))
3435
import Pos.Chain.Ssc (verifySscPayload)
3536
import Pos.Chain.Txp (checkTxPayload)
36-
import Pos.Core.Delegation (LightDlgIndices (..), checkDlgPayload)
3737
import Pos.Core.Slotting (SlotId (..))
3838
import Pos.Core.Ssc (checkSscPayload)
3939
import Pos.Core.Update (checkSoftwareVersion, checkUpdatePayload)

chain/src/Pos/Chain/Block/Constructors.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ import Pos.Chain.Block.Union (BlockHeader, BlockSignature (..),
2323
GenesisBlock, GenesisBlockHeader, HeaderHash, MainBlock,
2424
MainBlockHeader, MainConsensusData (..), MainToSign (..),
2525
headerHash)
26+
import Pos.Chain.Delegation (ProxySKBlockInfo)
2627
import Pos.Chain.Genesis (GenesisHash (..))
2728
import Pos.Core.Attributes (mkAttributes)
2829
import Pos.Core.Common (ChainDifficulty, HasDifficulty (..),
2930
SlotLeaders)
30-
import Pos.Core.Delegation (ProxySKBlockInfo)
3131
import Pos.Core.Slotting (EpochIndex, SlotId)
3232
import Pos.Core.Update (BlockVersion, SoftwareVersion)
3333
import Pos.Crypto (ProtocolMagic, SecretKey, SignTag (..), hash,

chain/src/Pos/Chain/Block/Main/Types.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ import qualified Formatting.Buildable as Buildable
2222

2323
import Pos.Binary.Class (Bi (..), Cons (..), Field (..),
2424
deriveSimpleBi, encodeListLen, enforceSize)
25+
import Pos.Chain.Delegation.Payload (DlgPayload)
2526
import Pos.Chain.Txp.TxPayload (TxPayload)
2627
import Pos.Chain.Txp.TxProof (TxProof)
2728
import Pos.Core.Attributes (Attributes, areAttributesKnown)
28-
import Pos.Core.Delegation (DlgPayload)
2929
import Pos.Core.Ssc (SscPayload, SscProof)
3030
import Pos.Core.Update (BlockVersion, SoftwareVersion, UpdatePayload,
3131
UpdateProof)

chain/src/Pos/Chain/Block/Union/Types.hs

+3-1
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,14 @@ import Pos.Chain.Block.Genesis.Types (GenesisBody (..),
128128
import Pos.Chain.Block.Main.Types (BlockBodyAttributes,
129129
BlockHeaderAttributes, MainBody (..), MainExtraBodyData,
130130
MainExtraHeaderData, MainProof (..))
131+
import Pos.Chain.Delegation.HeavyDlgIndex (ProxySigHeavy)
132+
import Pos.Chain.Delegation.LightDlgIndices (ProxySigLight)
133+
import Pos.Chain.Delegation.Payload (DlgPayload)
131134
import Pos.Chain.Txp.Tx (Tx)
132135
import Pos.Chain.Txp.TxPayload (TxPayload, txpTxs, txpWitnesses)
133136
import Pos.Chain.Txp.TxProof (mkTxProof)
134137
import Pos.Chain.Txp.TxWitness (TxWitness)
135138
import Pos.Core.Common (ChainDifficulty, HasDifficulty (..))
136-
import Pos.Core.Delegation (DlgPayload, ProxySigHeavy, ProxySigLight)
137139
import Pos.Core.Slotting (EpochOrSlot (..), HasEpochIndex (..),
138140
HasEpochOrSlot (..), SlotId (..), slotIdF)
139141
import Pos.Core.Ssc (SscPayload, mkSscProof)

chain/src/Pos/Chain/Delegation.hs

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
-- | Reexport module
22

33
module Pos.Chain.Delegation
4-
( module Pos.Chain.Delegation.Types
5-
, module Pos.Chain.Delegation.Configuration
6-
, module Pos.Chain.Delegation.Class
7-
, module Pos.Chain.Delegation.Cede
4+
( module X
85
) where
96

10-
import Pos.Chain.Delegation.Cede
11-
import Pos.Chain.Delegation.Class
12-
import Pos.Chain.Delegation.Configuration
13-
import Pos.Chain.Delegation.Types
7+
import Pos.Chain.Delegation.Cede as X
8+
import Pos.Chain.Delegation.Class as X
9+
import Pos.Chain.Delegation.Configuration as X
10+
import Pos.Chain.Delegation.HeavyDlgIndex as X
11+
import Pos.Chain.Delegation.LightDlgIndices as X
12+
import Pos.Chain.Delegation.Payload as X
13+
import Pos.Chain.Delegation.Proof as X
14+
import Pos.Chain.Delegation.Types as X

chain/src/Pos/Chain/Delegation/Cede/Class.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import Universum
1515
import Control.Monad.Trans (MonadTrans)
1616

1717
import Pos.Chain.Delegation.Cede.Types (DlgEdgeAction (..))
18+
import Pos.Chain.Delegation.HeavyDlgIndex (ProxySKHeavy)
1819
import Pos.Core (StakeholderId, addressHash)
19-
import Pos.Core.Delegation (ProxySKHeavy)
2020
import Pos.Crypto (PublicKey)
2121

2222

chain/src/Pos/Chain/Delegation/Cede/Types.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import Formatting (bprint, build, (%))
1818
import qualified Formatting.Buildable
1919
import Universum
2020

21+
import Pos.Chain.Delegation.HeavyDlgIndex (ProxySKHeavy)
2122
import Pos.Chain.Delegation.Types (isRevokePsk)
2223
import Pos.Core (StakeholderId, addressHash)
23-
import Pos.Core.Delegation (ProxySKHeavy)
2424
import Pos.Crypto (pskIssuerPk)
2525

2626
-- | Action on delegation database, used commonly. Generalizes

chain/src/Pos/Chain/Delegation/Class.hs

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ import Data.Time.Clock (UTCTime)
2626
import Serokell.Data.Memory.Units (Byte)
2727

2828
import Pos.Chain.Block.Union (HeaderHash)
29-
import Pos.Chain.Delegation.Types (DlgMemPool, ProxySKHeavy)
29+
import Pos.Chain.Delegation.HeavyDlgIndex (ProxySKHeavy)
30+
import Pos.Chain.Delegation.Types (DlgMemPool)
3031
import Pos.Util.Util (HasLens (..))
3132

3233
---------------------------------------------------------------------------

core/src/Pos/Core/Delegation/HeavyDlgIndex.hs renamed to chain/src/Pos/Chain/Delegation/HeavyDlgIndex.hs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{-# LANGUAGE RecordWildCards #-}
22

3-
module Pos.Core.Delegation.HeavyDlgIndex
3+
module Pos.Chain.Delegation.HeavyDlgIndex
44
( HeavyDlgIndex (..)
55
, ProxySigHeavy
66
, ProxySKHeavy
@@ -9,16 +9,18 @@ module Pos.Core.Delegation.HeavyDlgIndex
99

1010
import Universum
1111

12+
import Control.Monad.Except (MonadError)
1213
import qualified Data.Aeson as Aeson (FromJSON (..), ToJSON (..))
1314
import Data.SafeCopy (SafeCopy (..), contain, safeGet, safePut)
1415
import Formatting (bprint, build)
1516
import qualified Formatting.Buildable
1617
import Text.JSON.Canonical (FromJSON (..), Int54, JSValue (..),
17-
ReportSchemaErrors, ToJSON (..), fromJSField, mkObject)
18+
ToJSON (..), fromJSField, mkObject)
1819

1920
import Pos.Binary.Class (Bi (..))
2021
import Pos.Core.Slotting (EpochIndex)
2122
import Pos.Crypto (ProxySecretKey (..), ProxySignature, PublicKey)
23+
import Pos.Util.Json.Canonical (SchemaError)
2224

2325
-- | Witness for heavy delegation signature -- epoch in which
2426
-- certificate starts being active. It is needed for replay attack
@@ -65,7 +67,7 @@ instance Monad m => ToJSON m ProxySKHeavy where
6567
, ("cert", toJSON $ pskCert psk)
6668
]
6769

68-
instance ReportSchemaErrors m => FromJSON m ProxySKHeavy where
70+
instance MonadError SchemaError m => FromJSON m ProxySKHeavy where
6971
fromJSON obj = do
7072
pskOmega <- HeavyDlgIndex . fromIntegral @Int54 <$> fromJSField obj "omega"
7173
pskIssuerPk <- fromJSField obj "issuerPk"

core/src/Pos/Core/Delegation/LightDlgIndices.hs renamed to chain/src/Pos/Chain/Delegation/LightDlgIndices.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Pos.Core.Delegation.LightDlgIndices
1+
module Pos.Chain.Delegation.LightDlgIndices
22
( LightDlgIndices (..)
33
, ProxySigLight
44
, ProxySKLight

core/src/Pos/Core/Delegation/Payload.hs renamed to chain/src/Pos/Chain/Delegation/Payload.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Pos.Core.Delegation.Payload
1+
module Pos.Chain.Delegation.Payload
22
( DlgPayload (..)
33
, checkDlgPayload
44
) where
@@ -16,7 +16,7 @@ import Pos.Binary.Class (Bi (..))
1616
import Pos.Crypto (ProtocolMagic, ProxySecretKey (..),
1717
validateProxySecretKey)
1818

19-
import Pos.Core.Delegation.HeavyDlgIndex
19+
import Pos.Chain.Delegation.HeavyDlgIndex
2020

2121
-- | 'DlgPayload' is put into 'MainBlock' and is a set of heavyweight
2222
-- proxy signing keys. List of psk issuers should be unique also.

core/src/Pos/Core/Delegation/Proof.hs renamed to chain/src/Pos/Chain/Delegation/Proof.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
module Pos.Core.Delegation.Proof
1+
module Pos.Chain.Delegation.Proof
22
( DlgProof
33
, mkDlgProof
44
) where
55

66
import Pos.Crypto (Hash, hash)
77

8-
import Pos.Core.Delegation.Payload
8+
import Pos.Chain.Delegation.Payload
99

1010
-- | Proof of delegation payload.
1111
type DlgProof = Hash DlgPayload

chain/src/Pos/Chain/Delegation/Types.hs

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ module Pos.Chain.Delegation.Types
66
( DlgPayload (..)
77
, DlgUndo (..)
88
, DlgMemPool
9-
, module Pos.Core.Delegation
109
, isRevokePsk
1110

1211
, DlgBlock
@@ -21,9 +20,9 @@ import Serokell.Util.Text (listJson)
2120

2221
import Pos.Binary.Class (Cons (..), Field (..), deriveSimpleBi)
2322
import Pos.Chain.Block.Union (ComponentBlock (..))
23+
import Pos.Chain.Delegation.HeavyDlgIndex (ProxySKHeavy)
24+
import Pos.Chain.Delegation.Payload (DlgPayload (..))
2425
import Pos.Core (StakeholderId)
25-
import Pos.Core.Delegation (DlgPayload (..), ProxySKBlockInfo,
26-
ProxySKHeavy, checkDlgPayload)
2726
import Pos.Crypto (ProxySecretKey, PublicKey, isSelfSignedPsk)
2827

2928
-- | Undo for the delegation component.

chain/src/Pos/Chain/Genesis/Data.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ instance Monad m => ToJSON m GenesisData where
5151
, ("ftsSeed", toJSON gdFtsSeed)
5252
]
5353

54-
instance (Monad m, MonadError SchemaError m) => FromJSON m GenesisData where
54+
instance MonadError SchemaError m => FromJSON m GenesisData where
5555
fromJSON obj = do
5656
gdBootStakeholders <- fromJSField obj "bootStakeholders"
5757
gdHeavyDelegation <- fromJSField obj "heavyDelegation"

chain/src/Pos/Chain/Genesis/Delegation.hs

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ import qualified Data.Aeson as Aeson (FromJSON (..), ToJSON (..))
1515
import qualified Data.HashMap.Strict as HM
1616
import Formatting (build, sformat, (%))
1717
import Serokell.Util (allDistinct)
18-
import Text.JSON.Canonical (FromJSON (..), ReportSchemaErrors,
19-
ToJSON (..))
18+
import Text.JSON.Canonical (FromJSON (..), ToJSON (..))
2019

20+
import Pos.Chain.Delegation (ProxySKHeavy)
2121
import Pos.Core.Common (StakeholderId, addressHash)
22-
import Pos.Core.Delegation (ProxySKHeavy)
2322
import Pos.Crypto.Signing (ProxySecretKey (..), isSelfSignedPsk)
23+
import Pos.Util.Json.Canonical (SchemaError)
2424
import Pos.Util.Json.Parse (wrapConstructor)
2525
import Pos.Util.Util (toAesonError)
2626

@@ -39,7 +39,7 @@ newtype GenesisDelegation = UnsafeGenesisDelegation
3939
instance Monad m => ToJSON m GenesisDelegation where
4040
toJSON = toJSON . unGenesisDelegation
4141

42-
instance ReportSchemaErrors m => FromJSON m GenesisDelegation where
42+
instance MonadError SchemaError m => FromJSON m GenesisDelegation where
4343
fromJSON val = do
4444
psks <- fromJSON val
4545
wrapConstructor $ recreateGenesisDelegation psks

chain/src/Pos/Chain/Genesis/Generate.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ import Serokell.Util.Verify (VerificationRes (..), formatAllErrors,
3030
verifyGeneric)
3131

3232
import Pos.Binary.Class (asBinary, serialize')
33+
import Pos.Chain.Delegation (HeavyDlgIndex (..), ProxySKHeavy)
3334
import Pos.Core.Common (Address, Coin, IsBootstrapEraAddr (..),
3435
StakeholderId, addressHash, applyCoinPortionDown,
3536
coinToInteger, deriveFirstHDAddress,
3637
makePubKeyAddressBoot, mkCoin, sumCoins,
3738
unsafeIntegerToCoin)
38-
import Pos.Core.Delegation (HeavyDlgIndex (..), ProxySKHeavy)
3939
import Pos.Core.ProtocolConstants (ProtocolConstants, vssMaxTTL,
4040
vssMinTTL)
4141
import Pos.Core.Ssc (VssCertificate, VssCertificatesMap,

chain/test/Test/Pos/Chain/Block/Arbitrary.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ import Test.QuickCheck.Arbitrary.Generic (genericArbitrary,
3232
import Pos.Binary.Class (biSize)
3333
import Pos.Chain.Block (HeaderHash)
3434
import qualified Pos.Chain.Block as Block
35+
import qualified Pos.Chain.Delegation as Core
3536
import Pos.Chain.Genesis (GenesisHash (..))
3637
import Pos.Core (localSlotIndexMaxBound, localSlotIndexMinBound)
3738
import qualified Pos.Core as Core
3839
import Pos.Core.Attributes (areAttributesKnown)
39-
import qualified Pos.Core.Delegation as Core
4040
import Pos.Crypto (ProtocolMagic, PublicKey, SecretKey, createPsk,
4141
hash, toPublic)
4242

chain/test/Test/Pos/Chain/Block/Bi.hs

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,25 @@ import Pos.Chain.Block (BlockHeader (..), BlockHeaderAttributes,
1818
MainExtraBodyData (..), MainExtraHeaderData (..),
1919
MainProof (..), MainToSign (..), mkGenesisHeader,
2020
mkMainHeaderExplicit)
21+
import Pos.Chain.Delegation (DlgPayload (..))
2122
import Pos.Chain.Genesis (GenesisHash (..))
2223
import Pos.Core (EpochIndex (..))
2324
import Pos.Core.Attributes (mkAttributes)
24-
import Pos.Core.Delegation (DlgPayload (..))
2525
import Pos.Crypto (Hash, ProtocolMagic (..), SignTag (..),
2626
abstractHash, createPsk, hash, proxySign, sign, toPublic)
2727

2828
import Test.Pos.Binary.Helpers.GoldenRoundTrip (goldenTestBi,
2929
roundTripsBiBuildable, roundTripsBiShow)
3030
import Test.Pos.Chain.Block.Gen
31+
import Test.Pos.Chain.Delegation.Example (exampleLightDlgIndices,
32+
staticHeavyDlgIndexes, staticProxySKHeavys)
3133
import Test.Pos.Chain.Txp.Example (exampleTxPayload, exampleTxProof)
3234
import Test.Pos.Core.ExampleHelpers (exampleBlockVersion,
3335
exampleChainDifficulty, exampleEpochIndex,
34-
exampleLightDlgIndices, examplePublicKey,
35-
exampleSecretKey, exampleSecretKeys, exampleSlotId,
36-
exampleSlotLeaders, exampleSoftwareVersion,
36+
examplePublicKey, exampleSecretKey, exampleSecretKeys,
37+
exampleSlotId, exampleSlotLeaders, exampleSoftwareVersion,
3738
exampleSscPayload, exampleSscProof, exampleUpdatePayload,
38-
exampleUpdateProof, feedPM, feedPMEpochSlots,
39-
staticHeavyDlgIndexes, staticProxySKHeavys)
39+
exampleUpdateProof, feedPM, feedPMEpochSlots)
4040
import Test.Pos.Util.Golden (discoverGolden, eachOf)
4141
import Test.Pos.Util.Tripping (discoverRoundTrip)
4242

chain/test/Test/Pos/Chain/Block/BlockSpec.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ import Pos.Chain.Block (BlockHeader (..), BlockSignature (..),
2626
MainExtraHeaderData (..), MainToSign (..), headerHash,
2727
mkBodyProof, mkGenericHeader, mkGenesisHeader)
2828
import qualified Pos.Chain.Block as Block
29+
import Pos.Chain.Delegation (HeavyDlgIndex (..), LightDlgIndices (..))
2930
import Pos.Chain.Genesis (GenesisHash (..))
3031
import Pos.Core (EpochIndex (..), SlotId (..), difficultyL)
3132
import Pos.Core.Attributes (mkAttributes)
3233
import Pos.Core.Chrono (NewestFirst (..))
33-
import Pos.Core.Delegation (HeavyDlgIndex (..), LightDlgIndices (..))
3434
import Pos.Crypto (ProtocolMagic (..), ProxySecretKey (pskIssuerPk),
3535
SecretKey, SignTag (..), createPsk, proxySign, sign,
3636
toPublic)

chain/test/Test/Pos/Chain/Block/Gen.hs

+3-2
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ import Pos.Core (SlotCount)
3636
import Pos.Core.Attributes (mkAttributes)
3737
import Pos.Crypto (ProtocolMagic)
3838

39+
import Test.Pos.Chain.Delegation.Gen (genDlgPayload, genHeavyDlgIndex,
40+
genLightDlgIndices)
3941
import Test.Pos.Chain.Txp.Gen (genTxPayload, genTxProof)
4042
import Test.Pos.Core.Gen (genBlockVersion, genChainDifficulty,
41-
genDlgPayload, genEpochIndex, genHeavyDlgIndex,
42-
genLightDlgIndices, genSlotId, genSlotLeaders,
43+
genEpochIndex, genSlotId, genSlotLeaders,
4344
genSoftwareVersion, genSscPayload, genSscProof,
4445
genTextHash, genUpdatePayload, genUpdateProof)
4546
import Test.Pos.Crypto.Gen (genAbstractHash, genProxySignature,

chain/test/Test/Pos/Chain/Delegation/Arbitrary.hs

+13-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import Test.QuickCheck (Arbitrary (..), Gen, listOf)
1515
import Test.QuickCheck.Arbitrary.Generic (genericArbitrary,
1616
genericShrink)
1717

18-
import Pos.Chain.Delegation (DlgPayload (..), DlgUndo (..))
18+
import Pos.Chain.Delegation (DlgPayload (..), DlgUndo (..),
19+
HeavyDlgIndex (..), LightDlgIndices (..))
1920
import Pos.Core (EpochIndex)
20-
import Pos.Core.Delegation (HeavyDlgIndex (..))
2121
import Pos.Crypto (ProtocolMagic, ProxySecretKey (..), createPsk)
2222

2323
import Test.Pos.Core.Arbitrary ()
@@ -37,3 +37,14 @@ instance Arbitrary DlgPayload where
3737
instance Arbitrary DlgUndo where
3838
arbitrary = genericArbitrary
3939
shrink = genericShrink
40+
41+
instance Arbitrary HeavyDlgIndex where
42+
arbitrary = HeavyDlgIndex <$> arbitrary
43+
shrink = genericShrink
44+
45+
instance Arbitrary LightDlgIndices where
46+
arbitrary = do
47+
l <- arbitrary
48+
r <- arbitrary
49+
pure $ LightDlgIndices $ if r >= l then (l,r) else (r,l)
50+
shrink = genericShrink

0 commit comments

Comments
 (0)