From 8ef665d5e4765366b1c47a2ce7054d783ccca9d0 Mon Sep 17 00:00:00 2001 From: Ross Nicoll Date: Sun, 30 Sep 2018 15:38:37 +0100 Subject: Replace test data with Dogecoin values Replace test data with Dogecoin equivalents in the folowing tests: * base58 * bip32 * keys * miner * pow * wallet Replace RPC and deterministic signatures in unit tests with Dogecoin values. While conventionally I'd use an alternative implementation for these, as RFC 6979 compliant signature generation isn't terribly common, and there's no reason to suspect we've modified this code, I'm going to assert that it's good enough to test that the code doesn't provide different values. Disabled Bitcoin PoW tests, but left code in place to simplify later merges. These are replaced by the Dogecoin PoW tests. --- src/test/main_tests.cpp | 60 ++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 28 deletions(-) (limited to 'src/test/main_tests.cpp') diff --git a/src/test/main_tests.cpp b/src/test/main_tests.cpp index 5b3f2bc57..93456298f 100644 --- a/src/test/main_tests.cpp +++ b/src/test/main_tests.cpp @@ -15,47 +15,51 @@ BOOST_FIXTURE_TEST_SUITE(main_tests, TestingSetup) static void TestBlockSubsidyHalvings(const Consensus::Params& consensusParams) { - int maxHalvings = 64; - CAmount nInitialSubsidy = 50 * COIN; + // tested in dogecoin_tests.cpp + //int maxHalvings = 64; + //CAmount nInitialSubsidy = 50 * COIN; - CAmount nPreviousSubsidy = nInitialSubsidy * 2; // for height == 0 - BOOST_CHECK_EQUAL(nPreviousSubsidy, nInitialSubsidy * 2); - for (int nHalvings = 0; nHalvings < maxHalvings; nHalvings++) { - int nHeight = nHalvings * consensusParams.nSubsidyHalvingInterval; - CAmount nSubsidy = GetBlockSubsidy(nHeight, consensusParams); - BOOST_CHECK(nSubsidy <= nInitialSubsidy); - BOOST_CHECK_EQUAL(nSubsidy, nPreviousSubsidy / 2); - nPreviousSubsidy = nSubsidy; - } - BOOST_CHECK_EQUAL(GetBlockSubsidy(maxHalvings * consensusParams.nSubsidyHalvingInterval, consensusParams), 0); + //CAmount nPreviousSubsidy = nInitialSubsidy * 2; // for height == 0 + //BOOST_CHECK_EQUAL(nPreviousSubsidy, nInitialSubsidy * 2); + //for (int nHalvings = 0; nHalvings < maxHalvings; nHalvings++) { + // int nHeight = nHalvings * consensusParams.nSubsidyHalvingInterval; + // CAmount nSubsidy = GetBlockSubsidy(nHeight, consensusParams); + // BOOST_CHECK(nSubsidy <= nInitialSubsidy); + // BOOST_CHECK_EQUAL(nSubsidy, nPreviousSubsidy / 2); + // nPreviousSubsidy = nSubsidy; + //} + //BOOST_CHECK_EQUAL(GetBlockSubsidy(maxHalvings * consensusParams.nSubsidyHalvingInterval, consensusParams), 0); } static void TestBlockSubsidyHalvings(int nSubsidyHalvingInterval) { - Consensus::Params consensusParams; - consensusParams.nSubsidyHalvingInterval = nSubsidyHalvingInterval; - TestBlockSubsidyHalvings(consensusParams); + // tested in dogecoin_tests.cpp + //Consensus::Params consensusParams; + //consensusParams.nSubsidyHalvingInterval = nSubsidyHalvingInterval; + //TestBlockSubsidyHalvings(consensusParams); } BOOST_AUTO_TEST_CASE(block_subsidy_test) { - const auto chainParams = CreateChainParams(CBaseChainParams::MAIN); - TestBlockSubsidyHalvings(chainParams->GetConsensus()); // As in main - TestBlockSubsidyHalvings(150); // As in regtest - TestBlockSubsidyHalvings(1000); // Just another interval + // tested in dogecoin_tests.cpp + //const auto chainParams = CreateChainParams(CBaseChainParams::MAIN); + //TestBlockSubsidyHalvings(chainParams->GetConsensus()); // As in main + //TestBlockSubsidyHalvings(150); // As in regtest + //TestBlockSubsidyHalvings(1000); // Just another interval } BOOST_AUTO_TEST_CASE(subsidy_limit_test) { - const auto chainParams = CreateChainParams(CBaseChainParams::MAIN); - CAmount nSum = 0; - for (int nHeight = 0; nHeight < 14000000; nHeight += 1000) { - CAmount nSubsidy = GetBlockSubsidy(nHeight, chainParams->GetConsensus()); - BOOST_CHECK(nSubsidy <= 50 * COIN); - nSum += nSubsidy * 1000; - BOOST_CHECK(MoneyRange(nSum)); - } - BOOST_CHECK_EQUAL(nSum, CAmount{2099999997690000}); + // tested in dogecoin_tests.cpp + //const auto chainParams = CreateChainParams(CBaseChainParams::MAIN); + //CAmount nSum = 0; + //for (int nHeight = 0; nHeight < 14000000; nHeight += 1000) { + // CAmount nSubsidy = GetBlockSubsidy(nHeight, chainParams->GetConsensus()); + // BOOST_CHECK(nSubsidy <= 50 * COIN); + // nSum += nSubsidy * 1000; + // BOOST_CHECK(MoneyRange(nSum)); + //} + //BOOST_CHECK_EQUAL(nSum, CAmount{2099999997690000}); } static bool ReturnFalse() { return false; } -- cgit v1.2.3