mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-29 00:45:50 +01:00
test: refactor: Give unit test functions access to test state
Add unit test subclasses as needed so unit test functions that need to access members like m_rng can reference it directly.
This commit is contained in:
@@ -43,8 +43,9 @@ static CService ip(uint32_t i)
|
||||
return CService{CNetAddr{s}, Params().GetDefaultPort()};
|
||||
}
|
||||
|
||||
struct PeerTest : LogIPsTestingSetup {
|
||||
/** Create a peer and connect to it. If the optional `address` (IP/CJDNS only) isn't passed, a random address is created. */
|
||||
static void AddPeer(NodeId& id, std::vector<CNode*>& nodes, PeerManager& peerman, ConnmanTestMsg& connman, ConnectionType conn_type, bool onion_peer = false, std::optional<std::string> address = std::nullopt)
|
||||
void AddPeer(NodeId& id, std::vector<CNode*>& nodes, PeerManager& peerman, ConnmanTestMsg& connman, ConnectionType conn_type, bool onion_peer = false, std::optional<std::string> address = std::nullopt)
|
||||
{
|
||||
CAddress addr{};
|
||||
|
||||
@@ -80,8 +81,9 @@ static void AddPeer(NodeId& id, std::vector<CNode*>& nodes, PeerManager& peerman
|
||||
|
||||
connman.AddTestNode(node);
|
||||
}
|
||||
}; // struct PeerTest
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_addnode_getaddednodeinfo_and_connection_detection)
|
||||
BOOST_FIXTURE_TEST_CASE(test_addnode_getaddednodeinfo_and_connection_detection, PeerTest)
|
||||
{
|
||||
auto connman = std::make_unique<ConnmanTestMsg>(0x1337, 0x1337, *m_node.addrman, *m_node.netgroupman, Params());
|
||||
auto peerman = PeerManager::make(*connman, *m_node.addrman, nullptr, *m_node.chainman, *m_node.mempool, *m_node.warnings, {});
|
||||
|
||||
Reference in New Issue
Block a user