Changeset View
Changeset View
Standalone View
Standalone View
src/test/activation_tests.cpp
// Copyright (c) 2019 The Bitcoin developers | // Copyright (c) 2019 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <chain.h> | |||||
Fabien: That looks unrelated | |||||
PiRKAuthorUnsubmitted Done Inline ActionsMy IDE informed me that removing CBlockIndex from here made that import unused. It is probably a good idea for me to split this refactoring into a separate review. PiRK: My IDE informed me that removing CBlockIndex from here made that import unused. It is probably… | |||||
#include <chainparams.h> | #include <chainparams.h> | ||||
#include <consensus/activation.h> | #include <consensus/activation.h> | ||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <test/util/block_utils.h> | |||||
#include <test/util/setup_common.h> | #include <test/util/setup_common.h> | ||||
#include <boost/test/unit_test.hpp> | #include <boost/test/unit_test.hpp> | ||||
BOOST_FIXTURE_TEST_SUITE(activation_tests, BasicTestingSetup) | BOOST_FIXTURE_TEST_SUITE(activation_tests, BasicTestingSetup) | ||||
static void SetMTP(std::array<CBlockIndex, 12> &blocks, int64_t mtp) { | |||||
size_t len = blocks.size(); | |||||
for (size_t i = 0; i < len; ++i) { | |||||
blocks[i].nTime = mtp + (i - (len / 2)); | |||||
} | |||||
BOOST_CHECK_EQUAL(blocks.back().GetMedianTimePast(), mtp); | |||||
} | |||||
static void testPastActivation( | static void testPastActivation( | ||||
std::function<bool(const Consensus::Params &, const CBlockIndex *)> func, | std::function<bool(const Consensus::Params &, const CBlockIndex *)> func, | ||||
const Consensus::Params ¶ms, int activationHeight) { | const Consensus::Params ¶ms, int activationHeight) { | ||||
BOOST_CHECK(!func(params, nullptr)); | BOOST_CHECK(!func(params, nullptr)); | ||||
std::array<CBlockIndex, 4> blocks; | std::array<CBlockIndex, 4> blocks; | ||||
blocks[0].nHeight = activationHeight - 2; | blocks[0].nHeight = activationHeight - 2; | ||||
for (size_t i = 1; i < blocks.size(); ++i) { | for (size_t i = 1; i < blocks.size(); ++i) { | ||||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |
That looks unrelated