Skip to content

Commit ecefab7

Browse files
committed
wip: adjustments:
- wait longer before collecting final Values from wallets - node waiting ensures some slots are produced before proceed
1 parent bbc760e commit ecefab7

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

src/Test/Plutip/Contract.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,12 @@ maybeAddValuesCheck ioRes tws =
276276
valuesCheckCase =
277277
testCase "Values check" $
278278
ioRes
279-
>>= either (assertFailure . Text.unpack) (const $ pure ())
280-
. checkValues
281-
. outcome
279+
>>= \res -> do
280+
( either (assertFailure . Text.unpack) (const $ pure ())
281+
. checkValues
282+
. outcome
283+
)
284+
res
282285

283286
checkValues o =
284287
left (Text.pack . show) o
@@ -328,7 +331,7 @@ withContractAs walletIdx toContract = do
328331
-- contract that gets all the values present at the test wallets.
329332
valuesAtWallet :: Contract w s e (NonEmpty Value)
330333
valuesAtWallet =
331-
void (waitNSlots 1)
334+
void (waitNSlots 10)
332335
>> traverse (valueAt . (`pubKeyHashAddress` Nothing)) collectValuesPkhs
333336

334337
-- run the test contract

src/Test/Plutip/Internal/LocalCluster.hs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module Test.Plutip.Internal.LocalCluster (
1010
),
1111
) where
1212

13+
import Cardano.Api (ChainTip (ChainTip), SlotNo (SlotNo))
1314
import Cardano.Api qualified as CAPI
1415
import Cardano.BM.Configuration.Model qualified as CM
1516
import Cardano.BM.Data.Severity qualified as Severity
@@ -69,7 +70,7 @@ import Test.Plutip.Internal.Types (
6970
)
7071
import Test.Plutip.Tools.CardanoApi qualified as Tools
7172
import Text.Printf (printf)
72-
import UnliftIO.Concurrent (forkFinally, myThreadId, throwTo)
73+
import UnliftIO.Concurrent (forkFinally, myThreadId, throwTo, threadDelay)
7374
import UnliftIO.Exception (bracket, catchIO, finally)
7475
import UnliftIO.STM (TVar, atomically, newTVarIO, readTVar, retrySTM, writeTVar)
7576

@@ -232,12 +233,20 @@ checkProcessesAvailable requiredProcesses = do
232233
<> show (catMaybes results)
233234

234235
waitForRelayNode :: Tracer IO TestsLog -> RunningNode -> IO ()
235-
waitForRelayNode trCluster rn = do
236-
liftIO $ recoverAll policy (const getTip)
236+
waitForRelayNode trCluster rn =
237+
liftIO $ do
238+
recoverAll policy wait
239+
threadDelay 2_000_000
237240
where
238-
policy = constantDelay 500000 <> limitRetries 5
239-
getTip = trace >> void (Tools.queryTip rn)
241+
policy = constantDelay 500000 <> limitRetries 50
242+
getTip = trace >> Tools.queryTip rn
240243
trace = traceWith trCluster WaitingRelayNode
244+
wait _ = do
245+
-- give some time for setup
246+
(ChainTip (SlotNo ((> 5) -> True)) _ _) <- getTip
247+
pure ()
248+
249+
-- putStrLn $ "TIP: " ++ show tip
241250

242251
-- | Launch the chain index in a separate thread.
243252
launchChainIndex :: PlutipConfig -> RunningNode -> FilePath -> IO Int

test/Spec/Integration.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import Spec.TestContract.SimpleContracts (
2626
payTo,
2727
)
2828
import Spec.TestContract.ValidateTimeRange (failingTimeContract, successTimeContract)
29+
import Test.Plutip.Config (WorkingDirectory (Fixed), clusterWorkingDir)
2930
import Test.Plutip.Contract (
3031
TestWallets,
3132
ValueOrdering (VLt),
@@ -69,7 +70,7 @@ import Test.Tasty (TestTree)
6970
test :: TestTree
7071
test =
7172
withConfiguredCluster
72-
def
73+
def {clusterWorkingDir = Fixed "/home/mike/dev/dev-tmp/plutip-cluster" True}
7374
"Basic integration: launch, add wallet, tx from wallet to wallet"
7475
$ [
7576
-- Basic Succeed or Failed tests
@@ -108,6 +109,7 @@ test =
108109
assertExecution
109110
"Pay from wallet to wallet"
110111
(initAda [100] <> initAndAssertAda [100, 13] 123)
112+
-- (initAda [100] <> initAda [100, 13])
111113
(withContract $ \[pkh1] -> payTo pkh1 10_000_000)
112114
[shouldSucceed]
113115
, assertExecution

0 commit comments

Comments
 (0)