File tree Expand file tree Collapse file tree 4 files changed +53
-7
lines changed Expand file tree Collapse file tree 4 files changed +53
-7
lines changed Original file line number Diff line number Diff line change @@ -6,11 +6,11 @@ module Ctl.Internal.Contract.Hooks
66
77import Prelude
88
9- import Cardano.Types.PrivateKey (PrivateKey )
109import Cardano.Types.Transaction (Transaction )
1110import Data.Maybe (Maybe (Nothing))
1211import Effect (Effect )
1312import Effect.Exception (Error )
13+ import Node.Path (FilePath )
1414
1515type Hooks =
1616 { beforeSign :: Maybe (Effect Unit )
@@ -22,10 +22,7 @@ type Hooks =
2222 }
2323
2424type ClusterParameters =
25- { privateKeys :: Array PrivateKey
26- , nodeSocketPath :: String
27- , nodeConfigPath :: String
28- , privateKeysDirectory :: String
25+ { nodeSocketPath :: FilePath
2926 }
3027
3128emptyHooks :: Hooks
Original file line number Diff line number Diff line change @@ -77,8 +77,8 @@ import Ctl.Internal.Testnet.Utils
7777import Data.Array (concat , fromFoldable , zip ) as Array
7878import Data.Bifunctor (lmap )
7979import Data.Map (values ) as Map
80+ import Effect.Aff (apathize , try )
8081import Effect.Aff (bracket ) as Aff
81- import Effect.Aff (try )
8282import Effect.Exception (error )
8383import Effect.Ref (Ref )
8484import Effect.Ref (new , read , write ) as Ref
@@ -246,6 +246,11 @@ startTestnetContractEnv cfg distr cleanupRef = do
246246 { env, printLogs, clearLogs } <- makeClusterContractEnv cleanupRef cfg
247247 let env' = env { networkId = TestnetId }
248248 wallets <- mkWallets env' cluster
249+ apathize $ liftEffect $
250+ for_ env.hooks.onClusterStartup \onClusterStartup ->
251+ onClusterStartup
252+ { nodeSocketPath: (unwrap cluster).paths.nodeSocketPath
253+ }
249254 pure
250255 { cluster
251256 , env: env'
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ import Mote.Monad (mapTest)
2626import Mote.TestPlanM as Utils
2727import Test.Ctl.BalanceTx.ChangeGeneration as ChangeGeneration
2828import Test.Ctl.QueryM.AffInterface as QueryM.AffInterface
29+ import Test.Ctl.Testnet.ClusterParameters (runTest ) as ClusterParameters
2930import Test.Ctl.Testnet.Contract as Contract
3031import Test.Ctl.Testnet.Contract.Assert as Assert
3132import Test.Ctl.Testnet.Contract.Mnemonics as Mnemonics
@@ -63,7 +64,7 @@ main = interruptOnSignal SIGINT =<< launchAff do
6364 UtxoDistribution .suite
6465 testTestnetContracts config OgmiosMempool .suite
6566 runTestnetTestPlan config SameWallets .suite
66- -- FIXME: ClusterParameters.runTest
67+ ClusterParameters .runTest
6768
6869{-
6970configWithMaxExUnits :: PlutipConfig
Original file line number Diff line number Diff line change 1+ module Test.Ctl.Testnet.ClusterParameters
2+ ( mkSuite
3+ , runTest
4+ ) where
5+
6+ import Prelude
7+
8+ import Contract.Log (logDebug' )
9+ import Contract.Test (ContractTest , withWallets )
10+ import Contract.Test.Mote (TestPlanM )
11+ import Contract.Test.Testnet (defaultTestnetConfig , testTestnetContracts )
12+ import Ctl.Internal.Contract.Hooks (ClusterParameters )
13+ import Data.Maybe (Maybe (Just))
14+ import Effect.Aff (Aff )
15+ import Effect.Class (liftEffect )
16+ import Effect.Ref (Ref )
17+ import Effect.Ref as Ref
18+ import Mote (group , test )
19+ import Test.Spec.Assertions (shouldNotEqual )
20+
21+ runTest :: TestPlanM (Aff Unit ) Unit
22+ runTest = do
23+ clusterParamsRef <-
24+ liftEffect $ Ref .new
25+ { nodeSocketPath: mempty
26+ }
27+ testTestnetContracts
28+ defaultTestnetConfig
29+ { hooks = defaultTestnetConfig.hooks
30+ { onClusterStartup = Just (flip Ref .write clusterParamsRef)
31+ }
32+ }
33+ (mkSuite clusterParamsRef)
34+
35+ mkSuite :: Ref ClusterParameters -> TestPlanM ContractTest Unit
36+ mkSuite ref = do
37+ group " ClusterParameters" do
38+ test " Reading cardano-testnet cluster parameters" do
39+ withWallets unit \_ -> do
40+ clusterParams <- liftEffect $ Ref .read ref
41+ clusterParams.nodeSocketPath `shouldNotEqual` mempty
42+ logDebug' $ " ClusterParameters: " <> show clusterParams
43+ pure unit
You can’t perform that action at this time.
0 commit comments