Skip to content

Commit

Permalink
Merge #4216
Browse files Browse the repository at this point in the history
4216: Improve json fail message for TraceNodeIsLeader r=Jasagredo a=Jasagredo

This is only used in tests, and not even seen as we use parseMaybe.

Co-authored-by: Javier Sagredo <jasataco@gmail.com>
  • Loading branch information
iohk-bors[bot] and jasagredo authored Jul 25, 2022
2 parents f7d574e + 5af90d0 commit 753d91b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cardano-testnet/src/Test/Assert.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Data.Functor ((<$>))
import Data.Int (Int)
import Data.Maybe (Maybe (..), mapMaybe)
import Data.Ord (Ord (..))
import Data.Semigroup ((<>))
import Data.Text (Text)
import Data.Word (Word8)
import GHC.Stack (HasCallStack)
Expand Down Expand Up @@ -89,7 +90,7 @@ instance FromJSON TraceNodeIsLeader where
k <- v .: "val" >>= (.: "kind")
if k == "TraceNodeIsLeader"
then TraceNodeIsLeader k <$> (v .: "val" >>= (.: "slot"))
else fail "Not the right kind"
else fail $ "Expected kind was TraceNodeIsLeader, found " <> show k <> "instead"

instance FromJSON Kind where
parseJSON = Aeson.withObject "Kind" $ \v ->
Expand Down

0 comments on commit 753d91b

Please sign in to comment.