Skip to content

Commit 377b88a

Browse files
authored
Merge branch 'master' into post-collateral-handling
2 parents edfd4f2 + 2983fdb commit 377b88a

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

bot-plutus-interface.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ test-suite bot-plutus-interface-test
219219
, plutus-pab
220220
, plutus-tx
221221
, plutus-tx-plugin
222+
, pretty-diff
222223
, prettyprinter
223224
, QuickCheck
224225
, quickcheck-instances

src/PlutusConfig/Cardano/Api/Shelley.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import Config.Schema (
2020
naturalSpec,
2121
sectionsSpec,
2222
)
23+
import Control.Exception (IOException, catch)
2324
import Data.Aeson qualified as JSON
2425
import Data.ByteString.Lazy qualified as LazyByteString
2526
import Data.Default (def)
@@ -276,7 +277,7 @@ instance HasSpec ProtocolParameters where
276277
pure ProtocolParameters {..}
277278

278279
readProtocolParametersJSON :: FilePath -> IO (Either String ProtocolParameters)
279-
readProtocolParametersJSON fn = JSON.eitherDecode <$> LazyByteString.readFile fn
280+
readProtocolParametersJSON fn = (JSON.eitherDecode <$> LazyByteString.readFile fn) `catch` (\(e :: IOException) -> pure $ Left (show e))
280281

281282
writeProtocolParametersJSON :: FilePath -> ProtocolParameters -> IO ()
282283
writeProtocolParametersJSON fn params =

test/Spec/BotPlutusInterface/Contract.hs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ import Plutus.Contract (
4545
)
4646
import PlutusTx qualified
4747
import PlutusTx.Builtins (fromBuiltin)
48+
import Pretty.Diff (
49+
MultilineContext (FullContext),
50+
Wrapping (Wrap),
51+
)
52+
import Pretty.Diff qualified as Diff
4853
import Spec.MockContract (
4954
MockContractState (..),
5055
addr1,
@@ -903,7 +908,14 @@ assertCommandHistory state =
903908
assertCommandEqual :: String -> Text -> Text -> Assertion
904909
assertCommandEqual err expected actual
905910
| commandEqual expected actual = pure ()
906-
| otherwise = assertFailure $ err ++ "\nExpected:\n" ++ show expected ++ "\nGot:\n" ++ show actual
911+
| otherwise = assertFailure $ err ++ "\n" ++ prettyPrintDiff expected actual
912+
913+
prettyPrintDiff :: Text -> Text -> String
914+
prettyPrintDiff expected actual =
915+
"\nExpected:\n"
916+
++ Text.unpack (Diff.above (Wrap 80) FullContext (Text.replace "\n" " " expected) actual)
917+
++ "\nGot:\n"
918+
++ Text.unpack (Diff.below (Wrap 80) FullContext (Text.replace "\n" " " expected) actual)
907919

908920
{- | Checks if a command matches an expected command pattern
909921
Where a command pattern may use new lines in place of spaces, and use the wildcard `?` to match up to the next space

0 commit comments

Comments
 (0)