Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
Specify the oldStatus in waitForTxOutStatusChangeTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgenii Akentev committed Jul 6, 2022
1 parent 74ca796 commit 5f3cedc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion plutus-pab-executables/test/full/Plutus/PAB/CoreSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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''
Expand Down
7 changes: 7 additions & 0 deletions plutus-pab/src/Plutus/PAB/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ module Plutus.PAB.Core
, waitForState
, waitForTxStatusChange
, waitForTxOutStatusChange
, waitForTxOutStatusChange'
, activeEndpoints
, waitForEndpoint
, yieldedExportTxs
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions plutus-pab/src/Plutus/PAB/Simulator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module Plutus.PAB.Simulator(
, waitForEndpoint
, waitForTxStatusChange
, waitForTxOutStatusChange
, waitForTxOutStatusChange'
, currentSlot
, waitUntilSlot
, waitNSlots
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5f3cedc

Please sign in to comment.