diff --git a/bot-plutus-interface.cabal b/bot-plutus-interface.cabal index 6ddbede9..ebb32af9 100644 --- a/bot-plutus-interface.cabal +++ b/bot-plutus-interface.cabal @@ -219,6 +219,7 @@ test-suite bot-plutus-interface-test , plutus-pab , plutus-tx , plutus-tx-plugin + , pretty-diff , prettyprinter , QuickCheck , quickcheck-instances diff --git a/test/Spec/BotPlutusInterface/Contract.hs b/test/Spec/BotPlutusInterface/Contract.hs index 4818fdd3..efcf4f32 100644 --- a/test/Spec/BotPlutusInterface/Contract.hs +++ b/test/Spec/BotPlutusInterface/Contract.hs @@ -45,6 +45,11 @@ import Plutus.Contract ( ) import PlutusTx qualified import PlutusTx.Builtins (fromBuiltin) +import Pretty.Diff ( + MultilineContext (FullContext), + Wrapping (Wrap), + ) +import Pretty.Diff qualified as Diff import Spec.MockContract ( MockContractState (..), addr1, @@ -903,7 +908,14 @@ assertCommandHistory state = assertCommandEqual :: String -> Text -> Text -> Assertion assertCommandEqual err expected actual | commandEqual expected actual = pure () - | otherwise = assertFailure $ err ++ "\nExpected:\n" ++ show expected ++ "\nGot:\n" ++ show actual + | otherwise = assertFailure $ err ++ "\n" ++ prettyPrintDiff expected actual + +prettyPrintDiff :: Text -> Text -> String +prettyPrintDiff expected actual = + "\nExpected:\n" + ++ Text.unpack (Diff.above (Wrap 80) FullContext (Text.replace "\n" " " expected) actual) + ++ "\nGot:\n" + ++ Text.unpack (Diff.below (Wrap 80) FullContext (Text.replace "\n" " " expected) actual) {- | Checks if a command matches an expected command pattern Where a command pattern may use new lines in place of spaces, and use the wildcard `?` to match up to the next space