Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bot-plutus-interface.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ test-suite bot-plutus-interface-test
, plutus-pab
, plutus-tx
, plutus-tx-plugin
, pretty-diff
, prettyprinter
, QuickCheck
, quickcheck-instances
Expand Down
14 changes: 13 additions & 1 deletion test/Spec/BotPlutusInterface/Contract.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are "\n" being removed only from the expected?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual doesn't include any new lines. Of course we could add it, but it wouldn't have any effect.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming that this function will only be used to compare CLI commands.

++ "\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
Expand Down