From 22964642295793a7b075acab71b2445a9cc48b05 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Thu, 11 Oct 2018 18:17:00 -0400 Subject: [PATCH] [CO-410] Add golden decode only test for `Configuration` --- chain/src/Pos/Chain/Block/Configuration.hs | 2 +- chain/src/Pos/Chain/Genesis/Config.hs | 4 +- chain/src/Pos/Chain/Ssc/Configuration.hs | 2 +- chain/src/Pos/Chain/Update/Configuration.hs | 2 +- lib/cardano-sl.cabal | 2 + lib/src/Pos/Configuration.hs | 2 +- lib/src/Pos/Launcher/Configuration.hs | 6 +- lib/test/Test.hs | 3 + lib/test/Test/Pos/Launcher/Json.hs | 156 ++++++++++++++++++ .../Configuration_Legacy_NoNetworkMagicField | 1 + .../Prettified_Haskell_Value_Configuration | 106 ++++++++++++ .../golden/json/Prettified_JSON_Configuration | 116 +++++++++++++ networking/src/Ntp/Client.hs | 15 +- 13 files changed, 406 insertions(+), 11 deletions(-) create mode 100644 lib/test/Test/Pos/Launcher/Json.hs create mode 100644 lib/test/golden/json/Configuration_Legacy_NoNetworkMagicField create mode 100644 lib/test/golden/json/Prettified_Haskell_Value_Configuration create mode 100644 lib/test/golden/json/Prettified_JSON_Configuration diff --git a/chain/src/Pos/Chain/Block/Configuration.hs b/chain/src/Pos/Chain/Block/Configuration.hs index a8182878db2..a774e99206a 100644 --- a/chain/src/Pos/Chain/Block/Configuration.hs +++ b/chain/src/Pos/Chain/Block/Configuration.hs @@ -74,7 +74,7 @@ data BlockConfiguration = BlockConfiguration -- | Chain quality will be also calculated for this amount of seconds. , ccFixedTimeCQ :: !Second - } deriving (Show, Generic) + } deriving (Eq, Generic, Show) instance ToJSON BlockConfiguration where toJSON = genericToJSON defaultOptions diff --git a/chain/src/Pos/Chain/Genesis/Config.hs b/chain/src/Pos/Chain/Genesis/Config.hs index f0f5e101049..66cf11f210c 100644 --- a/chain/src/Pos/Chain/Genesis/Config.hs +++ b/chain/src/Pos/Chain/Genesis/Config.hs @@ -148,9 +148,9 @@ instance FromJSON StaticConfig where avvmBalanceFactor useHeavyDlg seed) - | otherwise = fail "Incorrect JSON encoding for GenesisConfiguration" + | otherwise = fail "Incorrect JSON encoding for StaticConfig" - parseJSON invalid = typeMismatch "GenesisConfiguration" invalid + parseJSON invalid = typeMismatch "StaticConfig" invalid -------------------------------------------------------------------------------- -- Config diff --git a/chain/src/Pos/Chain/Ssc/Configuration.hs b/chain/src/Pos/Chain/Ssc/Configuration.hs index d6300d6b4a8..1232e191863 100644 --- a/chain/src/Pos/Chain/Ssc/Configuration.hs +++ b/chain/src/Pos/Chain/Ssc/Configuration.hs @@ -37,7 +37,7 @@ data SscConfiguration = SscConfiguration -- | Don't print “SSC couldn't compute seed” for the first epoch. , ccNoReportNoSecretsForEpoch1 :: !Bool } - deriving (Show, Generic) + deriving (Eq, Generic, Show) instance FromJSON SscConfiguration where parseJSON = genericParseJSON defaultOptions diff --git a/chain/src/Pos/Chain/Update/Configuration.hs b/chain/src/Pos/Chain/Update/Configuration.hs index 1bb52da6bab..57afe07545a 100644 --- a/chain/src/Pos/Chain/Update/Configuration.hs +++ b/chain/src/Pos/Chain/Update/Configuration.hs @@ -55,7 +55,7 @@ data UpdateConfiguration = UpdateConfiguration -- | System tag. , ccSystemTag :: !SystemTag } - deriving (Show, Generic) + deriving (Eq, Generic, Show) instance ToJSON UpdateConfiguration where toJSON = genericToJSON defaultOptions diff --git a/lib/cardano-sl.cabal b/lib/cardano-sl.cabal index b7ce06fc885..e58a0f08de4 100644 --- a/lib/cardano-sl.cabal +++ b/lib/cardano-sl.cabal @@ -283,6 +283,7 @@ test-suite cardano-test Test.Pos.Diffusion.BlockSpec Test.Pos.Genesis.CanonicalSpec Test.Pos.Launcher.ConfigurationSpec + Test.Pos.Launcher.Json Test.Pos.MerkleSpec Test.Pos.Infra.Slotting.TypesSpec Test.Pos.Types.Identity.SafeCopySpec @@ -322,6 +323,7 @@ test-suite cardano-test , filelock , formatting , generic-arbitrary + , hedgehog , hspec , lens , network-transport diff --git a/lib/src/Pos/Configuration.hs b/lib/src/Pos/Configuration.hs index cf53dc965e8..70acb1dc052 100644 --- a/lib/src/Pos/Configuration.hs +++ b/lib/src/Pos/Configuration.hs @@ -58,7 +58,7 @@ data NodeConfiguration = NodeConfiguration , ccExplorerExtendedApi :: !Bool -- ^ Enable explorer extended API for fetching more -- info about addresses (like utxos) and bulk endpoints - } deriving (Show, Generic) + } deriving (Eq, Generic, Show) instance ToJSON NodeConfiguration where toJSON = genericToJSON defaultOptions diff --git a/lib/src/Pos/Launcher/Configuration.hs b/lib/src/Pos/Launcher/Configuration.hs index d7d73fcd84d..7b4acfc506d 100644 --- a/lib/src/Pos/Launcher/Configuration.hs +++ b/lib/src/Pos/Launcher/Configuration.hs @@ -74,7 +74,7 @@ data Configuration = Configuration , ccNode :: !NodeConfiguration , ccWallet :: !WalletConfiguration , ccReqNetMagic :: !RequiresNetworkMagic - } deriving (Show, Generic) + } deriving (Eq, Generic , Show) instance FromJSON Configuration where parseJSON = withObject "Configuration" $ \o -> do @@ -114,7 +114,7 @@ instance ToJSON Configuration where data WalletConfiguration = WalletConfiguration { ccThrottle :: !(Maybe ThrottleSettings) - } deriving (Show, Generic) + } deriving (Eq, Generic, Show) defaultWalletConfiguration :: WalletConfiguration defaultWalletConfiguration = WalletConfiguration @@ -131,7 +131,7 @@ data ThrottleSettings = ThrottleSettings { tsRate :: !Word64 , tsPeriod :: !Word64 , tsBurst :: !Word64 - } deriving (Show, Generic) + } deriving (Eq, Generic, Show) defaultThrottleSettings :: ThrottleSettings defaultThrottleSettings = ThrottleSettings diff --git a/lib/test/Test.hs b/lib/test/Test.hs index 6684452ff03..669ae90b67d 100644 --- a/lib/test/Test.hs +++ b/lib/test/Test.hs @@ -5,8 +5,11 @@ import Test.Hspec (hspec) import Spec (spec) import Test.Pos.Configuration (defaultTestConf) +import qualified Test.Pos.Launcher.Json +import Test.Pos.Util.Tripping (runTests) main :: IO () main = do putText $ "default configuration: " <> show defaultTestConf hspec spec + runTests [ Test.Pos.Launcher.Json.tests ] diff --git a/lib/test/Test/Pos/Launcher/Json.hs b/lib/test/Test/Pos/Launcher/Json.hs new file mode 100644 index 00000000000..9054b447beb --- /dev/null +++ b/lib/test/Test/Pos/Launcher/Json.hs @@ -0,0 +1,156 @@ +{-# LANGUAGE TemplateHaskell #-} + +module Test.Pos.Launcher.Json + ( tests + ) where + +import Universum + +import qualified Data.HashMap.Strict as HM +import qualified Data.Set as S +import Hedgehog (Property) +import qualified Hedgehog as H +import Pos.Launcher.Configuration + +import Ntp.Client (NtpConfiguration (..)) +import Pos.Chain.Block (BlockConfiguration (..)) +import Pos.Chain.Delegation (DlgConfiguration (..)) +import Pos.Chain.Genesis (FakeAvvmOptions (..), + GenesisAvvmBalances (..), GenesisDelegation (..), + GenesisInitializer (..), GenesisProtocolConstants (..), + GenesisSpec (..), StaticConfig (..), + TestnetBalanceOptions (..)) +import Pos.Chain.Ssc (SscConfiguration (..)) +import Pos.Chain.Txp (TxpConfiguration (..)) +import Pos.Chain.Update +import Pos.Configuration (NodeConfiguration (..)) +import Pos.Core +import Pos.Core.Common (CoinPortion (..)) +import Pos.Core.ProtocolConstants (VssMaxTTL (..), VssMinTTL (..)) +import Pos.Crypto.Configuration (ProtocolMagic (..), + ProtocolMagicId (..), RequiresNetworkMagic (..)) + +import Test.Pos.Util.Golden (discoverGolden, goldenTestJSONDec) +-------------------------------------------------------------------------------- +-- Configuration +-------------------------------------------------------------------------------- + +-- Decode-only golden tests for ensuring that, when decoding the legacy +-- `Configuration` JSON format, the `RequiresNetworkMagic` field defaults to +-- the correct `RequiresNetworkMagic`. + +golden_Configuration_Legacy_NoNetworkMagicField :: Property +golden_Configuration_Legacy_NoNetworkMagicField = + goldenTestJSONDec + testGoldenConf_NoNetworkMagicField + "test/golden/json/Configuration_Legacy_NoNetworkMagicField" + +testGoldenConf_NoNetworkMagicField :: Configuration +testGoldenConf_NoNetworkMagicField = Configuration + { ccGenesis = GCSpec + ( UnsafeGenesisSpec + { gsAvvmDistr = GenesisAvvmBalances (HM.fromList []) + , gsFtsSeed = SharedSeed "skovoroda Ggurda boroda provoda " + , gsHeavyDelegation = UnsafeGenesisDelegation (HM.fromList []) + , gsBlockVersionData = BlockVersionData + { bvdScriptVersion = 0 + , bvdSlotDuration = 7000 + , bvdMaxBlockSize = 2000000 + , bvdMaxHeaderSize = 2000000 + , bvdMaxTxSize = 4096 + , bvdMaxProposalSize = 700 + , bvdMpcThd = CoinPortion 100000000000000 + , bvdHeavyDelThd = CoinPortion 100000000000000 + , bvdUpdateVoteThd = CoinPortion 100000000000000 + , bvdUpdateProposalThd = CoinPortion 100000000000000 + , bvdUpdateImplicit = 10 + , bvdSoftforkRule = SoftforkRule + { srInitThd = CoinPortion 100000000000000 + , srMinThd = CoinPortion 100000000000000 + , srThdDecrement = CoinPortion 100000000000000 + } + , bvdTxFeePolicy = + TxFeePolicyTxSizeLinear + (TxSizeLinear + (Coeff 155381.000000000) (Coeff 43.946000000)) + , bvdUnlockStakeEpoch = EpochIndex 1844 + } + , gsProtocolConstants = GenesisProtocolConstants + { gpcK = 2 + , gpcProtocolMagic = ProtocolMagic + (ProtocolMagicId 55550001) RequiresMagic + , gpcVssMaxTTL = VssMaxTTL 6 + , gpcVssMinTTL = VssMinTTL 2 + } + , gsInitializer = GenesisInitializer + { giTestBalance = TestnetBalanceOptions + { tboPoors = 12 + , tboRichmen = 4 + , tboTotalBalance = 600000000000000000 + , tboRichmenShare = 0.99 + , tboUseHDAddresses = True + } + , giFakeAvvmBalance = FakeAvvmOptions + { faoCount = 10 + , faoOneBalance = 100000 + } + , giAvvmBalanceFactor = CoinPortion 100000000000000 + , giUseHeavyDlg = True + , giSeed = 0 + } + } + ) + , ccNtp = NtpConfiguration + { ntpcServers = + [ "0.pool.ntp.org" + , "2.pool.ntp.org" + , "3.pool.ntp.org" + ] + , ntpcResponseTimeout = 30000000 + , ntpcPollDelay = 1800000000 + } + , ccUpdate = UpdateConfiguration + { ccApplicationName = ApplicationName "cardano-sl" + , ccLastKnownBlockVersion = BlockVersion 0 0 0 + , ccApplicationVersion = 0 + , ccSystemTag = SystemTag "linux64" + } + , ccSsc = SscConfiguration + { ccMpcSendInterval = 10 + , ccMdNoCommitmentsEpochThreshold = 3 + , ccNoReportNoSecretsForEpoch1 = False + } + , ccDlg = DlgConfiguration + { ccDlgCacheParam = 500 + , ccMessageCacheTimeout = 30 + } + , ccTxp = TxpConfiguration + { ccMemPoolLimitTx = 200 + , tcAssetLockedSrcAddrs = S.fromList [] + } + , ccBlock = BlockConfiguration + { ccNetworkDiameter = 3 + , ccRecoveryHeadersMessage = 20 + , ccStreamWindow = 2048 + , ccNonCriticalCQBootstrap = 0.95 + , ccCriticalCQBootstrap = 0.8888 + , ccNonCriticalCQ = 0.8 + , ccCriticalCQ = 0.654321 + , ccCriticalForkThreshold = 2 + , ccFixedTimeCQ = 10 + } + , ccNode = NodeConfiguration + { ccNetworkConnectionTimeout = 15000 + , ccConversationEstablishTimeout = 30000 + , ccBlockRetrievalQueueSize = 100 + , ccPendingTxResubmissionPeriod = 7 + , ccWalletProductionApi = False + , ccWalletTxCreationDisabled = False + , ccExplorerExtendedApi = False + } + , ccWallet = WalletConfiguration { ccThrottle = Nothing } + , ccReqNetMagic = RequiresNoMagic + } + +tests :: IO Bool +tests = H.checkSequential $$discoverGolden diff --git a/lib/test/golden/json/Configuration_Legacy_NoNetworkMagicField b/lib/test/golden/json/Configuration_Legacy_NoNetworkMagicField new file mode 100644 index 00000000000..59a6d675024 --- /dev/null +++ b/lib/test/golden/json/Configuration_Legacy_NoNetworkMagicField @@ -0,0 +1 @@ +{"core":{"genesis":{"spec":{"initializer":{"testBalance":{"poors":12,"richmen":4,"richmenShare":0.99,"useHDAddresses":true,"totalBalance":600000000000000000},"fakeAvvmBalance":{"count":10,"oneBalance":100000},"avvmBalanceFactor":0.1,"useHeavyDlg":true,"seed":0},"blockVersionData":{"scriptVersion":0,"slotDuration":7000,"maxBlockSize":2000000,"maxHeaderSize":2000000,"maxTxSize":4096,"maxProposalSize":700,"mpcThd":0.1,"heavyDelThd":0.1,"updateVoteThd":0.1,"updateProposalThd":0.1,"updateImplicit":10,"softforkRule":{"initThd":0.1,"minThd":0.1,"thdDecrement":0.1},"txFeePolicy":{"txSizeLinear":{"a":155381,"b":43.946}},"unlockStakeEpoch":1844},"protocolConstants":{"k":2,"protocolMagic":55550001,"vssMinTTL":2,"vssMaxTTL":6},"ftsSeed":"c2tvdm9yb2RhIEdndXJkYSBib3JvZGEgcHJvdm9kYSA=","heavyDelegation":{},"avvmDistr":{}}},"requiresNetworkMagic":"RequiresNoMagic","dbSerializeVersion":0},"ntp":{"responseTimeout":30000000,"pollDelay":1800000000,"servers":["0.pool.ntp.org","2.pool.ntp.org","3.pool.ntp.org"]},"update":{"applicationName":"cardano-sl","applicationVersion":0,"lastKnownBlockVersion":{"bvMajor":0,"bvMinor":0,"bvAlt":0}},"ssc":{"mpcSendInterval":10,"mdNoCommitmentsEpochThreshold":3,"noReportNoSecretsForEpoch1":false},"txp":{"memPoolLimitTx":200,"assetLockedSrcAddrs":[]},"dlg":{"dlgCacheParam":500,"messageCacheTimeout":30},"block":{"networkDiameter":3,"recoveryHeadersMessage":20,"streamWindow":2048,"nonCriticalCQBootstrap":0.95,"criticalCQBootstrap":0.8888,"nonCriticalCQ":0.8,"criticalCQ":0.654321,"criticalForkThreshold":2,"fixedTimeCQ":10},"node":{"networkConnectionTimeout":15000,"conversationEstablishTimeout":30000,"blockRetrievalQueueSize":100,"pendingTxResubmissionPeriod":7,"walletProductionApi":false,"walletTxCreationDisabled":false,"explorerExtendedApi":false},"wallet":{"throttle":null}} \ No newline at end of file diff --git a/lib/test/golden/json/Prettified_Haskell_Value_Configuration b/lib/test/golden/json/Prettified_Haskell_Value_Configuration new file mode 100644 index 00000000000..5ea34b43d10 --- /dev/null +++ b/lib/test/golden/json/Prettified_Haskell_Value_Configuration @@ -0,0 +1,106 @@ +This is the prettified version of `testGoldenConf_NoNetworkMagicField` for reference purposes. + +Configuration + { ccGenesis = GCSpec + ( UnsafeGenesisSpec + { gsAvvmDistr = GenesisAvvmBalances { getGenesisAvvmBalances = fromList [] } + , gsFtsSeed = SharedSeed { getSharedSeed = "skovoroda Ggurda boroda provoda " } + , gsHeavyDelegation = UnsafeGenesisDelegation { unGenesisDelegation = fromList [] } + , gsBlockVersionData = BlockVersionData + { bvdScriptVersion = 0 + , bvdSlotDuration = 7000ms + , bvdMaxBlockSize = Byte 2000000 + , bvdMaxHeaderSize = Byte 2000000 + , bvdMaxTxSize = Byte 4096 + , bvdMaxProposalSize = Byte 700 + , bvdMpcThd = CoinPortion { getCoinPortion = 10000000000000 } + , bvdHeavyDelThd = CoinPortion { getCoinPortion = 5000000000000 } + , bvdUpdateVoteThd = CoinPortion { getCoinPortion = 1000000000000 } + , bvdUpdateProposalThd = CoinPortion { getCoinPortion = 100000000000000 } + , bvdUpdateImplicit = 10 + , bvdSoftforkRule = SoftforkRule + { srInitThd = CoinPortion { getCoinPortion = 900000000000000 } + , srMinThd = CoinPortion { getCoinPortion = 600000000000000 } + , srThdDecrement = CoinPortion { getCoinPortion = 50000000000000 } + } + , bvdTxFeePolicy = TxFeePolicyTxSizeLinear ( TxSizeLinear ( Coeff 155381.000000000 ) ( Coeff 43.946000000 ) ) + , bvdUnlockStakeEpoch = EpochIndex { getEpochIndex = 18446744073709551615 } + } + , gsProtocolConstants = GenesisProtocolConstants + { gpcK = 10 + , gpcProtocolMagic = ProtocolMagic + { getProtocolMagicId = ProtocolMagicId { unProtocolMagicId = 55550001 } + , getRequiresNetworkMagic = RequiresMagic + } + , gpcVssMaxTTL = VssMaxTTL { getVssMaxTTL = 6 } + , gpcVssMinTTL = VssMinTTL { getVssMinTTL = 2 } + } + , gsInitializer = GenesisInitializer + { giTestBalance = TestnetBalanceOptions + { tboPoors = 12 + , tboRichmen = 4 + , tboTotalBalance = 600000000000000000 + , tboRichmenShare = 0.99 + , tboUseHDAddresses = True + } + , giFakeAvvmBalance = FakeAvvmOptions + { faoCount = 10 + , faoOneBalance = 100000 + } + , giAvvmBalanceFactor = CoinPortion { getCoinPortion = 1000000000000000 } + , giUseHeavyDlg = True + , giSeed = 0 + } + } + ) + , ccNtp = NtpConfiguration + { ntpcServers = + [ "0.pool.ntp.org" + , "2.pool.ntp.org" + , "3.pool.ntp.org" + ] + , ntpcResponseTimeout = 30000000 + , ntpcPollDelay = 1800000000 + } + , ccUpdate = UpdateConfiguration + { ccApplicationName = ApplicationName { getApplicationName = "cardano-sl" } + , ccLastKnownBlockVersion = 0.0.0 + , ccApplicationVersion = 0 + , ccSystemTag = SystemTag { getSystemTag = "linux64" } + } + , ccSsc = SscConfiguration + { ccMpcSendInterval = 10 + , ccMdNoCommitmentsEpochThreshold = 3 + , ccNoReportNoSecretsForEpoch1 = False + } + , ccDlg = DlgConfiguration + { ccDlgCacheParam = 500 + , ccMessageCacheTimeout = 30 + } + , ccTxp = TxpConfiguration + { ccMemPoolLimitTx = 200 + , tcAssetLockedSrcAddrs = fromList [] + } + , ccBlock = BlockConfiguration + { ccNetworkDiameter = 3 + , ccRecoveryHeadersMessage = 20 + , ccStreamWindow = 2048 + , ccNonCriticalCQBootstrap = 0.95 + , ccCriticalCQBootstrap = 0.8888 + , ccNonCriticalCQ = 0.8 + , ccCriticalCQ = 0.654321 + , ccCriticalForkThreshold = 2 + , ccFixedTimeCQ = 10s + } + , ccNode = NodeConfiguration + { ccNetworkConnectionTimeout = 15000 + , ccConversationEstablishTimeout = 30000 + , ccBlockRetrievalQueueSize = 100 + , ccPendingTxResubmissionPeriod = 7 + , ccWalletProductionApi = False + , ccWalletTxCreationDisabled = False + , ccExplorerExtendedApi = False + } + , ccWallet = WalletConfiguration { ccThrottle = Nothing } + , ccReqNetMagic = RequiresNoMagic + } diff --git a/lib/test/golden/json/Prettified_JSON_Configuration b/lib/test/golden/json/Prettified_JSON_Configuration new file mode 100644 index 00000000000..f51e1de3151 --- /dev/null +++ b/lib/test/golden/json/Prettified_JSON_Configuration @@ -0,0 +1,116 @@ +This is the prettified version of `Configuration_Legacy_NoNetworkMagicField` for reference purposes. + +{ + "core": { + "genesis": { + "spec": { + "initializer": { + "testBalance": { + "poors": 12, + "richmen": 4, + "richmenShare": 0.99, + "useHDAddresses": true, + "totalBalance": 600000000000000000 + }, + "fakeAvvmBalance": { + "count": 10, + "oneBalance": 100000 + }, + "avvmBalanceFactor": 0.1, + "useHeavyDlg": true, + "seed": 0 + }, + "blockVersionData": { + "scriptVersion": 0, + "slotDuration": 7000, + "maxBlockSize": 2000000, + "maxHeaderSize": 2000000, + "maxTxSize": 4096, + "maxProposalSize": 700, + "mpcThd": 0.1, + "heavyDelThd": 0.1, + "updateVoteThd": 0.1, + "updateProposalThd": 0.1, + "updateImplicit": 10, + "softforkRule": { + "initThd": 0.1, + "minThd": 0.1, + "thdDecrement": 0.1 + }, + "txFeePolicy": { + "txSizeLinear": { + "a": 155381, + "b": 43.946 + } + }, + "unlockStakeEpoch": 1844 + }, + "protocolConstants": { + "k": 2, + "protocolMagic": 55550001, + "vssMinTTL": 2, + "vssMaxTTL": 6 + }, + "ftsSeed": "c2tvdm9yb2RhIEdndXJkYSBib3JvZGEgcHJvdm9kYSA=", + "heavyDelegation": {}, + "avvmDistr": {} + } + }, + "requiresNetworkMagic": "RequiresNoMagic", + "dbSerializeVersion": 0 + }, + "ntp": { + "responseTimeout": 30000000, + "pollDelay": 1800000000, + "servers": [ + "0.pool.ntp.org", + "2.pool.ntp.org", + "3.pool.ntp.org" + ] + }, + "update": { + "applicationName": "cardano-sl", + "applicationVersion": 0, + "lastKnownBlockVersion": { + "bvMajor": 0, + "bvMinor": 0, + "bvAlt": 0 + } + }, + "ssc": { + "mpcSendInterval": 10, + "mdNoCommitmentsEpochThreshold": 3, + "noReportNoSecretsForEpoch1": false + }, + "txp": { + "memPoolLimitTx": 200, + "assetLockedSrcAddrs": [] + }, + "dlg": { + "dlgCacheParam": 500, + "messageCacheTimeout": 30 + }, + "block": { + "networkDiameter": 3, + "recoveryHeadersMessage": 20, + "streamWindow": 2048, + "nonCriticalCQBootstrap": 0.95, + "criticalCQBootstrap": 0.8888, + "nonCriticalCQ": 0.8, + "criticalCQ": 0.654321, + "criticalForkThreshold": 2, + "fixedTimeCQ": 10 + }, + "node": { + "networkConnectionTimeout": 15000, + "conversationEstablishTimeout": 30000, + "blockRetrievalQueueSize": 100, + "pendingTxResubmissionPeriod": 7, + "walletProductionApi": false, + "walletTxCreationDisabled": false, + "explorerExtendedApi": false + }, + "wallet": { + "throttle": null + } +} \ No newline at end of file diff --git a/networking/src/Ntp/Client.hs b/networking/src/Ntp/Client.hs index 66d3e015681..269b3293ab0 100644 --- a/networking/src/Ntp/Client.hs +++ b/networking/src/Ntp/Client.hs @@ -7,6 +7,7 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE StandaloneDeriving #-} -- | This module implements functionality of NTP client. @@ -71,6 +72,16 @@ data NtpClientSettings = NtpClientSettings -- some servers failed to respond in time, but never an empty list } +-- Written for JSON golden decode only tests. Only +-- the fields ntpServers, ntpResponseTimeout and ntpPollDelay +-- end up in the JSON encoding of `Configuration`. Also, +-- equality testing of a function does not make sense. + +instance Eq NtpClientSettings where + (==) (NtpClientSettings servs respT pDel _) (NtpClientSettings servs' respT' pDel' _) = + servs == servs' && respT == respT' && pDel == pDel' + + data NtpClient = NtpClient { ncSockets :: TVar Sockets -- ^ Ntp client sockets: ipv4 / ipv6 / both. @@ -83,7 +94,7 @@ data NtpClient = NtpClient -- once all responses arrived. , ncSettings :: NtpClientSettings -- ^ Ntp client configuration. - } + } deriving Eq data NtpConfiguration = NtpConfiguration { @@ -94,7 +105,7 @@ data NtpConfiguration = NtpConfiguration , ntpcPollDelay :: !Integer -- ^ how long to wait between sending requests to the ntp servers (in -- microseconds) - } deriving (Show, Generic) + } deriving (Eq, Generic, Show) instance FromJSON NtpConfiguration where parseJSON = genericParseJSON defaultOptions