Skip to content

Commit

Permalink
Adapt the expected error to the actual message tested (#359)
Browse files Browse the repository at this point in the history
* Adapt the expected error to the actuall message

* Fix an off-by-one mistake (#360)

In PR #354, I introduced a mechanism that counts how many times a given
datum is present in the MockChain, and only deletes the entry in the
'mcstDatums' once that count reaches zero. I realized just now that I
wrote the logic in such a way as to delete the entry *after* the count
has reached zero and would be decremented to -1. This means that entries
are never deleted, which defeats the memory saving purpose that of the
whole operation... This commit rectifies this.
  • Loading branch information
carlhammann authored Nov 13, 2023
1 parent 1b85002 commit 582efbc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Cooked/MockChain/Direct.hs
Original file line number Diff line number Diff line change
Expand Up @@ -397,4 +397,4 @@ runTransactionValidation theParams cardanoTx rawModTx consumedData producedData
return (Ledger.CardanoEmulatorEraTx cardanoTx)
where
addMcstDatums stored new = Map.unionWith (\(d, n1) (_, n2) -> (d, n1 + n2)) stored (Map.map (,1) new)
removeMcstDatums = Map.differenceWith $ \(d, n) _ -> if n == 0 then Nothing else Just (d, n - 1)
removeMcstDatums = Map.differenceWith $ \(d, n) _ -> if n == 1 then Nothing else Just (d, n - 1)
2 changes: 1 addition & 1 deletion tests/Cooked/ReferenceScriptsSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ tests =
txSkelSigners = [wallet 1]
},
testCase "fail from transaction generation for mismatching reference scripts" $
let expectedError = GenerateTxErrorGeneral "txSkelInToTxIn: The hash of the reference script and the hash of the owner of the input mismatch. Are you using the correct TxOutRef on your TxSkelRedeemerForReferencedScript?"
let expectedError = GenerateTxErrorGeneral "txSkelInToTxIn: Wrong reference script hash. Are you using the correct TxOutRef on your TxSkelRedeemerForReferencedScript?"
in testFailsFrom
def
( \case
Expand Down

0 comments on commit 582efbc

Please sign in to comment.