diff options
| author | Patrick Lodder <[email protected]> | 2015-07-20 15:03:02 +0200 |
|---|---|---|
| committer | Patrick Lodder <[email protected]> | 2015-07-20 15:03:02 +0200 |
| commit | 8cd835cddba565594f5cde2d91ee92e32bcbf2fd (patch) | |
| tree | 049698b334daf7e65af268b0da64134fd9dbbfdc /src/test | |
| parent | Merge pull request #1200 from rnicoll/1.10-auxpow-clean (diff) | |
| parent | Update Python test address and key values to match Dogecoin format. (diff) | |
| download | discoin-8cd835cddba565594f5cde2d91ee92e32bcbf2fd.tar.xz discoin-8cd835cddba565594f5cde2d91ee92e32bcbf2fd.zip | |
Merge pull request #1201 from rnicoll/1.10-sync
Consensus fixes
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/alert_tests.cpp | 2 | ||||
| -rw-r--r-- | src/test/auxpow_tests.cpp | 8 | ||||
| -rw-r--r-- | src/test/data/bitcoin-util-test.json | 8 | ||||
| -rw-r--r-- | src/test/dogecoin_tests.cpp | 50 | ||||
| -rw-r--r-- | src/test/pow_tests.cpp | 10 |
5 files changed, 57 insertions, 21 deletions
diff --git a/src/test/alert_tests.cpp b/src/test/alert_tests.cpp index 0eda2ca1a..915326d4c 100644 --- a/src/test/alert_tests.cpp +++ b/src/test/alert_tests.cpp @@ -203,7 +203,7 @@ BOOST_AUTO_TEST_CASE(PartitionAlert) CCriticalSection csDummy; CBlockIndex indexDummy[800]; CChainParams& params = Params(CBaseChainParams::MAIN); - int64_t nPowTargetSpacing = params.GetConsensus().nPowTargetSpacing; + int64_t nPowTargetSpacing = params.GetConsensus(0).nPowTargetSpacing; // Generate fake blockchain timestamps relative to // an arbitrary time: diff --git a/src/test/auxpow_tests.cpp b/src/test/auxpow_tests.cpp index 566c88feb..24c0bf263 100644 --- a/src/test/auxpow_tests.cpp +++ b/src/test/auxpow_tests.cpp @@ -180,7 +180,7 @@ CAuxpowBuilder::buildCoinbaseData(bool header, const std::vector<unsigned char>& BOOST_AUTO_TEST_CASE(check_auxpow) { - const Consensus::Params& params = Params().GetConsensus(); + const Consensus::Params& params = Params().GetConsensus(371337); CAuxpowBuilder builder(5, 42); CAuxPow auxpow; @@ -339,16 +339,16 @@ mineBlock(CBlockHeader& block, bool ok, int nBits = -1) } if (ok) - BOOST_CHECK(CheckProofOfWork(block.GetPoWHash(), nBits, Params().GetConsensus())); + BOOST_CHECK(CheckProofOfWork(block.GetPoWHash(), nBits, Params().GetConsensus(371337))); else - BOOST_CHECK(!CheckProofOfWork(block.GetPoWHash(), nBits, Params().GetConsensus())); + BOOST_CHECK(!CheckProofOfWork(block.GetPoWHash(), nBits, Params().GetConsensus(371337))); } BOOST_AUTO_TEST_CASE(auxpow_pow) { /* Use regtest parameters to allow mining with easy difficulty. */ SelectParams(CBaseChainParams::REGTEST); - const Consensus::Params& params = Params().GetConsensus(); + const Consensus::Params& params = Params().GetConsensus(371337); const arith_uint256 target = (~arith_uint256(0) >> 1); CBlockHeader block; diff --git a/src/test/data/bitcoin-util-test.json b/src/test/data/bitcoin-util-test.json index 6090421cb..1cf3e598d 100644 --- a/src/test/data/bitcoin-util-test.json +++ b/src/test/data/bitcoin-util-test.json @@ -39,8 +39,8 @@ "in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:0", "in=bf829c6bcf84579331337659d31f89dfd138f7f7785802d5501c92333145ca7c:18", "in=22a6f904655d53ae2ff70e701a0bbd90aa3975c0f40bfc6cc996a9049e31cdfc:1", - "outaddr=0.18:13tuJJDR2RgArmgfv6JScSdreahzgc4T6o", - "outaddr=4:1P8yWvZW8jVihP1bzHeqfE4aoXNX8AVa46"], + "outaddr=0.18:D82zqZA4KqaTPmsGegJ1ACoTXiSJ21NcZd", + "outaddr=4:DTH54BW9S9Q1EPCCiseQCzEBgf6pTRZv3U"], "output_cmp": "txcreate1.hex" }, { "exec": "./bitcoin-tx", @@ -51,10 +51,10 @@ "args": ["-create", "in=4d49a71ec9da436f71ec4ee231d04f292a29cd316f598bb7068feccabdc59485:0", - "set=privatekeys:[\"5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf\"]", + "set=privatekeys:[\"6J8csdv3eDrnJcpSEb4shfjMh2JTiG9MKzC1Yfge4Y4GyUsjdM6\"]", "set=prevtxs:[{\"txid\":\"4d49a71ec9da436f71ec4ee231d04f292a29cd316f598bb7068feccabdc59485\",\"vout\":0,\"scriptPubKey\":\"4d49a71ec9da436f71ec4ee231d04f292a29cd316f598bb7068feccabdc59485\"}]", "sign=ALL", - "outaddr=0.001:193P6LtvS4nCnkDvM9uXn1gsSRqh4aDAz7"], + "outaddr=0.001:DDBUdbqZjUgVKkQX5ju6KmrUKZZzPu2aZc"], "output_cmp": "txcreatesign.hex" } ] diff --git a/src/test/dogecoin_tests.cpp b/src/test/dogecoin_tests.cpp index 4a8d08089..7185b377a 100644 --- a/src/test/dogecoin_tests.cpp +++ b/src/test/dogecoin_tests.cpp @@ -63,7 +63,7 @@ BOOST_AUTO_TEST_CASE(subsidy_limit_test) { int nHeight = 0; int nStepSize= 1; - const Consensus::Params& params = Params(CBaseChainParams::MAIN).GetConsensus(); + const Consensus::Params& params = Params(CBaseChainParams::MAIN).GetConsensus(0); CAmount nSum = 0; uint256 prevHash = uint256S("0"); @@ -105,7 +105,7 @@ BOOST_AUTO_TEST_CASE(subsidy_limit_test) BOOST_AUTO_TEST_CASE(get_next_work_difficulty_limit) { SelectParams(CBaseChainParams::MAIN); - const Consensus::Params& params = Params().GetConsensus(); + const Consensus::Params& params = Params().GetConsensus(0); CBlockIndex pindexLast; int64_t nLastRetargetTime = 1386474927; // Block # 1 @@ -119,7 +119,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_difficulty_limit) BOOST_AUTO_TEST_CASE(get_next_work_pre_digishield) { SelectParams(CBaseChainParams::MAIN); - const Consensus::Params& params = Params().GetConsensus(); + const Consensus::Params& params = Params().GetConsensus(0); CBlockIndex pindexLast; int64_t nLastRetargetTime = 1386942008; // Block 9359 @@ -133,7 +133,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_pre_digishield) BOOST_AUTO_TEST_CASE(get_next_work_digishield) { SelectParams(CBaseChainParams::MAIN); - const Consensus::Params& params = Params().GetConsensus(); + const Consensus::Params& params = Params().GetConsensus(145000); CBlockIndex pindexLast; int64_t nLastRetargetTime = 1395094427; @@ -148,7 +148,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_digishield) BOOST_AUTO_TEST_CASE(get_next_work_digishield_modulated_upper) { SelectParams(CBaseChainParams::MAIN); - const Consensus::Params& params = Params().GetConsensus(); + const Consensus::Params& params = Params().GetConsensus(145000); CBlockIndex pindexLast; int64_t nLastRetargetTime = 1395100835; @@ -163,7 +163,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_digishield_modulated_upper) BOOST_AUTO_TEST_CASE(get_next_work_digishield_modulated_lower) { SelectParams(CBaseChainParams::MAIN); - const Consensus::Params& params = Params().GetConsensus(); + const Consensus::Params& params = Params().GetConsensus(145000); CBlockIndex pindexLast; int64_t nLastRetargetTime = 1395380517; @@ -178,7 +178,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_digishield_modulated_lower) BOOST_AUTO_TEST_CASE(get_next_work_digishield_rounding) { SelectParams(CBaseChainParams::MAIN); - const Consensus::Params& params = Params().GetConsensus(); + const Consensus::Params& params = Params().GetConsensus(145000); CBlockIndex pindexLast; int64_t nLastRetargetTime = 1395094679; @@ -191,4 +191,40 @@ BOOST_AUTO_TEST_CASE(get_next_work_digishield_rounding) BOOST_CHECK_EQUAL(CalculateDogecoinNextWorkRequired(&pindexLast, nLastRetargetTime, params), 0x1b6558a4); } +BOOST_AUTO_TEST_CASE(hardfork_parameters) +{ + SelectParams(CBaseChainParams::MAIN); + const Consensus::Params& initialParams = Params().GetConsensus(0); + + BOOST_CHECK_EQUAL(initialParams.nPowTargetTimespan, 14400); + BOOST_CHECK_EQUAL(initialParams.fAllowLegacyBlocks, true); + BOOST_CHECK_EQUAL(initialParams.fDigishieldDifficultyCalculation, false); + + const Consensus::Params& initialParamsEnd = Params().GetConsensus(144999); + BOOST_CHECK_EQUAL(initialParamsEnd.nPowTargetTimespan, 14400); + BOOST_CHECK_EQUAL(initialParamsEnd.fAllowLegacyBlocks, true); + BOOST_CHECK_EQUAL(initialParamsEnd.fDigishieldDifficultyCalculation, false); + + const Consensus::Params& digishieldParams = Params().GetConsensus(145000); + BOOST_CHECK_EQUAL(digishieldParams.nPowTargetTimespan, 60); + BOOST_CHECK_EQUAL(digishieldParams.fAllowLegacyBlocks, true); + BOOST_CHECK_EQUAL(digishieldParams.fDigishieldDifficultyCalculation, true); + + const Consensus::Params& digishieldParamsEnd = Params().GetConsensus(371336); + BOOST_CHECK_EQUAL(digishieldParamsEnd.nPowTargetTimespan, 60); + BOOST_CHECK_EQUAL(digishieldParamsEnd.fAllowLegacyBlocks, true); + BOOST_CHECK_EQUAL(digishieldParamsEnd.fDigishieldDifficultyCalculation, true); + + const Consensus::Params& auxpowParams = Params().GetConsensus(371337); + BOOST_CHECK_EQUAL(auxpowParams.nHeightEffective, 371337); + BOOST_CHECK_EQUAL(auxpowParams.nPowTargetTimespan, 60); + BOOST_CHECK_EQUAL(auxpowParams.fAllowLegacyBlocks, false); + BOOST_CHECK_EQUAL(auxpowParams.fDigishieldDifficultyCalculation, true); + + const Consensus::Params& auxpowHighParams = Params().GetConsensus(700000); // Arbitrary point after last hard-fork + BOOST_CHECK_EQUAL(auxpowHighParams.nPowTargetTimespan, 60); + BOOST_CHECK_EQUAL(auxpowHighParams.fAllowLegacyBlocks, false); + BOOST_CHECK_EQUAL(auxpowHighParams.fDigishieldDifficultyCalculation, true); +} + BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/pow_tests.cpp b/src/test/pow_tests.cpp index fad447362..fcd86c3d5 100644 --- a/src/test/pow_tests.cpp +++ b/src/test/pow_tests.cpp @@ -18,7 +18,7 @@ BOOST_FIXTURE_TEST_SUITE(pow_tests, BasicTestingSetup) /* BOOST_AUTO_TEST_CASE(get_next_work) { SelectParams(CBaseChainParams::MAIN); - const Consensus::Params& params = Params().GetConsensus(); + const Consensus::Params& params = Params().GetConsensus(0); int64_t nLastRetargetTime = 1261130161; // Block #30240 CBlockIndex pindexLast; @@ -33,7 +33,7 @@ BOOST_FIXTURE_TEST_SUITE(pow_tests, BasicTestingSetup) /* BOOST_AUTO_TEST_CASE(get_next_work_pow_limit) { SelectParams(CBaseChainParams::MAIN); - const Consensus::Params& params = Params().GetConsensus(); + const Consensus::Params& params = Params().GetConsensus(0); int64_t nLastRetargetTime = 1231006505; // Block #0 CBlockIndex pindexLast; @@ -48,7 +48,7 @@ BOOST_FIXTURE_TEST_SUITE(pow_tests, BasicTestingSetup) /* BOOST_AUTO_TEST_CASE(get_next_work_lower_limit_actual) { SelectParams(CBaseChainParams::MAIN); - const Consensus::Params& params = Params().GetConsensus(); + const Consensus::Params& params = Params().GetConsensus(0); int64_t nLastRetargetTime = 1279008237; // Block #66528 CBlockIndex pindexLast; @@ -63,7 +63,7 @@ BOOST_FIXTURE_TEST_SUITE(pow_tests, BasicTestingSetup) /* BOOST_AUTO_TEST_CASE(get_next_work_upper_limit_actual) { SelectParams(CBaseChainParams::MAIN); - const Consensus::Params& params = Params().GetConsensus(); + const Consensus::Params& params = Params().GetConsensus(0); int64_t nLastRetargetTime = 1263163443; // NOTE: Not an actual block time CBlockIndex pindexLast; @@ -76,7 +76,7 @@ BOOST_FIXTURE_TEST_SUITE(pow_tests, BasicTestingSetup) BOOST_AUTO_TEST_CASE(GetBlockProofEquivalentTime_test) { SelectParams(CBaseChainParams::MAIN); - const Consensus::Params& params = Params().GetConsensus(); + const Consensus::Params& params = Params().GetConsensus(0); std::vector<CBlockIndex> blocks(10000); for (int i = 0; i < 10000; i++) { |