Bitcoin Core 28.99.0
P2P Digital Currency
Public Member Functions | Public Attributes | List of all members
BasicTestingSetup Struct Reference

Basic testing setup. More...

#include <setup_common.h>

Inheritance diagram for BasicTestingSetup:
[legend]
Collaboration diagram for BasicTestingSetup:
[legend]

Public Member Functions

void SeedRandomForTest (SeedRand seed)
 Seed the global RNG state and m_rng for testing and log the seed value. More...
 
 BasicTestingSetup (const ChainType chainType=ChainType::MAIN, TestOpts={})
 
 ~BasicTestingSetup ()
 

Public Attributes

util::SignalInterrupt m_interrupt
 
node::NodeContext m_node
 
FastRandomContext m_rng
 
fs::path m_path_root
 
fs::path m_path_lock
 
bool m_has_custom_datadir {false}
 
ArgsManager m_args
 Test-specific arguments and settings. More...
 

Detailed Description

Basic testing setup.

This just configures logging, data dir and chain parameters.

Definition at line 63 of file setup_common.h.

Constructor & Destructor Documentation

◆ BasicTestingSetup()

BasicTestingSetup::BasicTestingSetup ( const ChainType  chainType = ChainType::MAIN,
TestOpts  opts = {} 
)
explicit

Definition at line 108 of file setup_common.cpp.

Here is the call graph for this function:

◆ ~BasicTestingSetup()

BasicTestingSetup::~BasicTestingSetup ( )

Definition at line 198 of file setup_common.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ SeedRandomForTest()

void BasicTestingSetup::SeedRandomForTest ( SeedRand  seed)
inline

Seed the global RNG state and m_rng for testing and log the seed value.

This affects all randomness, except GetStrongRandBytes().

Definition at line 69 of file setup_common.h.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_args

ArgsManager BasicTestingSetup::m_args

Test-specific arguments and settings.

This member is intended to be the primary source of settings for code being tested by unit tests. It exists to make tests more self-contained and reduce reliance on global state.

Usage guidelines:

  1. Prefer using m_args where possible in test code.
  2. If m_args is not accessible, use m_node.args as a fallback.
  3. Avoid direct references to gArgs in test code.

Note: Currently, m_node.args points to gArgs for backwards compatibility. In the future, it will point to m_args to further isolate test environments.

See also
https://github.com/bitcoin/bitcoin/issues/25055 for additional context.

Definition at line 98 of file setup_common.h.

◆ m_has_custom_datadir

bool BasicTestingSetup::m_has_custom_datadir {false}

Definition at line 80 of file setup_common.h.

◆ m_interrupt

util::SignalInterrupt BasicTestingSetup::m_interrupt

Definition at line 64 of file setup_common.h.

◆ m_node

node::NodeContext BasicTestingSetup::m_node

Definition at line 65 of file setup_common.h.

◆ m_path_lock

fs::path BasicTestingSetup::m_path_lock

Definition at line 79 of file setup_common.h.

◆ m_path_root

fs::path BasicTestingSetup::m_path_root

Definition at line 78 of file setup_common.h.

◆ m_rng

FastRandomContext BasicTestingSetup::m_rng

Definition at line 67 of file setup_common.h.


The documentation for this struct was generated from the following files: