From b3127f985810b8a86e3420698be42c9e79e93fc4 Mon Sep 17 00:00:00 2001 From: David Wilson <30732161+Anteproperispomenon@users.noreply.github.com> Date: Thu, 25 Aug 2022 11:26:48 -0400 Subject: [PATCH] Used `printf` for some error messages. --- test/Spec/BotPlutusInterface/Balance.hs | 33 ++++++++++--------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/test/Spec/BotPlutusInterface/Balance.hs b/test/Spec/BotPlutusInterface/Balance.hs index 4f4cc82..3648799 100644 --- a/test/Spec/BotPlutusInterface/Balance.hs +++ b/test/Spec/BotPlutusInterface/Balance.hs @@ -51,6 +51,7 @@ import Spec.MockContract ( ) import Test.Tasty (TestTree, testGroup) import Test.Tasty.HUnit (Assertion, assertBool, assertFailure, testCase, (@?=)) +import Text.Printf (printf) import Prelude {- | Tests for 'cardano-cli query utxo' result parsers @@ -239,13 +240,13 @@ dontAddChangeToDatum = do (balScrUtxos, balOtherUtxos) = partition isScrUtxo (txOutputs trx) assertBool ( "Expected UTxO not in output Tx." - <> "\nExpected UTxO: " + <> "\nExpected UTxO: \n" <> show scrTxOutExpected - <> "\nBalanced Script UTxOs: " + <> "\nBalanced Script UTxOs: \n" <> show balScrUtxos - <> "\nOther Balanced UTxOs: " + <> "\nOther Balanced UTxOs: \n" <> show balOtherUtxos - <> "\nUnbalanced UTxOs: " + <> "\nUnbalanced UTxOs: \n" <> show (txOutputs (unbalancedTx ^. OffChain.tx)) ) (scrTxOutExpected `elem` txOutputs trx) @@ -306,13 +307,13 @@ dontAddChangeToDatum2 = do -- is in the output. assertBool ( "Expected UTxO not in output Tx." - <> "\nExpected UTxO: " + <> "\nExpected UTxO: \n" <> show scrTxOutExpected - <> "\nBalanced Script UTxOs: " + <> "\nBalanced Script UTxOs: \n" <> show balScrUtxos - <> "\nOther Balanced UTxOs: " + <> "\nOther Balanced UTxOs: \n" <> show balOtherUtxos - <> "\nUnbalanced UTxOs: " + <> "\nUnbalanced UTxOs: \n" <> show (txOutputs (unbalancedTx ^. OffChain.tx)) ) (scrTxOutExpected `elem` txOutputs trx) @@ -331,23 +332,15 @@ dontAddChangeToDatum2 = do -- Check for ADA change assertBool ( "Other UTxOs do not contain expected ADA change." - <> "\nExpected Amount : " - <> show adaChange - <> " Lovelace" - <> "\nActual Amount : " - <> show (lovelaceInValue remainingValue) - <> " Lovelace" + <> printf "\nExpected Amount : %d Lovelace" adaChange + <> printf "\nActual Amount : %d Lovelace" (lovelaceInValue remainingValue) ) (adaChange == lovelaceInValue remainingValue) -- Check for Token change assertBool ( "Other UTxOs do not contain expected Token change." - <> "\nExpected Amount : " - <> show tokChange - <> " tokens" - <> "\nActual Amount : " - <> show (acValueOf tokenAsset remainingValue) - <> " tokens" + <> printf "\nExpected Amount : %d tokens" tokChange + <> printf "\nActual Amount : %d tokens" (acValueOf tokenAsset remainingValue) ) (tokChange == acValueOf tokenAsset remainingValue)