Skip to content

Commit

Permalink
Switch to use lenses
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Jan 6, 2024
1 parent 85ca504 commit 5353e38
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
2 changes: 2 additions & 0 deletions cardano-testnet/cardano-testnet.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ library
, filepath
, hedgehog
, hedgehog-extras ^>= 0.4.7.0
, microlens
, lens-aeson
, mtl
, network
, network-mux
Expand Down
23 changes: 9 additions & 14 deletions cardano-testnet/src/Testnet/Components/Configuration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 5353e38

Please sign in to comment.