2021-08-11 06:18:40 +02:00
|
|
|
// Copyright (c) 2014-2019 The Bitcoin Core developers
|
2014-12-13 05:09:33 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2014-03-18 10:11:00 +01:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2020-03-19 23:46:56 +01:00
|
|
|
#include <net.h>
|
2023-06-01 16:57:52 +02:00
|
|
|
#include <uint256.h>
|
|
|
|
#include <validation.h>
|
2014-02-19 01:54:11 +01:00
|
|
|
|
2022-02-25 18:19:25 +01:00
|
|
|
#include <test/util/setup_common.h>
|
2015-03-09 15:04:12 +01:00
|
|
|
|
2015-04-01 16:03:11 +02:00
|
|
|
#include <boost/signals2/signal.hpp>
|
2014-02-19 01:54:11 +01:00
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
|
2021-08-11 06:18:40 +02:00
|
|
|
BOOST_FIXTURE_TEST_SUITE(validation_tests, TestingSetup)
|
2014-02-19 01:54:11 +01:00
|
|
|
|
2018-05-04 22:42:39 +02:00
|
|
|
static bool ReturnFalse() { return false; }
|
|
|
|
static bool ReturnTrue() { return true; }
|
2015-03-05 13:01:01 +01:00
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(test_combiner_all)
|
|
|
|
{
|
|
|
|
boost::signals2::signal<bool (), CombinerAll> Test;
|
|
|
|
BOOST_CHECK(Test());
|
|
|
|
Test.connect(&ReturnFalse);
|
|
|
|
BOOST_CHECK(!Test());
|
|
|
|
Test.connect(&ReturnTrue);
|
|
|
|
BOOST_CHECK(!Test());
|
|
|
|
Test.disconnect(&ReturnFalse);
|
|
|
|
BOOST_CHECK(Test());
|
|
|
|
Test.disconnect(&ReturnTrue);
|
|
|
|
BOOST_CHECK(Test());
|
|
|
|
}
|
2023-06-01 16:57:52 +02:00
|
|
|
|
|
|
|
//! Test retrieval of valid assumeutxo values.
|
|
|
|
BOOST_AUTO_TEST_CASE(test_assumeutxo)
|
|
|
|
{
|
|
|
|
const auto params = CreateChainParams(CBaseChainParams::REGTEST);
|
|
|
|
|
|
|
|
// These heights don't have assumeutxo configurations associated, per the contents
|
|
|
|
// of chainparams.cpp.
|
|
|
|
std::vector<int> bad_heights{0, 100, 111, 115, 209, 211};
|
|
|
|
|
|
|
|
for (auto empty : bad_heights) {
|
|
|
|
const auto out = ExpectedAssumeutxo(empty, *params);
|
|
|
|
BOOST_CHECK(!out);
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto out110 = *ExpectedAssumeutxo(110, *params);
|
2023-06-06 12:31:17 +02:00
|
|
|
BOOST_CHECK_EQUAL(out110.hash_serialized, uint256S("9b2a277a3e3b979f1a539d57e949495d7f8247312dbc32bce6619128c192b44b"));
|
2023-06-01 16:57:52 +02:00
|
|
|
BOOST_CHECK_EQUAL(out110.nChainTx, (unsigned int)110);
|
|
|
|
|
|
|
|
const auto out210 = *ExpectedAssumeutxo(210, *params);
|
2023-06-06 12:31:17 +02:00
|
|
|
BOOST_CHECK_EQUAL(out210.hash_serialized, uint256S("d4c97d32882583b057efc3dce673e44204851435e6ffcef20346e69cddc7c91e"));
|
2023-06-01 16:57:52 +02:00
|
|
|
BOOST_CHECK_EQUAL(out210.nChainTx, (unsigned int)210);
|
|
|
|
}
|
|
|
|
|
2014-02-19 01:54:11 +01:00
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|