Skip to content

Commit

Permalink
Create workspace only once
Browse files Browse the repository at this point in the history
  • Loading branch information
smelc committed Feb 7, 2024
1 parent 8066d30 commit 164d8a1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cardano-cli/test/cardano-cli-test/Test/Cli/CreateTestnetData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Control.Monad.IO.Class
import Data.Aeson (FromJSON, ToJSON)
import qualified Data.Aeson as A
import qualified Data.ByteString.Lazy as LBS
import Data.IORef (atomicModifyIORef, newIORef)
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as M
import Data.Text (Text)
Expand Down Expand Up @@ -43,8 +44,10 @@ hprop_create_testnet_data_minimal =
]
success

-- Execute this test with:
-- @cabal test cardano-cli-test --test-options '-p "/create testnet data create nonegative supply/"'@
hprop_create_testnet_data_create_nonegative_supply :: Property
hprop_create_testnet_data_create_nonegative_supply = do
hprop_create_testnet_data_create_nonegative_supply = H.property $ do
-- FIXME rewrite this as a property test
let supplyValues =
[ -- (total supply, delegated supply)
Expand All @@ -53,9 +56,12 @@ hprop_create_testnet_data_create_nonegative_supply = do
, (1_000_000_000, 2_000_000_000)
] :: [(Int, Int)]

propertyOnce $ forM_ supplyValues $ \(totalSupply, delegatedSupply) ->
moduleWorkspace "tmp" $ \tempDir -> do
let outputDir = tempDir </> "out"
ref <- liftIO $ newIORef (0 :: Int)

moduleWorkspace "tmp" $ \tempDir -> do
forM_ supplyValues $ \(totalSupply, delegatedSupply) -> do
suffix <- liftIO $ atomicModifyIORef ref (\x -> (x + 1, x))
let outputDir = tempDir </> "out" <> show suffix

H.noteM_ $ execCardanoCLI
["conway", "genesis", "create-testnet-data"
Expand Down

0 comments on commit 164d8a1

Please sign in to comment.