-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test to check ConwayGenesis deserialization from a file
- Loading branch information
Showing
5 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
eras/conway/impl/test/Test/Cardano/Ledger/Conway/GenesisSpec.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{-# LANGUAGE AllowAmbiguousTypes #-} | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
|
||
module Test.Cardano.Ledger.Conway.GenesisSpec (spec) where | ||
|
||
import Test.Cardano.Ledger.Common | ||
import Cardano.Ledger.Conway | ||
import Cardano.Ledger.Conway.Genesis (ConwayGenesis(..)) | ||
import Paths_cardano_ledger_conway (getDataFileName) | ||
import Data.Aeson hiding (Encoding) | ||
import Data.Default.Class (Default (def)) | ||
|
||
spec :: Spec | ||
spec = do | ||
describe "Genesis Golden Spec" $ do | ||
goldenJSON "test/data/conway-genesis.json" | ||
|
||
goldenJSON :: FilePath -> Spec | ||
goldenJSON fileName = do | ||
it "should deserialize to the default value" $ do | ||
file <- getDataFileName fileName | ||
dec <- eitherDecodeFileStrict' file | ||
cg <- case dec of | ||
Left err -> fail ("Failed to deserialize JSON: " ++ err) | ||
Right x -> pure x | ||
cg `shouldBe` (def :: ConwayGenesis Conway) | ||
print cg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"upgradeProtocolParams":{ | ||
"poolVotingThresholds":{ | ||
"pvtCommitteeNormal":0, | ||
"pvtCommitteeNoConfidence":0, | ||
"pvtHardForkInitiation":0, | ||
"pvtMotionNoConfidence":0 | ||
}, | ||
"dRepVotingThresholds":{ | ||
"dvtMotionNoConfidence":0, | ||
"dvtCommitteeNormal":0, | ||
"dvtCommitteeNoConfidence":0, | ||
"dvtUpdateToConstitution":0, | ||
"dvtHardForkInitiation":0, | ||
"dvtPPNetworkGroup":0, | ||
"dvtPPEconomicGroup":0, | ||
"dvtPPTechnicalGroup":0, | ||
"dvtPPGovGroup":0, | ||
"dvtTreasuryWithdrawal":0 | ||
}, | ||
"minCommitteeSize":0, | ||
"committeeTermLimit":0, | ||
"govActionExpiration":0, | ||
"govActionDeposit":0, | ||
"dRepDeposit":0, | ||
"dRepActivity":0 | ||
}, | ||
"constitution": { | ||
"anchor": { | ||
"url": "", | ||
"dataHash": "0000000000000000000000000000000000000000000000000000000000000000" | ||
} | ||
} | ||
} |