Skip to content

Commit

Permalink
[PASS] Adjust ModelSpec.txOutsOurs to account for script validation.
Browse files Browse the repository at this point in the history
We fix the testing function `txOutsOurs` to create the correct set of
outputs, based on whether or not the transaction is marked as having
failed script validation.

This commit fixes `ModelSpec` tests that use the test blockchain.
  • Loading branch information
jonathanknowles committed Jun 21, 2022
1 parent 461f068 commit c10c9f0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/core/test/unit/Cardano/Wallet/Primitive/ModelSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,8 +1011,8 @@ txOutsOurs
-> s
-> (Set (Tx, TxOut), s)
txOutsOurs txs =
runState $ Set.fromList <$>
forMaybe (foldMap (\tx -> zip (repeat tx) (outputs tx)) txs) pick
runState $ Set.fromList <$> forMaybe
(foldMap (\tx -> zip (repeat tx) (outputsToCreate tx)) txs) pick
where
pick :: (Tx, TxOut) -> State s (Maybe (Tx, TxOut))
pick (tx, out) = do
Expand All @@ -1023,6 +1023,13 @@ txOutsOurs txs =
forMaybe :: Monad m => [a] -> (a -> m (Maybe b)) -> m [b]
forMaybe xs = fmap catMaybes . for xs

outputsToCreate :: Tx -> [TxOut]
outputsToCreate tx
| txScriptInvalid tx =
F.toList (collateralOutput tx)
| otherwise =
outputs tx

{-------------------------------------------------------------------------------
Test Data
Expand Down

0 comments on commit c10c9f0

Please sign in to comment.