Bitcoin Core 30.99.0
P2P Digital Currency
Classes | Macros | Typedefs | Functions | Variables
headers_sync_chainwork_tests.cpp File Reference
#include <chain.h>
#include <chainparams.h>
#include <consensus/params.h>
#include <headerssync.h>
#include <net_processing.h>
#include <pow.h>
#include <test/util/setup_common.h>
#include <validation.h>
#include <cstddef>
#include <vector>
#include <boost/test/unit_test.hpp>
Include dependency graph for headers_sync_chainwork_tests.cpp:

Go to the source code of this file.

Classes

struct  HeadersGeneratorSetup
 

Macros

#define CHECK_RESULT(result_expression, hss, exp_state, exp_success, exp_request_more, exp_headers_size, exp_pow_validated_prev, exp_locator_hash)
 

Typedefs

using State = HeadersSyncState::State
 

Functions

 BOOST_AUTO_TEST_CASE (sneaky_redownload)
 
 BOOST_AUTO_TEST_CASE (happy_path)
 
 BOOST_AUTO_TEST_CASE (too_little_work)
 

Variables

constexpr size_t TARGET_BLOCKS {15'000}
 
constexpr arith_uint256 CHAIN_WORK {TARGET_BLOCKS * 2}
 
constexpr size_t REDOWNLOAD_BUFFER_SIZE {TARGET_BLOCKS - (MAX_HEADERS_RESULTS + 123)}
 
constexpr size_t COMMITMENT_PERIOD {600}
 

Macro Definition Documentation

◆ CHECK_RESULT

#define CHECK_RESULT (   result_expression,
  hss,
  exp_state,
  exp_success,
  exp_request_more,
  exp_headers_size,
  exp_pow_validated_prev,
  exp_locator_hash 
)
Value:
do { \
const auto result{result_expression}; \
BOOST_REQUIRE_EQUAL(hss.GetState(), exp_state); \
BOOST_CHECK_EQUAL(result.success, exp_success); \
BOOST_CHECK_EQUAL(result.request_more, exp_request_more); \
BOOST_CHECK_EQUAL(result.pow_validated_headers.size(), exp_headers_size); \
const std::optional<uint256> pow_validated_prev_opt{exp_pow_validated_prev}; \
if (pow_validated_prev_opt) { \
BOOST_CHECK_EQUAL(result.pow_validated_headers.at(0).hashPrevBlock, pow_validated_prev_opt); \
} else { \
BOOST_CHECK_EQUAL(exp_headers_size, 0); \
} \
const std::optional<uint256> locator_hash_opt{exp_locator_hash}; \
if (locator_hash_opt) { \
BOOST_CHECK_EQUAL(hss.NextHeadersRequestLocator().vHave.at(0), locator_hash_opt); \
} else { \
BOOST_CHECK_EQUAL(exp_state, State::FINAL); \
} \
} while (false)
@ FINAL
We're done syncing with this peer and can discard any remaining state.

Definition at line 22 of file headers_sync_chainwork_tests.cpp.

Typedef Documentation

◆ State

Definition at line 19 of file headers_sync_chainwork_tests.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/3]

BOOST_AUTO_TEST_CASE ( happy_path  )

Definition at line 182 of file headers_sync_chainwork_tests.cpp.

◆ BOOST_AUTO_TEST_CASE() [2/3]

BOOST_AUTO_TEST_CASE ( sneaky_redownload  )

Definition at line 143 of file headers_sync_chainwork_tests.cpp.

◆ BOOST_AUTO_TEST_CASE() [3/3]

BOOST_AUTO_TEST_CASE ( too_little_work  )

Definition at line 225 of file headers_sync_chainwork_tests.cpp.

Variable Documentation

◆ CHAIN_WORK

constexpr arith_uint256 CHAIN_WORK {TARGET_BLOCKS * 2}
constexpr

Definition at line 45 of file headers_sync_chainwork_tests.cpp.

◆ COMMITMENT_PERIOD

constexpr size_t COMMITMENT_PERIOD {600}
constexpr

Definition at line 51 of file headers_sync_chainwork_tests.cpp.

◆ REDOWNLOAD_BUFFER_SIZE

constexpr size_t REDOWNLOAD_BUFFER_SIZE {TARGET_BLOCKS - (MAX_HEADERS_RESULTS + 123)}
constexpr

Definition at line 50 of file headers_sync_chainwork_tests.cpp.

◆ TARGET_BLOCKS

constexpr size_t TARGET_BLOCKS {15'000}
constexpr

Definition at line 44 of file headers_sync_chainwork_tests.cpp.