From be95c75a0a024a0e73e142cc704edea7ff41f1c7 Mon Sep 17 00:00:00 2001 From: Sebastian Nagel Date: Wed, 30 Nov 2022 10:00:04 +0100 Subject: [PATCH] Add a manual Eq QueryException instance This is to work around a missing Eq AcquiringFailure, see https://github.com/input-output-hk/cardano-node/pull/4683 --- hydra-node/src/Hydra/Chain/CardanoClient.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hydra-node/src/Hydra/Chain/CardanoClient.hs b/hydra-node/src/Hydra/Chain/CardanoClient.hs index 1061b980d9d..f058b253e22 100644 --- a/hydra-node/src/Hydra/Chain/CardanoClient.hs +++ b/hydra-node/src/Hydra/Chain/CardanoClient.hs @@ -20,7 +20,16 @@ type NodeSocket = FilePath data QueryException = QueryAcquireException AcquiringFailure | QueryEraMismatchException EraMismatch - deriving (Eq, Show) + deriving (Show) + +instance Eq QueryException where + a == b = case (a, b) of + (QueryAcquireException af1, QueryAcquireException af2) -> case (af1, af2) of + (AFPointTooOld, AFPointTooOld) -> True + (AFPointNotOnChain, AFPointNotOnChain) -> True + _ -> False + (QueryEraMismatchException em1, QueryEraMismatchException em2) -> em1 == em2 + _ -> False instance Exception QueryException