@@ -5,8 +5,7 @@ module Api.Handlers (
55
66import Cardano.Api (serialiseToCBOR )
77import Cardano.Launcher.Node (nodeSocketFile )
8-
9- -- import Cardano.Wallet.Shelley.Launch.Cluster (RunningNode (RunningNode))
8+ import Test.Plutip.Tools.CardanoApi qualified as Tools
109
1110import Control.Concurrent.MVar (isEmptyMVar , putMVar , takeMVar )
1211import Control.Monad (unless )
@@ -21,14 +20,21 @@ import Data.Text.Encoding qualified as Text
2120import Data.Traversable (for )
2221import System.Directory (doesFileExist )
2322import System.FilePath (replaceFileName )
24- import Test.Plutip.Config (PlutipConfig (extraConfig ), chainIndexPort , relayNodeLogs )
23+ import Test.Plutip.Config (
24+ PlutipConfig (extraConfig ),
25+ chainIndexPort ,
26+ relayNodeLogs ,
27+ )
2528import Test.Plutip.Internal.BotPlutusInterface.Setup (keysDir )
26- import Test.Plutip.Internal.BotPlutusInterface.Wallet (BpiWallet (signKey ), addSomeWallet , cardanoMainnetAddress )
29+ import Test.Plutip.Internal.BotPlutusInterface.Wallet (
30+ BpiWallet (signKey ),
31+ addSomeWallet ,
32+ cardanoMainnetAddress ,
33+ )
2734import Test.Plutip.Internal.Cluster (RunningNode (RunningNode ))
28- import Test.Plutip.Internal.Cluster.Extra.Types (ExtraConfig (ExtraConfig ))
35+ import Test.Plutip.Internal.Cluster.Extra.Types (ExtraConfig (ExtraConfig , ecSlotLength ))
2936import Test.Plutip.Internal.LocalCluster (startCluster , stopCluster )
30- import Test.Plutip.Internal.Types (ClusterEnv (runningNode ))
31- import Test.Plutip.Tools.Cluster (awaitAddressFunded )
37+ import Test.Plutip.Internal.Types (ClusterEnv (plutipConf , runningNode ))
3238import Types (
3339 AppM ,
3440 ClusterStartupFailureReason (
@@ -97,7 +103,7 @@ startClusterHandler
97103 for keysToGenerate $ \ lovelaceAmounts -> do
98104 addSomeWallet (fromInteger . unLovelace <$> lovelaceAmounts)
99105 liftIO $ putStrLn " Waiting for wallets to be funded..."
100- awaitFunds wallets 2
106+ awaitFunds wallets (ecSlotLength $ extraConfig $ plutipConf env)
101107 pure (env, wallets)
102108 getNodeSocketFile (runningNode -> RunningNode conn _ _ _) = nodeSocketFile conn
103109 getNodeConfigFile =
@@ -108,13 +114,10 @@ startClusterHandler
108114 interpret = fmap (either ClusterStartupFailure id ) . runExceptT
109115
110116 -- waits for the last wallet to be funded
111- awaitFunds :: [BpiWallet ] -> Int -> ReaderT ClusterEnv IO ()
112117 awaitFunds ws delay = do
113- env <- ask
114- let lastWallet = last ws
115- liftIO $ do
116- putStrLn $ " Waiting till all wallets will be funded..."
117- awaitAddressFunded env delay (cardanoMainnetAddress lastWallet)
118+ let lastWalletPkh = cardanoMainnetAddress $ last ws
119+ liftIO $ putStrLn " Waiting till all wallets will be funded..."
120+ Tools. awaitAddressFunded lastWalletPkh delay
118121
119122stopClusterHandler :: StopClusterRequest -> AppM StopClusterResponse
120123stopClusterHandler StopClusterRequest = do
@@ -125,4 +128,4 @@ stopClusterHandler StopClusterRequest = do
125128 else do
126129 statusTVar <- liftIO $ takeMVar statusMVar
127130 liftIO $ stopCluster statusTVar
128- pure $ StopClusterSuccess
131+ pure StopClusterSuccess
0 commit comments