Changeset View
Changeset View
Standalone View
Standalone View
src/test/timedata_tests.cpp
// Copyright (c) 2011-2019 The Bitcoin Core developers | // Copyright (c) 2011-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 <timedata.h> | #include <timedata.h> | ||||
#include <netaddress.h> | #include <netaddress.h> | ||||
#include <noui.h> | #include <noui.h> | ||||
#include <test/util/logging.h> | #include <test/util/logging.h> | ||||
#include <util/string.h> | #include <util/string.h> | ||||
#include <util/translation.h> | |||||
#include <warnings.h> | #include <warnings.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> | ||||
#include <string> | #include <string> | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(addtimedata) { | ||||
{ | { | ||||
ASSERT_DEBUG_LOG( | ASSERT_DEBUG_LOG( | ||||
"Please check that your computer's date and time are correct!"); | "Please check that your computer's date and time are correct!"); | ||||
// filter size 5 | // filter size 5 | ||||
MultiAddTimeData(1, DEFAULT_MAX_TIME_ADJUSTMENT + 1); | MultiAddTimeData(1, DEFAULT_MAX_TIME_ADJUSTMENT + 1); | ||||
} | } | ||||
BOOST_CHECK(GetWarnings(true).find("clock is wrong") != std::string::npos); | BOOST_CHECK(GetWarnings(true).original.find("clock is wrong") != | ||||
std::string::npos); | |||||
// nTimeOffset is not changed if the median of offsets exceeds | // nTimeOffset is not changed if the median of offsets exceeds | ||||
// DEFAULT_MAX_TIME_ADJUSTMENT | // DEFAULT_MAX_TIME_ADJUSTMENT | ||||
BOOST_CHECK_EQUAL(GetTimeOffset(), 0); | BOOST_CHECK_EQUAL(GetTimeOffset(), 0); | ||||
// Part 2: Test positive and negative medians by adding more offsets | // Part 2: Test positive and negative medians by adding more offsets | ||||
// filter size 9 | // filter size 9 | ||||
MultiAddTimeData(4, 100); | MultiAddTimeData(4, 100); | ||||
Show All 34 Lines |