Skip to content

Commit 40d3afa

Browse files
palascarbolymer
andcommitted
Use H.forConcurrently_ in generateVoteFiles
Co-authored-by: Mateusz Galazyn <[email protected]>
1 parent a6c24a1 commit 40d3afa

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

cardano-testnet/cardano-testnet.cabal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ library
6767
, mtl
6868
, network
6969
, network-mux
70+
, monad-control
7071
, optparse-applicative-fork
7172
, ouroboros-network ^>= 0.14
7273
, ouroboros-network-api
@@ -230,6 +231,7 @@ test-suite cardano-testnet-test
230231
, http-conduit
231232
, lens-aeson
232233
, microlens
234+
, monad-control
233235
, mtl
234236
, process
235237
, regex-compat

cardano-testnet/src/Testnet/Process/Cli/DRep.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE DataKinds #-}
22
{-# LANGUAGE ExistentialQuantification #-}
3+
{-# LANGUAGE FlexibleContexts #-}
34
{-# LANGUAGE OverloadedStrings #-}
45
{-# LANGUAGE ScopedTypeVariables #-}
56
{-# LANGUAGE TypeApplications #-}

cardano-testnet/src/Testnet/Process/Cli/SPO.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{-# LANGUAGE DataKinds #-}
2+
{-# LANGUAGE FlexibleContexts #-}
23
{-# LANGUAGE GADTs #-}
34
{-# LANGUAGE NumericUnderscores #-}
45
{-# LANGUAGE ScopedTypeVariables #-}
@@ -25,6 +26,7 @@ import qualified Cardano.Ledger.UMap as L
2526
import Control.Monad
2627
import Control.Monad.Catch (MonadCatch)
2728
import Control.Monad.State.Strict as StateT
29+
import Control.Monad.Trans.Control (MonadBaseControl)
2830
import qualified Data.Aeson as Aeson
2931
import Data.Map.Strict (Map)
3032
import qualified Data.Map.Strict as Map
@@ -47,6 +49,7 @@ import Testnet.Types
4749
import Hedgehog
4850
import Hedgehog.Extras (ExecConfig)
4951
import qualified Hedgehog.Extras as H
52+
import Hedgehog.Extras.Test.Concurrent (forConcurrently)
5053

5154
checkStakePoolRegistered
5255
:: (MonadTest m, MonadCatch m, MonadIO m, HasCallStack)
@@ -408,7 +411,7 @@ registerSingleSpo identifier tap@(TmpAbsolutePath tempAbsPath') nodeConfigFile s
408411
-- Returns a list of generated @File VoteFile In@ representing the paths to
409412
-- the generated voting files.
410413
-- TODO: unify with DRep.generateVoteFiles
411-
generateVoteFiles :: (MonadTest m, MonadIO m, MonadCatch m, HasCallStack)
414+
generateVoteFiles :: (MonadTest m, MonadIO m, MonadCatch m, HasCallStack, MonadBaseControl IO m)
412415
=> ConwayEraOnwards era -- ^ The conway era onwards witness for the era in which the
413416
-- transaction will be constructed.
414417
-> H.ExecConfig -- ^ Specifies the CLI execution configuration.
@@ -424,7 +427,7 @@ generateVoteFiles :: (MonadTest m, MonadIO m, MonadCatch m, HasCallStack)
424427
-> m [File VoteFile In]
425428
generateVoteFiles ceo execConfig work prefix governanceActionTxId governanceActionIndex allVotes = do
426429
baseDir <- H.createDirectoryIfMissing $ work </> prefix
427-
forM (zip [(1 :: Integer)..] allVotes) $ \(idx, (spoKeys, vote)) -> do
430+
forConcurrently (zip [(1 :: Integer)..] allVotes) $ \(idx, (spoKeys, vote)) -> do
428431
let path = File (baseDir </> "vote-spo-" <> show idx)
429432
void $ execCli' execConfig
430433
[ eraToString $ toCardanoEra ceo, "governance", "vote", "create"

cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PredefinedAbstainDRep.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import Prelude
2828

2929
import Control.Monad (void)
3030
import Control.Monad.Catch (MonadCatch)
31+
import Control.Monad.Trans.Control (MonadBaseControl)
3132
import Data.Data (Typeable)
3233
import Data.String (fromString)
3334
import qualified Data.Text as Text
@@ -184,7 +185,7 @@ delegateToAutomaticDRep execConfig epochStateView sbe work prefix flag payingWal
184185
void $ waitForEpochs epochStateView (EpochInterval 1)
185186

186187
desiredPoolNumberProposalTest
187-
:: (HasCallStack, MonadTest m, MonadIO m, H.MonadAssertion m, MonadCatch m, Foldable t)
188+
:: (HasCallStack, MonadTest m, MonadIO m, H.MonadAssertion m, MonadCatch m, MonadBaseControl IO m, Foldable t)
188189
=> H.ExecConfig -- ^ Specifies the CLI execution configuration.
189190
-> EpochStateView -- ^ Current epoch state view for transaction building. It can be obtained
190191
-> ConwayEraOnwards ConwayEra -- ^ The ConwaysEraOnwards witness for the Conway era
@@ -317,7 +318,7 @@ type DefaultSPOVote = (String, Int)
317318
-- | Create and issue votes for (or against) a government proposal with default
318319
-- Delegate Representative (DReps created by 'cardanoTestnetDefault') and
319320
-- default Stake Pool Operatorsusing using @cardano-cli@.
320-
voteChangeProposal :: (Typeable era, MonadTest m, MonadIO m, MonadCatch m, H.MonadAssertion m)
321+
voteChangeProposal :: (Typeable era, MonadTest m, MonadIO m, MonadCatch m, H.MonadAssertion m, MonadBaseControl IO m)
321322
=> H.ExecConfig -- ^ Specifies the CLI execution configuration.
322323
-> EpochStateView -- ^ Current epoch state view for transaction building. It can be obtained
323324
-> ConwayEraOnwards era -- ^ The @ConwayEraOnwards@ witness for the current era.

cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/PredefinedNoConfidenceDRep.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{-# LANGUAGE DataKinds #-}
2+
{-# LANGUAGE FlexibleContexts #-}
23
{-# LANGUAGE NamedFieldPuns #-}
34
{-# LANGUAGE OverloadedStrings #-}
45
{-# LANGUAGE ScopedTypeVariables #-}
@@ -23,6 +24,7 @@ import Prelude
2324

2425
import Control.Monad (void)
2526
import Control.Monad.Catch (MonadCatch)
27+
import Control.Monad.Trans.Control (MonadBaseControl)
2628
import qualified Data.Map as Map
2729
import Data.String (fromString)
2830
import qualified Data.Text as Text
@@ -134,7 +136,7 @@ filterCommittee (AnyNewEpochState sbe newEpochState) =
134136
sbe
135137

136138
updateConstitutionalCommittee
137-
:: (MonadTest m, MonadIO m, H.MonadAssertion m, MonadCatch m, Foldable t)
139+
:: (MonadTest m, MonadIO m, H.MonadAssertion m, MonadCatch m, MonadBaseControl IO m, Foldable t, HasCallStack)
138140
=> H.ExecConfig
139141
-> EpochStateView
140142
-> ConwayEraOnwards ConwayEra
@@ -266,7 +268,7 @@ makeUpdateConstitutionalCommitteeProposal execConfig epochStateView ceo work pre
266268
-- Run a no confidence motion and check the result. Vote "yes" with 3 SPOs. Check the no
267269
-- confidence motion passes.
268270
testNoConfidenceProposal
269-
:: (MonadTest m, MonadIO m, H.MonadAssertion m, MonadCatch m, Foldable t, HasCallStack)
271+
:: (MonadTest m, MonadIO m, H.MonadAssertion m, MonadCatch m, MonadBaseControl IO m, Foldable t, HasCallStack)
270272
=> H.ExecConfig -- ^ Specifies the CLI execution configuration.
271273
-> EpochStateView -- ^ Current epoch state view for transaction building. It can be obtained
272274
-- using the 'getEpochStateView' function.
@@ -302,9 +304,8 @@ testNoConfidenceProposal execConfig epochStateView ceo work prefix
302304

303305
return thisProposal
304306

305-
306307
makeNoConfidenceProposal
307-
:: (H.MonadAssertion m, MonadTest m, MonadCatch m, MonadIO m)
308+
:: (H.MonadAssertion m, MonadTest m, MonadCatch m, MonadIO m, HasCallStack)
308309
=> H.ExecConfig
309310
-> EpochStateView
310311
-> ConwayEraOnwards ConwayEra

0 commit comments

Comments
 (0)