Browse Source

Add CConnmanTest to mutate g_connman in tests

Github-Pull: #11560
Rebased-From: 83df25736e
tags/v0.15.1
João Barbosa 3 years ago
parent
commit
2ed0647ac1
3 changed files with 20 additions and 0 deletions
  1. 2
    0
      src/net.h
  2. 12
    0
      src/test/test_bitcoin.cpp
  3. 6
    0
      src/test/test_bitcoin.h

+ 2
- 0
src/net.h View File

@@ -434,6 +434,8 @@ private:
* in excess of nMaxOutbound
* This takes the place of a feeler connection */
std::atomic_bool m_try_another_outbound_peer;

friend struct CConnmanTest;
};
extern std::unique_ptr<CConnman> g_connman;
void Discover(boost::thread_group& threadGroup);

+ 12
- 0
src/test/test_bitcoin.cpp View File

@@ -24,6 +24,18 @@

#include <memory>

void CConnmanTest::AddNode(CNode& node)
{
LOCK(g_connman->cs_vNodes);
g_connman->vNodes.push_back(&node);
}

void CConnmanTest::ClearNodes()
{
LOCK(g_connman->cs_vNodes);
g_connman->vNodes.clear();
}

uint256 insecure_rand_seed = GetRandHash();
FastRandomContext insecure_rand_ctx(insecure_rand_seed);


+ 6
- 0
src/test/test_bitcoin.h View File

@@ -49,6 +49,12 @@ struct BasicTestingSetup {
* Included are data directory, coins database, script check threads setup.
*/
class CConnman;
class CNode;
struct CConnmanTest {
static void AddNode(CNode& node);
static void ClearNodes();
};

class PeerLogicValidation;
struct TestingSetup: public BasicTestingSetup {
CCoinsViewDB *pcoinsdbview;

Loading…
Cancel
Save