From 541fabc94c80624264e1317c7e1d3a4f46321d90 Mon Sep 17 00:00:00 2001 From: Mikhail Lazarev Date: Thu, 18 Aug 2022 13:07:50 +0300 Subject: [PATCH] wip: adjustments: - wait longer before collecting final Values from wallets - node waiting ensures some slots are produced before proceed --- src/Test/Plutip/Contract.hs | 11 +++++++---- src/Test/Plutip/Internal/LocalCluster.hs | 13 ++++++++++--- test/Spec/Integration.hs | 7 +++++-- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/Test/Plutip/Contract.hs b/src/Test/Plutip/Contract.hs index 847fd252..fa296f60 100644 --- a/src/Test/Plutip/Contract.hs +++ b/src/Test/Plutip/Contract.hs @@ -276,9 +276,12 @@ maybeAddValuesCheck ioRes tws = valuesCheckCase = testCase "Values check" $ ioRes - >>= either (assertFailure . Text.unpack) (const $ pure ()) - . checkValues - . outcome + >>= \res -> do + ( either (assertFailure . Text.unpack) (const $ pure ()) + . checkValues + . outcome + ) + res checkValues o = left (Text.pack . show) o @@ -328,7 +331,7 @@ withContractAs walletIdx toContract = do -- contract that gets all the values present at the test wallets. valuesAtWallet :: Contract w s e (NonEmpty Value) valuesAtWallet = - void (waitNSlots 1) + void (waitNSlots 10) >> traverse (valueAt . (`pubKeyHashAddress` Nothing)) collectValuesPkhs -- run the test contract diff --git a/src/Test/Plutip/Internal/LocalCluster.hs b/src/Test/Plutip/Internal/LocalCluster.hs index cd460617..247a505d 100644 --- a/src/Test/Plutip/Internal/LocalCluster.hs +++ b/src/Test/Plutip/Internal/LocalCluster.hs @@ -10,6 +10,7 @@ module Test.Plutip.Internal.LocalCluster ( ), ) where +import Cardano.Api (ChainTip (ChainTip), SlotNo (SlotNo)) import Cardano.Api qualified as CAPI import Cardano.BM.Configuration.Model qualified as CM import Cardano.BM.Data.Severity qualified as Severity @@ -233,11 +234,17 @@ checkProcessesAvailable requiredProcesses = do waitForRelayNode :: Tracer IO TestsLog -> RunningNode -> IO () waitForRelayNode trCluster rn = do - liftIO $ recoverAll policy (const getTip) + liftIO $ recoverAll policy wait where - policy = constantDelay 500000 <> limitRetries 5 - getTip = trace >> void (Tools.queryTip rn) + policy = constantDelay 500000 <> limitRetries 50 + getTip = trace >> Tools.queryTip rn trace = traceWith trCluster WaitingRelayNode + wait _ = do + -- give some time for setup + (ChainTip (SlotNo ((> 5) -> True)) _ _) <- getTip + pure () + +-- putStrLn $ "TIP: " ++ show tip -- | Launch the chain index in a separate thread. launchChainIndex :: PlutipConfig -> RunningNode -> FilePath -> IO Int diff --git a/test/Spec/Integration.hs b/test/Spec/Integration.hs index eff83aef..bd233cbd 100644 --- a/test/Spec/Integration.hs +++ b/test/Spec/Integration.hs @@ -26,6 +26,7 @@ import Spec.TestContract.SimpleContracts ( payTo, ) import Spec.TestContract.ValidateTimeRange (failingTimeContract, successTimeContract) +import Test.Plutip.Config (WorkingDirectory (Fixed), clusterWorkingDir) import Test.Plutip.Contract ( TestWallets, ValueOrdering (VLt), @@ -69,7 +70,7 @@ import Test.Tasty (TestTree) test :: TestTree test = withConfiguredCluster - def + def {clusterWorkingDir = Fixed "/home/mike/dev/dev-tmp/plutip-cluster" True} "Basic integration: launch, add wallet, tx from wallet to wallet" $ [ -- Basic Succeed or Failed tests @@ -108,6 +109,7 @@ test = assertExecution "Pay from wallet to wallet" (initAda [100] <> initAndAssertAda [100, 13] 123) + -- (initAda [100] <> initAda [100, 13]) (withContract $ \[pkh1] -> payTo pkh1 10_000_000) [shouldSucceed] , assertExecution @@ -208,7 +210,8 @@ test = , errorSatisfies "Fail validation with 'I always fail'" errCheck ] ] - ++ testValueAssertionsOrderCorrectness + +-- ++ testValueAssertionsOrderCorrectness -- Tests for https://github.com/mlabs-haskell/plutip/issues/84 testValueAssertionsOrderCorrectness ::