Skip to content

Commit 1d35684

Browse files
committed
wb | compatibility mode (desc, chaindb, preset, composition, overlay, plutus.redeemer)
1 parent 6ee891c commit 1d35684

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

bench/cardano-profile/src/Cardano/Benchmarking/Profile.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ overlay overlaykeyMap profile =
179179
union = KeyMap.unionWithKey unionWithKey profileKeyMap overlaykeyMap
180180
in case Aeson.fromJSON (Aeson.Object union) of
181181
-- Add the overlay to the profile.
182-
(Aeson.Success profile') -> profile' {Types.overlay = Just overlaykeyMap}
182+
(Aeson.Success profile') -> profile' {Types.overlay = overlaykeyMap}
183183
(Aeson.Error str) -> error $ "Could not apply overlay: " ++ str
184184

185185
-- Right-biased merge of both JSON objects at all depths.

bench/cardano-profile/src/Cardano/Benchmarking/Profile/Types.hs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ module Cardano.Benchmarking.Profile.Types (
4949
--------------------------------------------------------------------------------
5050

5151
import Prelude
52+
import Data.Maybe (isJust)
5253
import GHC.Generics
5354
-- Package: aeson.
5455
import qualified Data.Aeson as Aeson
@@ -97,11 +98,15 @@ data Profile = Profile
9798

9899
-- TODO: Somehow merge these two!
99100
, preset :: Maybe String
100-
, overlay :: Maybe Aeson.Object
101+
, overlay :: Aeson.Object --TODO: Add `Maybe`, empty object for compatibility.
101102
}
102103
deriving (Eq, Show, Generic)
103104

104-
instance Aeson.ToJSON Profile
105+
instance Aeson.ToJSON Profile where
106+
toJSON = Aeson.genericToJSON
107+
-- TODO: Remove after removing `jq` profiles.
108+
-- To compare JSONs without "desc", "chaindb" and "preset" properties.
109+
(Aeson.defaultOptions {Aeson.omitNothingFields = True})
105110

106111
instance Aeson.FromJSON Profile where
107112
parseJSON = Aeson.genericParseJSON
@@ -202,7 +207,11 @@ data Composition = Composition
202207
}
203208
deriving (Eq, Show, Generic)
204209

205-
instance Aeson.ToJSON Composition
210+
instance Aeson.ToJSON Composition where
211+
toJSON = Aeson.genericToJSON
212+
-- TODO: Remove after removing `jq` profiles.
213+
-- To compare JSONs without the "with_chaindb_server" property.
214+
(Aeson.defaultOptions {Aeson.omitNothingFields = True})
206215

207216
instance Aeson.FromJSON Composition where
208217
parseJSON = Aeson.genericParseJSON
@@ -462,11 +471,13 @@ data Plutus = Plutus
462471

463472
instance Aeson.ToJSON Plutus where
464473
toJSON p =
465-
Aeson.object
474+
Aeson.object $
466475
[ "type" Aeson..= plutusType p
467476
, "script" Aeson..= plutusScript p
468-
, "redeemer" Aeson..= redeemer p
469477
]
478+
++
479+
-- TODO: Needed to replicate the old "jq" JSON output.
480+
["redeemer" Aeson..= redeemer p | isJust (redeemer p)]
470481

471482
instance Aeson.FromJSON Plutus where
472483
parseJSON =

bench/cardano-profile/test/Main.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ ciTestBage = Types.Profile {
452452
]
453453
}
454454
, Types.preset = mempty
455-
, Types.overlay = Just mempty
455+
, Types.overlay = mempty
456456
}
457457

458458
--------------------------------------------------------------------------------
@@ -714,6 +714,6 @@ testGroupOverlay = Tasty.testGroup
714714
(Types.effective_epochs $ Types.derived profile)
715715
-- The overlay used is added to the profile.
716716
assertEqual "New overlay"
717-
(Just overlay)
717+
overlay
718718
(Types.overlay profile)
719719
]

0 commit comments

Comments
 (0)