| 158 | } |
| 159 | |
| 160 | void sanity_check_chainparams(const ArgsManager& args, ChainType chain_type) |
| 161 | { |
| 162 | const auto chainParams = CreateChainParams(args, chain_type); |
| 163 | const auto consensus = chainParams->GetConsensus(); |
| 164 | |
| 165 | // hash genesis is correct |
| 166 | BOOST_CHECK_EQUAL(consensus.hashGenesisBlock, chainParams->GenesisBlock().GetHash()); |
| 167 | |
| 168 | // target timespan is an even multiple of spacing |
| 169 | BOOST_CHECK_EQUAL(consensus.nPowTargetTimespan % consensus.nPowTargetSpacing, 0); |
| 170 | |
| 171 | // genesis nBits is positive, doesn't overflow and is lower than powLimit |
| 172 | arith_uint256 pow_compact; |
| 173 | bool neg, over; |
| 174 | pow_compact.SetCompact(chainParams->GenesisBlock().nBits, &neg, &over); |
| 175 | BOOST_CHECK(!neg && pow_compact != 0); |
| 176 | BOOST_CHECK(!over); |
| 177 | BOOST_CHECK(UintToArith256(consensus.powLimit) >= pow_compact); |
| 178 | |
| 179 | // check max target * 4*nPowTargetTimespan doesn't overflow -- see pow.cpp:CalculateNextWorkRequired() |
| 180 | if (!consensus.fPowNoRetargeting) { |
| 181 | arith_uint256 targ_max{UintToArith256(uint256{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"})}; |
| 182 | targ_max /= consensus.nPowTargetTimespan*4; |
| 183 | BOOST_CHECK(UintToArith256(consensus.powLimit) < targ_max); |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | BOOST_AUTO_TEST_CASE(ChainParams_MAIN_sanity) |
| 188 | { |
no test coverage detected