From 5353e3861f1230596f5d5811186f0c5a8d3c922e Mon Sep 17 00:00:00 2001 From: John Ky Date: Sat, 6 Jan 2024 15:26:26 +1100 Subject: [PATCH] Switch to use lenses --- cardano-testnet/cardano-testnet.cabal | 2 ++ .../src/Testnet/Components/Configuration.hs | 23 ++++++++----------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/cardano-testnet/cardano-testnet.cabal b/cardano-testnet/cardano-testnet.cabal index a532f3276b7..e4473f12d67 100644 --- a/cardano-testnet/cardano-testnet.cabal +++ b/cardano-testnet/cardano-testnet.cabal @@ -56,6 +56,8 @@ library , filepath , hedgehog , hedgehog-extras ^>= 0.4.7.0 + , microlens + , lens-aeson , mtl , network , network-mux diff --git a/cardano-testnet/src/Testnet/Components/Configuration.hs b/cardano-testnet/src/Testnet/Components/Configuration.hs index 93fbf638e74..812e26c319d 100644 --- a/cardano-testnet/src/Testnet/Components/Configuration.hs +++ b/cardano-testnet/src/Testnet/Components/Configuration.hs @@ -37,6 +37,9 @@ import qualified Hedgehog.Extras.Stock.Time as DTC import qualified Hedgehog.Extras.Test.Base as H import qualified Hedgehog.Extras.Test.File as H +import qualified Data.Aeson.Lens as L +import Lens.Micro + import Testnet.Defaults import Testnet.Filepath import Testnet.Process.Run (execCli_) @@ -102,20 +105,12 @@ createSPOGenesisAndFiles testnetOptions startTime (TmpAbsolutePath tempAbsPath') -- TODO: Remove this rewrite. -- 50 second epochs -- Epoch length should be "10 * k / f" where "k = securityParam, f = activeSlotsCoeff" - H.rewriteJsonFile createStakedInitialGenesisFile $ \o -> - o - -- J.rewriteObject - -- ( HM.insert "securityParam" (toJSON @Int 5) -- TODO: USE config p arameter - -- . HM.adjust - -- (J.rewriteObject - -- $ HM.adjust - -- (J.rewriteObject (HM.insert "major" (toJSON @Int 8))) - -- "protocolVersion" - -- ) "protocolParams" - -- . HM.insert "rho" (toJSON @Double 0.1) - -- . HM.insert "tau" (toJSON @Double 0.1) - -- . HM.insert "updateQuorum" (toJSON @Int 2) - -- ) + H.rewriteJsonFile createStakedInitialGenesisFile $ \o -> o + & L.key "securityParam" . L._Integer .~ 5 + & L.key "rho" . L._Double .~ 0.1 + & L.key "tau" . L._Double .~ 0.1 + & L.key "updateQuorum" . L._Integer .~ 2 + & L.key "protocolParams" . L.key "protocolVersion" . L.key "major" . L._Integer .~ 8 execCli_ [ "genesis", "create-staked"