From 5f3cedc4199079013e341f2fd3cb2e66f502ecaa Mon Sep 17 00:00:00 2001 From: Evgenii Akentev Date: Wed, 6 Jul 2022 15:58:28 +0500 Subject: [PATCH] Specify the oldStatus in waitForTxOutStatusChangeTest --- plutus-pab-executables/test/full/Plutus/PAB/CoreSpec.hs | 3 ++- plutus-pab/src/Plutus/PAB/Core.hs | 7 +++++++ plutus-pab/src/Plutus/PAB/Simulator.hs | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/plutus-pab-executables/test/full/Plutus/PAB/CoreSpec.hs b/plutus-pab-executables/test/full/Plutus/PAB/CoreSpec.hs index a2cc897691..103b09752f 100644 --- a/plutus-pab-executables/test/full/Plutus/PAB/CoreSpec.hs +++ b/plutus-pab-executables/test/full/Plutus/PAB/CoreSpec.hs @@ -262,7 +262,8 @@ waitForTxOutStatusChangeTest = runScenario $ do void $ Simulator.payToPaymentPublicKeyHash w1 pk1 (Ada.toValue Ledger.minAdaTxOut) Simulator.waitNSlots 1 - txOutStatus1'' <- Simulator.waitForTxOutStatusChange txOutRef1 + let oldStatus = (TentativelyConfirmed 8 TxValid (Spent $ getCardanoTxId tx2)) + txOutStatus1'' <- Simulator.waitForTxOutStatusChange' oldStatus txOutRef1 assertEqual "tx output 1 should be committed" (Committed TxValid (Spent $ getCardanoTxId tx2)) txOutStatus1'' diff --git a/plutus-pab/src/Plutus/PAB/Core.hs b/plutus-pab/src/Plutus/PAB/Core.hs index c9c4a0d7e7..6422002cc3 100644 --- a/plutus-pab/src/Plutus/PAB/Core.hs +++ b/plutus-pab/src/Plutus/PAB/Core.hs @@ -58,6 +58,7 @@ module Plutus.PAB.Core , waitForState , waitForTxStatusChange , waitForTxOutStatusChange + , waitForTxOutStatusChange' , activeEndpoints , waitForEndpoint , yieldedExportTxs @@ -520,6 +521,12 @@ waitForTxOutStatusChange t = do env <- asks @(PABEnvironment t env) blockchainEnv liftIO $ STM.atomically $ Instances.waitForTxOutStatusChange Unknown t env +-- | Wait until the status of the transaction changes from the given status +waitForTxOutStatusChange' :: forall t env. TxOutStatus -> TxOutRef -> PABAction t env TxOutStatus +waitForTxOutStatusChange' oldStatus t = do + env <- asks @(PABEnvironment t env) blockchainEnv + liftIO $ STM.atomically $ Instances.waitForTxOutStatusChange oldStatus t env + -- | The list of endpoints that are currently open activeEndpoints :: forall t env. ContractInstanceId -> PABAction t env (STM [OpenEndpoint]) activeEndpoints instanceId = do diff --git a/plutus-pab/src/Plutus/PAB/Simulator.hs b/plutus-pab/src/Plutus/PAB/Simulator.hs index eba787c5f5..2a199414a6 100644 --- a/plutus-pab/src/Plutus/PAB/Simulator.hs +++ b/plutus-pab/src/Plutus/PAB/Simulator.hs @@ -50,6 +50,7 @@ module Plutus.PAB.Simulator( , waitForEndpoint , waitForTxStatusChange , waitForTxOutStatusChange + , waitForTxOutStatusChange' , currentSlot , waitUntilSlot , waitNSlots @@ -405,6 +406,10 @@ waitForTxStatusChange = Core.waitForTxStatusChange waitForTxOutStatusChange :: forall t. TxOutRef -> Simulation t TxOutStatus waitForTxOutStatusChange = Core.waitForTxOutStatusChange +-- | Wait until the status of the transaction changes from the given status +waitForTxOutStatusChange' :: forall t. TxOutStatus -> TxOutRef -> Simulation t TxOutStatus +waitForTxOutStatusChange' = Core.waitForTxOutStatusChange' + -- | Wait until the endpoint becomes active. waitForEndpoint :: forall t. ContractInstanceId -> String -> Simulation t () waitForEndpoint = Core.waitForEndpoint