Skip to content

Commit

Permalink
Format code using script
Browse files Browse the repository at this point in the history
  • Loading branch information
abailly committed Oct 25, 2024
1 parent 2f64542 commit 2249b54
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 243 deletions.
10 changes: 6 additions & 4 deletions ouroboros-consensus-cardano/app/GenHeader/Parsers.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module GenHeader.Parsers where

import Cardano.Tools.Headers (Options (..))
import Data.Version (showVersion)
import Options.Applicative (Parser, ParserInfo, auto, command, execParser, help, helper, hsubparser, info, long, metavar, option, progDesc, short, (<**>))
import Paths_ouroboros_consensus_cardano (version)
import Cardano.Tools.Headers (Options (..))
import Data.Version (showVersion)
import Options.Applicative (Parser, ParserInfo, auto, command,
execParser, help, helper, hsubparser, info, long, metavar,
option, progDesc, short, (<**>))
import Paths_ouroboros_consensus_cardano (version)

parseOptions :: IO Options
parseOptions = execParser argsParser
Expand Down
8 changes: 4 additions & 4 deletions ouroboros-consensus-cardano/app/gen-header.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
-- | This tool generates valid and invalid Cardano headers.
module Main (main) where

import Cardano.Crypto.Init (cryptoInit)
import Cardano.Tools.Headers (run)
import GenHeader.Parsers (parseOptions)
import Main.Utf8 (withUtf8)
import Cardano.Crypto.Init (cryptoInit)
import Cardano.Tools.Headers (run)
import GenHeader.Parsers (parseOptions)
import Main.Utf8 (withUtf8)

main :: IO ()
main = withUtf8 $ do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,40 @@
-- | Tooling to generate and validate (Praos) headers.
module Cardano.Tools.Headers where

import Cardano.Crypto.DSIGN (deriveVerKeyDSIGN)
import Cardano.Crypto.Hash (Blake2b_256, hashToBytes)
import Cardano.Crypto.VRF (VRFAlgorithm (deriveVerKeyVRF, hashVerKeyVRF))
import Cardano.Ledger.Api (ConwayEra, StandardCrypto, VRF)
import Cardano.Ledger.BaseTypes (BoundedRational (boundRational), PositiveUnitInterval, mkActiveSlotCoeff)
import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Compactible (toCompact)
import Cardano.Ledger.Keys (VKey (..), hashKey)
import Cardano.Ledger.PoolDistr (IndividualPoolStake (..))
import Cardano.Prelude (ExitCode (..), exitWith, forM_, hPutStrLn, stderr)
import Control.Monad.Except (runExcept)
import Cardano.Crypto.DSIGN (deriveVerKeyDSIGN)
import Cardano.Crypto.Hash (Blake2b_256, hashToBytes)
import Cardano.Crypto.VRF
(VRFAlgorithm (deriveVerKeyVRF, hashVerKeyVRF))
import Cardano.Ledger.Api (ConwayEra, StandardCrypto, VRF)
import Cardano.Ledger.BaseTypes (BoundedRational (boundRational),
PositiveUnitInterval, mkActiveSlotCoeff)
import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Compactible (toCompact)
import Cardano.Ledger.Keys (VKey (..), hashKey)
import Cardano.Ledger.PoolDistr (IndividualPoolStake (..))
import Cardano.Prelude (ExitCode (..), exitWith, forM_, hPutStrLn,
stderr)
import Control.Monad.Except (runExcept)
import qualified Data.Aeson as Json
import qualified Data.ByteString.Base16 as Hex
import qualified Data.ByteString.Lazy as LBS
import qualified Data.Map as Map
import Data.Maybe (fromJust)
import Data.Text (unpack)
import Data.Text.Encoding (decodeUtf8)
import Debug.Trace (trace)
import Ouroboros.Consensus.Block (validateView)
import Ouroboros.Consensus.Protocol.Praos (
Praos,
doValidateKESSignature,
doValidateVRFSignature,
)
import Data.Maybe (fromJust)
import Data.Text (unpack)
import Data.Text.Encoding (decodeUtf8)
import Debug.Trace (trace)
import Ouroboros.Consensus.Block (validateView)
import Ouroboros.Consensus.Protocol.Praos (Praos,
doValidateKESSignature, doValidateVRFSignature)
import qualified Ouroboros.Consensus.Protocol.Praos.Views as Views
import Ouroboros.Consensus.Shelley.HFEras ()
import Ouroboros.Consensus.Shelley.Ledger (
ShelleyBlock,
mkShelleyHeader,
)
import Ouroboros.Consensus.Shelley.Protocol.Praos ()
import Test.Ouroboros.Consensus.Protocol.Praos.Header (
GeneratorContext (..),
MutatedHeader (..),
Mutation (..),
Sample (..),
expectedError,
generateSamples,
header,
mutation,
)
import Ouroboros.Consensus.Shelley.HFEras ()
import Ouroboros.Consensus.Shelley.Ledger (ShelleyBlock,
mkShelleyHeader)
import Ouroboros.Consensus.Shelley.Protocol.Praos ()
import Test.Ouroboros.Consensus.Protocol.Praos.Header
(GeneratorContext (..), MutatedHeader (..), Mutation (..),
Sample (..), expectedError, generateSamples, header,
mutation)

type ConwayBlock = ShelleyBlock (Praos StandardCrypto) (ConwayEra StandardCrypto)

Expand Down
8 changes: 3 additions & 5 deletions ouroboros-consensus-cardano/test/shelley-test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import qualified Test.Consensus.Shelley.Coherence (tests)
import qualified Test.Consensus.Shelley.Golden (tests)
import qualified Test.Consensus.Shelley.Serialisation (tests)
import qualified Test.Consensus.Shelley.SupportedNetworkProtocolVersion (tests)
import Test.Tasty
import Test.Tasty
import qualified Test.ThreadNet.Shelley (tests)
import Test.Util.TestEnv (
defaultMainWithTestEnv,
defaultTestEnvConfig,
)
import Test.Util.TestEnv (defaultMainWithTestEnv,
defaultTestEnvConfig)

main :: IO ()
main = defaultMainWithTestEnv defaultTestEnvConfig tests
Expand Down
14 changes: 7 additions & 7 deletions ouroboros-consensus-cardano/test/tools-test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ module Main (main) where

import qualified Cardano.Tools.DBAnalyser.Block.Cardano as Cardano
import qualified Cardano.Tools.DBAnalyser.Run as DBAnalyser
import Cardano.Tools.DBAnalyser.Types
import Cardano.Tools.DBAnalyser.Types
import qualified Cardano.Tools.DBImmutaliser.Run as DBImmutaliser
import qualified Cardano.Tools.DBSynthesizer.Run as DBSynthesizer
import Cardano.Tools.DBSynthesizer.Types
import Ouroboros.Consensus.Block
import Ouroboros.Consensus.Cardano.Block
import Cardano.Tools.DBSynthesizer.Types
import Ouroboros.Consensus.Block
import Ouroboros.Consensus.Cardano.Block
import qualified Test.Cardano.Tools.Headers
import Test.Tasty
import Test.Tasty.HUnit
import Test.Util.TestEnv
import Test.Tasty
import Test.Tasty.HUnit
import Test.Util.TestEnv

nodeConfig, chainDB :: FilePath
nodeConfig = "test/tools-test/disk/config/config.json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
module Test.Cardano.Tools.Headers (tests) where

import Cardano.Tools.Headers (ValidationResult (..), validate)
import Cardano.Tools.Headers (ValidationResult (..), validate)
import qualified Data.Aeson as Json
import Data.Function ((&))
import Data.Function ((&))
import qualified Data.Text.Lazy as LT
import Data.Text.Lazy.Encoding (decodeUtf8)
import Test.Ouroboros.Consensus.Protocol.Praos.Header (
genContext,
genMutatedHeader,
genSample,
)
import Test.QuickCheck (
Property,
counterexample,
forAll,
forAllBlind,
label,
property,
(===),
)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.QuickCheck (testProperty)
import Data.Text.Lazy.Encoding (decodeUtf8)
import Test.Ouroboros.Consensus.Protocol.Praos.Header (genContext,
genMutatedHeader, genSample)
import Test.QuickCheck (Property, counterexample, forAll, forAllBlind,
label, property, (===))
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.QuickCheck (testProperty)

tests :: TestTree
tests =
Expand Down
Loading

0 comments on commit 2249b54

Please sign in to comment.