|
| 1 | +{-# LANGUAGE TemplateHaskell #-} |
| 2 | + |
| 3 | +module Test.Pos.Launcher.Json |
| 4 | + ( tests |
| 5 | + ) where |
| 6 | + |
| 7 | +import Universum |
| 8 | + |
| 9 | +import qualified Data.HashMap.Strict as HM |
| 10 | +import qualified Data.Set as S |
| 11 | +import Hedgehog (Property) |
| 12 | +import qualified Hedgehog as H |
| 13 | + |
| 14 | +import Ntp.Client (NtpConfiguration (..)) |
| 15 | +import Pos.Chain.Block (BlockConfiguration (..)) |
| 16 | +import Pos.Chain.Delegation (DlgConfiguration (..)) |
| 17 | +import Pos.Chain.Genesis (FakeAvvmOptions (..), |
| 18 | + GenesisAvvmBalances (..), GenesisDelegation (..), |
| 19 | + GenesisInitializer (..), GenesisProtocolConstants (..), |
| 20 | + GenesisSpec (..), StaticConfig (..), |
| 21 | + TestnetBalanceOptions (..)) |
| 22 | +import Pos.Chain.Ssc (SscConfiguration (..)) |
| 23 | +import Pos.Chain.Txp (TxpConfiguration (..)) |
| 24 | +import Pos.Chain.Update |
| 25 | +import Pos.Configuration (NodeConfiguration (..)) |
| 26 | +import Pos.Core.Common (Coeff (..), CoinPortion (..), SharedSeed (..), |
| 27 | + TxFeePolicy (..), TxSizeLinear (..)) |
| 28 | +import Pos.Core.ProtocolConstants (VssMaxTTL (..), VssMinTTL (..)) |
| 29 | +import Pos.Core.Slotting (EpochIndex (..)) |
| 30 | +import Pos.Crypto.Configuration (ProtocolMagic (..), |
| 31 | + ProtocolMagicId (..), RequiresNetworkMagic (..)) |
| 32 | +import Pos.Launcher.Configuration (Configuration (..), |
| 33 | + WalletConfiguration (..)) |
| 34 | + |
| 35 | +import Test.Pos.Util.Golden (discoverGolden, goldenTestJSONDec) |
| 36 | +-------------------------------------------------------------------------------- |
| 37 | +-- Configuration |
| 38 | +-------------------------------------------------------------------------------- |
| 39 | + |
| 40 | +-- Decode-only golden tests for ensuring that, when decoding the legacy |
| 41 | +-- `Configuration` JSON format, the `RequiresNetworkMagic` field defaults to |
| 42 | +-- the correct `RequiresNetworkMagic`. |
| 43 | + |
| 44 | +golden_Configuration_Legacy_NoNetworkMagicField :: Property |
| 45 | +golden_Configuration_Legacy_NoNetworkMagicField = |
| 46 | + goldenTestJSONDec |
| 47 | + testGoldenConf_NoNetworkMagicField |
| 48 | + "test/golden/json/Configuration_Legacy_NoNetworkMagicField" |
| 49 | + |
| 50 | +testGoldenConf_NoNetworkMagicField :: Configuration |
| 51 | +testGoldenConf_NoNetworkMagicField = Configuration |
| 52 | + { ccGenesis = GCSpec |
| 53 | + ( UnsafeGenesisSpec |
| 54 | + { gsAvvmDistr = GenesisAvvmBalances (HM.fromList []) |
| 55 | + , gsFtsSeed = SharedSeed "skovoroda Ggurda boroda provoda " |
| 56 | + , gsHeavyDelegation = UnsafeGenesisDelegation (HM.fromList []) |
| 57 | + , gsBlockVersionData = BlockVersionData |
| 58 | + { bvdScriptVersion = 0 |
| 59 | + , bvdSlotDuration = 7000 |
| 60 | + , bvdMaxBlockSize = 2000000 |
| 61 | + , bvdMaxHeaderSize = 2000000 |
| 62 | + , bvdMaxTxSize = 4096 |
| 63 | + , bvdMaxProposalSize = 700 |
| 64 | + , bvdMpcThd = CoinPortion 100000000000000 |
| 65 | + , bvdHeavyDelThd = CoinPortion 100000000000000 |
| 66 | + , bvdUpdateVoteThd = CoinPortion 100000000000000 |
| 67 | + , bvdUpdateProposalThd = CoinPortion 100000000000000 |
| 68 | + , bvdUpdateImplicit = 10 |
| 69 | + , bvdSoftforkRule = SoftforkRule |
| 70 | + { srInitThd = CoinPortion 100000000000000 |
| 71 | + , srMinThd = CoinPortion 100000000000000 |
| 72 | + , srThdDecrement = CoinPortion 100000000000000 |
| 73 | + } |
| 74 | + , bvdTxFeePolicy = |
| 75 | + TxFeePolicyTxSizeLinear |
| 76 | + (TxSizeLinear |
| 77 | + (Coeff 155381.000000000) (Coeff 43.946000000)) |
| 78 | + , bvdUnlockStakeEpoch = EpochIndex 1844 |
| 79 | + } |
| 80 | + , gsProtocolConstants = GenesisProtocolConstants |
| 81 | + { gpcK = 2 |
| 82 | + , gpcProtocolMagic = ProtocolMagic |
| 83 | + (ProtocolMagicId 55550001) RequiresMagic |
| 84 | + , gpcVssMaxTTL = VssMaxTTL 6 |
| 85 | + , gpcVssMinTTL = VssMinTTL 2 |
| 86 | + } |
| 87 | + , gsInitializer = GenesisInitializer |
| 88 | + { giTestBalance = TestnetBalanceOptions |
| 89 | + { tboPoors = 12 |
| 90 | + , tboRichmen = 4 |
| 91 | + , tboTotalBalance = 600000000000000000 |
| 92 | + , tboRichmenShare = 0.99 |
| 93 | + , tboUseHDAddresses = True |
| 94 | + } |
| 95 | + , giFakeAvvmBalance = FakeAvvmOptions |
| 96 | + { faoCount = 10 |
| 97 | + , faoOneBalance = 100000 |
| 98 | + } |
| 99 | + , giAvvmBalanceFactor = CoinPortion 100000000000000 |
| 100 | + , giUseHeavyDlg = True |
| 101 | + , giSeed = 0 |
| 102 | + } |
| 103 | + } |
| 104 | + ) |
| 105 | + , ccNtp = NtpConfiguration |
| 106 | + { ntpcServers = |
| 107 | + [ "0.pool.ntp.org" |
| 108 | + , "2.pool.ntp.org" |
| 109 | + , "3.pool.ntp.org" |
| 110 | + ] |
| 111 | + , ntpcResponseTimeout = 30000000 |
| 112 | + , ntpcPollDelay = 1800000000 |
| 113 | + } |
| 114 | + , ccUpdate = UpdateConfiguration |
| 115 | + { ccApplicationName = ApplicationName "cardano-sl" |
| 116 | + , ccLastKnownBlockVersion = BlockVersion 0 0 0 |
| 117 | + , ccApplicationVersion = 0 |
| 118 | + , ccSystemTag = SystemTag "linux64" |
| 119 | + } |
| 120 | + , ccSsc = SscConfiguration |
| 121 | + { ccMpcSendInterval = 10 |
| 122 | + , ccMdNoCommitmentsEpochThreshold = 3 |
| 123 | + , ccNoReportNoSecretsForEpoch1 = False |
| 124 | + } |
| 125 | + , ccDlg = DlgConfiguration |
| 126 | + { ccDlgCacheParam = 500 |
| 127 | + , ccMessageCacheTimeout = 30 |
| 128 | + } |
| 129 | + , ccTxp = TxpConfiguration |
| 130 | + { ccMemPoolLimitTx = 200 |
| 131 | + , tcAssetLockedSrcAddrs = S.fromList [] |
| 132 | + } |
| 133 | + , ccBlock = BlockConfiguration |
| 134 | + { ccNetworkDiameter = 3 |
| 135 | + , ccRecoveryHeadersMessage = 20 |
| 136 | + , ccStreamWindow = 2048 |
| 137 | + , ccNonCriticalCQBootstrap = 0.95 |
| 138 | + , ccCriticalCQBootstrap = 0.8888 |
| 139 | + , ccNonCriticalCQ = 0.8 |
| 140 | + , ccCriticalCQ = 0.654321 |
| 141 | + , ccCriticalForkThreshold = 2 |
| 142 | + , ccFixedTimeCQ = 10 |
| 143 | + } |
| 144 | + , ccNode = NodeConfiguration |
| 145 | + { ccNetworkConnectionTimeout = 15000 |
| 146 | + , ccConversationEstablishTimeout = 30000 |
| 147 | + , ccBlockRetrievalQueueSize = 100 |
| 148 | + , ccPendingTxResubmissionPeriod = 7 |
| 149 | + , ccWalletProductionApi = False |
| 150 | + , ccWalletTxCreationDisabled = False |
| 151 | + , ccExplorerExtendedApi = False |
| 152 | + } |
| 153 | + , ccWallet = WalletConfiguration { ccThrottle = Nothing } |
| 154 | + , ccReqNetMagic = RequiresNoMagic |
| 155 | + } |
| 156 | + |
| 157 | +tests :: IO Bool |
| 158 | +tests = H.checkSequential $$discoverGolden |
0 commit comments