Changeset View
Changeset View
Standalone View
Standalone View
src/test/validation_chainstatemanager_tests.cpp
// Copyright (c) 2019 The Bitcoin Core developers | // Copyright (c) 2019 The Bitcoin Core 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 <chainparams.h> | #include <chainparams.h> | ||||
#include <config.h> | #include <config.h> | ||||
#include <consensus/validation.h> | #include <consensus/validation.h> | ||||
#include <random.h> | #include <random.h> | ||||
#include <sync.h> | #include <sync.h> | ||||
#include <test/util/setup_common.h> | #include <test/util/setup_common.h> | ||||
#include <validation.h> | #include <validation.h> | ||||
#include <validationinterface.h> | |||||
#include <vector> | #include <vector> | ||||
#include <boost/test/unit_test.hpp> | #include <boost/test/unit_test.hpp> | ||||
BOOST_FIXTURE_TEST_SUITE(validation_chainstatemanager_tests, TestingSetup) | BOOST_FIXTURE_TEST_SUITE(validation_chainstatemanager_tests, TestingSetup) | ||||
//! Basic tests for ChainstateManager. | //! Basic tests for ChainstateManager. | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(chainstatemanager) { | ||||
auto &validated_chain = manager.ValidatedChain(); | auto &validated_chain = manager.ValidatedChain(); | ||||
BOOST_CHECK_EQUAL(&validated_chain, &c1.m_chain); | BOOST_CHECK_EQUAL(&validated_chain, &c1.m_chain); | ||||
auto validated_tip = manager.ValidatedTip(); | auto validated_tip = manager.ValidatedTip(); | ||||
exp_tip = c1.m_chain.Tip(); | exp_tip = c1.m_chain.Tip(); | ||||
BOOST_CHECK_EQUAL(validated_tip, exp_tip); | BOOST_CHECK_EQUAL(validated_tip, exp_tip); | ||||
// Avoid triggering the address sanitizer. | // Let scheduler events finish running to avoid accessing memory that is | ||||
// going to be unloaded | |||||
SyncWithValidationInterfaceQueue(); | |||||
WITH_LOCK(::cs_main, manager.Unload()); | WITH_LOCK(::cs_main, manager.Unload()); | ||||
} | } | ||||
BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() |