Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
abailly-iohk committed Oct 14, 2021
1 parent c96d534 commit df918e1
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 35 deletions.
1 change: 1 addition & 0 deletions hydra-node/src/Hydra/Chain/Direct/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ observeAbortTx ValidatedTx{wits} st =
firstDatum = snd <$> datums

datums = Map.toList . unTxDats $ txdats wits

--

-- * Helpers
Expand Down
12 changes: 10 additions & 2 deletions hydra-node/src/Hydra/Chain/Direct/Wallet.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE PatternSynonyms #-}
{-# OPTIONS_GHC -Wno-unused-imports #-}

-- | Companion tiny-wallet for the direct chain component. This module provide
-- some useful utilities to tracking the wallet's UTXO, and accessing it
module Hydra.Chain.Direct.Wallet where
Expand Down Expand Up @@ -46,8 +47,15 @@ import Ouroboros.Consensus.Ledger.Query (Query (..))
import Ouroboros.Consensus.Network.NodeToClient (Codecs' (..))
import Ouroboros.Consensus.Shelley.Ledger.Block (ShelleyBlock (..), ShelleyHash (..))
import Ouroboros.Consensus.Shelley.Ledger.Query (BlockQuery (..))
import Ouroboros.Network.Block (Point (..), Tip (..), castPoint, blockPoint, genesisPoint,
pattern BlockPoint, pattern GenesisPoint)
import Ouroboros.Network.Block (
Point (..),
Tip (..),
blockPoint,
castPoint,
genesisPoint,
pattern BlockPoint,
pattern GenesisPoint,
)
import Ouroboros.Network.Magic (NetworkMagic (..))
import Ouroboros.Network.Mux (
MuxMode (..),
Expand Down
2 changes: 1 addition & 1 deletion hydra-node/src/Hydra/Network/Ouroboros.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Hydra.Network.Ouroboros (
import Hydra.Prelude

import Cardano.Tracing.OrphanInstances.Network ()
import Codec.CBOR.Term (Term,)
import Codec.CBOR.Term (Term)
import qualified Codec.CBOR.Term as CBOR
import Control.Concurrent.STM (
TChan,
Expand Down
6 changes: 3 additions & 3 deletions hydra-node/src/Hydra/Network/Ouroboros/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ instance Protocol (FireForget msg) where
data NobodyHasAgency st where
TokDone :: NobodyHasAgency 'StDone

exclusionLemma_ClientAndServerHaveAgency TokIdle tok = case tok of
exclusionLemma_NobodyAndClientHaveAgency TokDone tok = case tok of
exclusionLemma_NobodyAndServerHaveAgency TokDone tok = case tok of
exclusionLemma_ClientAndServerHaveAgency TokIdle tok = case tok of {}
exclusionLemma_NobodyAndClientHaveAgency TokDone tok = case tok of {}
exclusionLemma_NobodyAndServerHaveAgency TokDone tok = case tok of {}

deriving instance (Show msg) => Show (Message (FireForget msg) from to)

Expand Down
1 change: 1 addition & 0 deletions hydra-node/src/Hydra/Node.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ initEnvironment Options{me, parties} = do
case mKey of
Nothing -> fail $ "Failed to decode verification key from " <> p
Just key -> pure key

--

-- ** Create and run a hydra node
Expand Down
2 changes: 1 addition & 1 deletion hydra-node/test/Hydra/APISpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ spec = parallel $ do
specify "Utxo" $ \(specs, tmp) ->
withMaxSuccess 1 $ prop_validateToJSON @(Utxo CardanoTx) specs (tmp </> "Utxo")
specify "CardanoTx" $ \(specs, tmp) ->
withMaxSuccess 1 $prop_validateToJSON @CardanoTx specs (tmp </> "CardanoTx")
withMaxSuccess 1 $ prop_validateToJSON @CardanoTx specs (tmp </> "CardanoTx")

apiSpecificationSelector ::
Text -> SpecificationSelector
Expand Down
26 changes: 13 additions & 13 deletions hydra-node/test/Hydra/Chain/Direct/TxSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ module Hydra.Chain.Direct.TxSpec where
import Hydra.Prelude
import Test.Hydra.Prelude

import Test.Cardano.Ledger.Generic.Updaters hiding (vkey)
import Test.Cardano.Ledger.Generic.Proof
import Cardano.Binary (serialize)
import Cardano.Ledger.Alonzo (TxOut)
import Cardano.Ledger.Alonzo.Data (Data (Data), hashData)
import Cardano.Ledger.Alonzo.Language (Language (PlutusV1))
import Cardano.Ledger.Alonzo.PParams (PParams, ProtVer (..))
import Cardano.Ledger.Alonzo.Scripts (ExUnits(..))
import Cardano.Ledger.Alonzo.Scripts (ExUnits (..))
import Cardano.Ledger.Alonzo.Tools (ScriptFailure, evaluateTransactionExecutionUnits)
import Cardano.Ledger.Alonzo.Tx (ValidatedTx (ValidatedTx, body, wits))
import Cardano.Ledger.Alonzo.TxBody (TxOut (TxOut))
Expand Down Expand Up @@ -46,7 +44,9 @@ import Plutus.V1.Ledger.Api (PubKeyHash (PubKeyHash), toBuiltin, toBuiltinData,
import Shelley.Spec.Ledger.API (Coin (Coin), StrictMaybe (SJust), TxId (TxId), TxIn (TxIn), UTxO (UTxO))
import Test.Cardano.Ledger.Alonzo.PlutusScripts (defaultCostModel)
import Test.Cardano.Ledger.Alonzo.Serialisation.Generators ()
import Test.QuickCheck (Gen, NonEmptyList (NonEmpty), counterexample, listOf, oneof, (===), withMaxSuccess)
import Test.Cardano.Ledger.Generic.Proof
import Test.Cardano.Ledger.Generic.Updaters hiding (vkey)
import Test.QuickCheck (Gen, NonEmptyList (NonEmpty), counterexample, listOf, oneof, withMaxSuccess, (===))
import Test.QuickCheck.Instances ()

maxTxSize :: Int64
Expand Down Expand Up @@ -128,10 +128,10 @@ toTxOut (txIn, pkh) =
where
(policyId, _) = first currencyMPSHash (unAssetClass threadToken)
dependencies =
Initial.Dependencies
{ Initial.headScript = Head.validatorHash policyId
, Initial.commitScript = Commit.validatorHash
}
Initial.Dependencies
{ Initial.headScript = Head.validatorHash policyId
, Initial.commitScript = Commit.validatorHash
}

isImplemented :: PostChainTx tx -> OnChainHeadState -> Bool
isImplemented tx st =
Expand Down Expand Up @@ -161,11 +161,11 @@ pparams :: PParams Era
pparams =
newPParams
(Alonzo Standard)
[ Costmdls $ Map.singleton PlutusV1 $ fromJust defaultCostModel,
MaxValSize 1000000000,
MaxTxExUnits $ ExUnits 100000000 100000000,
MaxBlockExUnits $ ExUnits 100000000 100000000,
ProtocolVersion $ ProtVer 5 0
[ Costmdls $ Map.singleton PlutusV1 $ fromJust defaultCostModel
, MaxValSize 1000000000
, MaxTxExUnits $ ExUnits 100000000 100000000
, MaxBlockExUnits $ ExUnits 100000000 100000000
, ProtocolVersion $ ProtVer 5 0
]

-- | Extract NFT candidates. any single quantity assets not being ADA is a
Expand Down
2 changes: 1 addition & 1 deletion hydra-node/test/Test/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import Data.List (isInfixOf)
import Data.Typeable (cast)
import Hydra.Ledger.Simple (SimpleTx)
import Hydra.Node (HydraNodeLog)
import Test.Hydra.Prelude (failure, location)
import Test.HUnit.Lang (FailureReason (ExpectedButGot), HUnitFailure (HUnitFailure))
import Test.Hydra.Prelude (failure, location)

-- | Run given 'action' in 'IOSim' and fail on exceptions. This runner has
-- special support for detecting and re-throwing 'HUnitFailure' exceptions.
Expand Down
9 changes: 4 additions & 5 deletions hydra-plutus/exe/inspect-script/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Main where

import Hydra.Prelude

import Cardano.Api (scriptDataToJson, ScriptDataJsonSchema(ScriptDataJsonDetailedSchema), serialiseToTextEnvelope)
import Cardano.Api (ScriptDataJsonSchema (ScriptDataJsonDetailedSchema), scriptDataToJson, serialiseToTextEnvelope)
import Cardano.Api.Shelley (fromPlutusData)
import qualified Data.Aeson as Aeson
import qualified Data.ByteString.Lazy as BL
Expand All @@ -11,11 +11,11 @@ import Hydra.Contract.Commit as Commit
import Hydra.Contract.Head as Head
import Hydra.Contract.Initial as Initial
import Ledger (Datum (..), datumHash)
import Ledger.Scripts (Script, toCardanoApiScript)
import Ledger.Value
import Ledger.Scripts (toCardanoApiScript, Script)
import Plutus.V1.Ledger.Api (dataToBuiltinData, toData, Data)
import Plutus.V1.Ledger.Api (Data, dataToBuiltinData, toData)

-- | Serialise Hydra scripts to files for submission through cardano-cli
-- | Serialise Hydra scripts to files for submission through cardano-cli.
-- This small utility is useful to manually construct transactions payload for Hydra on-chain
-- protocol. It takes as arguments the currency and token name to be used as unique Head
-- identifier, both of which can simply be a UTXO in the network that's consumed by the
Expand All @@ -41,7 +41,6 @@ main = do
putTextLn "Datum hashes:"
forM_ datums $ \(aDatum, datumName) ->
putTextLn $ toText $ datumName <> ": " <> show (datumHash $ Datum $ dataToBuiltinData $ aDatum)

where
writeScripts :: [(Script, String)] -> IO ()
writeScripts plutus =
Expand Down
2 changes: 1 addition & 1 deletion hydra-plutus/src/Hydra/PAB.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Control.Lens (makeClassyPrisms)
import Data.Aeson (Options (..), defaultOptions, genericToJSON)
import qualified Data.List.NonEmpty as NonEmpty
import qualified Data.Map as Map
import Data.OpenApi.Internal.Schema (ToSchema)
import Data.Text.Prettyprint.Doc (Pretty (..), viaShow)
import qualified Hydra.Contract.Commit as Commit
import qualified Hydra.Contract.Head as Head
Expand Down Expand Up @@ -50,7 +51,6 @@ import qualified Plutus.Contract.StateMachine as SM
import Plutus.Contract.Types (Promise (..))
import qualified Plutus.Contracts.Currency as Currency
import Plutus.PAB.Effects.Contract.Builtin (HasDefinitions (..), SomeBuiltin (..))
import Data.OpenApi.Internal.Schema(ToSchema)

-- | Hard-coded port used between hydra-node and the PAB server.
pabPort :: Int
Expand Down
5 changes: 2 additions & 3 deletions hydra-plutus/test/Hydra/ContractModelTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import Ledger (pubKeyHash)
import Ledger.Ada as Ada
import Ledger.Typed.Scripts (MintingPolicy)
import Plutus.Contract (Contract)
import Plutus.Contract.Test (Wallet(..), walletPubKey)
import Wallet.Emulator.Wallet(knownWallet)
import Plutus.Contract.Test (Wallet (..), walletPubKey)
import Plutus.Contract.Test.ContractModel
import Plutus.Contract.Types (ContractError)
import Test.QuickCheck (Property, Testable (property))
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.QuickCheck (testProperty)
import Wallet.Emulator.Wallet (knownWallet)

w1, w2, w3 :: Wallet
[w1, w2, w3] = map knownWallet [1, 2, 3]
Expand All @@ -41,7 +41,6 @@ instance ContractModel HydraModel where
deriving (Eq, Show)

data ContractInstanceKey HydraModel w schema err where
-- | No party in a Hydra Head is privileged
HeadParty :: Wallet -> ContractInstanceKey HydraModel [OnChain.State] OffChain.Schema ContractError

arbitraryAction _ = pure (Init w1)
Expand Down
2 changes: 1 addition & 1 deletion hydra-plutus/test/Hydra/ContractTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import Plutus.Contract.Test (
import Plutus.Trace.Emulator.Types (walletInstanceTag)
import PlutusTx.Monoid (inv)
import Test.Tasty (TestTree, testGroup)
import Wallet.Emulator.Wallet (knownWallet)
import Wallet.Types (ContractError (..))
import Wallet.Emulator.Wallet(knownWallet)

import qualified Control.Monad.Freer.Extras.Log as Trace
import qualified Data.Map.Strict as Map
Expand Down
2 changes: 1 addition & 1 deletion hydra-tui/src/Hydra/TUI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ draw s =
Nothing -> emptyWidget
Just me -> str "Address " <+> withAttr own (txt $ ellipsize 40 $ encodeAddress (getAddress me))

ellipsize n t = Text.take (n -2) t <> ".."
ellipsize n t = Text.take (n - 2) t <> ".."

nodeStatus =
case s ^. clientStateL of
Expand Down
5 changes: 3 additions & 2 deletions hydra-tui/test/Hydra/TUISpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ import Hydra.Prelude
import Test.Hydra.Prelude

spec :: Spec
spec = parallel $
it "exists" True
spec =
parallel $
it "exists" True
2 changes: 1 addition & 1 deletion local-cluster/src/CardanoCluster.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import CardanoNode (
withCardanoNode,
)
import Control.Tracer (Tracer, traceWith)
import Test.Network.Ports (randomUnusedTCPPorts)
import System.Directory (copyFile, createDirectoryIfMissing)
import System.FilePath ((</>))
import System.Posix.Files (
ownerReadMode,
setFileMode,
)
import Test.Network.Ports (randomUnusedTCPPorts)

data RunningCluster = RunningCluster ClusterConfig [RunningNode]

Expand Down

0 comments on commit df918e1

Please sign in to comment.