<commit_before>{-# OPTIONS_GHC -fno-warn-orphans #-}

module Test.Pos.Chain.Update.Arbitrary
       ( genUpdatePayload
       , genUpdateVote
       , genUpdateProposal
       ) where

import           Universum

import qualified Data.HashMap.Strict as HM
import           Test.QuickCheck (Arbitrary (..), Gen, elements, frequency,
                     listOf, listOf1)
import           Test.QuickCheck.Arbitrary.Generic (genericArbitrary,
                     genericShrink)

import           Pos.Chain.Update (BlockVersion (..), BlockVersionData (..),
                     BlockVersionModifier, SoftforkRule (..), SystemTag (..),
                     UpdateData (..), UpdatePayload (..), UpdateProposal,
                     UpdateProposalToSign (..), UpdateVote (..),
                     VoteState (..), mkUpdateProposalWSign, mkUpdateVote)
import           Pos.Core.Attributes (mkAttributes)
import           Pos.Crypto (ProtocolMagic, fakeSigner)

import           Test.Pos.Core.Arbitrary ()
import           Test.Pos.Core.Arbitrary.Slotting ()
import           Test.Pos.Crypto.Arbitrary ()
import           Test.Pos.Crypto.Dummy (dummyProtocolMagic)


instance Arbitrary SoftforkRule where
    arbitrary = genericArbitrary
    shrink = genericShrink

instance Arbitrary BlockVersionData where
    arbitrary = genericArbitrary
    shrink = genericShrink

instance Arbitrary BlockVersion where
    arbitrary = genericArbitrary
    shrink = genericShrink

instance Arbitrary BlockVersionModifier where
    arbitrary = genericArbitrary
    shrink = genericShrink

instance Arbitrary SystemTag where
    arbitrary =
        elements . fmap SystemTag $
        (<>) <$> ["win", "linux", "mac"] <*> ["32", "64"]
    shrink = genericShrink

genUpdateVote :: ProtocolMagic -> Gen UpdateVote
genUpdateVote pm = mkUpdateVote pm <$> arbitrary <*> arbitrary <*> arbitrary
<commit_msg>[CBR-481/482] Add Arbitrary instances for ConsensusEra and ObftConsensusStrictness<commit_after>{-# OPTIONS_GHC -fno-warn-orphans #-}

module Test.Pos.Chain.Update.Arbitrary
       ( genUpdatePayload
       , genUpdateVote
       , genUpdateProposal
       ) where

import           Universum

import qualified Data.HashMap.Strict as HM
import           Test.QuickCheck (Arbitrary (..), Gen, elements, frequency,
                     listOf, listOf1)
import           Test.QuickCheck.Arbitrary.Generic (genericArbitrary,
                     genericShrink)

import           Pos.Chain.Update (BlockVersion (..), BlockVersionData (..),
                     BlockVersionModifier, ConsensusEra,
                     ObftConsensusStrictness, SoftforkRule (..),
                     SystemTag (..), UpdateData (..), UpdatePayload (..),
                     UpdateProposal, UpdateProposalToSign (..),
                     UpdateVote (..), VoteState (..), mkUpdateProposalWSign,
                     mkUpdateVote)
import           Pos.Core.Attributes (mkAttributes)
import           Pos.Crypto (ProtocolMagic, fakeSigner)

import           Test.Pos.Core.Arbitrary ()
import           Test.Pos.Core.Arbitrary.Slotting ()
import           Test.Pos.Crypto.Arbitrary ()
import           Test.Pos.Crypto.Dummy (dummyProtocolMagic)


instance Arbitrary SoftforkRule where
    arbitrary = genericArbitrary
    shrink = genericShrink

instance Arbitrary BlockVersionData where
    arbitrary = genericArbitrary
    shrink = genericShrink

instance Arbitrary BlockVersion where
    arbitrary = genericArbitrary
    shrink = genericShrink

instance Arbitrary BlockVersionModifier where
    arbitrary = genericArbitrary
    shrink = genericShrink

instance Arbitrary ConsensusEra where
    arbitrary = genericArbitrary
    shrink = genericShrink

instance Arbitrary ObftConsensusStrictness where
    arbitrary = genericArbitrary
    shrink = genericShrink

instance Arbitrary SystemTag where
    arbitrary =
        elements . fmap SystemTag $
        (<>) <$> ["win", "linux", "mac"] <*> ["32", "64"]
    shrink = genericShrink

genUpdateVote :: ProtocolMagic -> Gen UpdateVote
genUpdateVote pm = mkUpdateVote pm <$> arbitrary <*> arbitrary <*> arbitrary

{'fraction_non_alphanumeric': 0.08699878493317133, 'fraction_numerical': 0.003888213851761847, 'mean_word_length': 2.5544041450777204, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6262126', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1132, 'n_words': 259}