[Pkg-bitcoin-commits] [bitcoin] 113/126: Add CConnmanTest to mutate g_connman in tests
Jonas Smedegaard
dr at jones.dk
Mon Nov 13 20:03:00 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag debian/0.15.1_dfsg-1
in repository bitcoin.
commit 2ed0647ac1d6c14ff1be11f8d5284c0dc645fc18
Author: João Barbosa <joao.paulo.barbosa at gmail.com>
Date: Tue Oct 24 09:26:05 2017 +0100
Add CConnmanTest to mutate g_connman in tests
Github-Pull: #11560
Rebased-From: 83df25736ebaa23777e965d265ed677a8d79f23f
---
src/net.h | 2 ++
src/test/test_bitcoin.cpp | 12 ++++++++++++
src/test/test_bitcoin.h | 6 ++++++
3 files changed, 20 insertions(+)
diff --git a/src/net.h b/src/net.h
index 83f2d96..6b57d5c 100644
--- a/src/net.h
+++ b/src/net.h
@@ -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);
diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp
index 10959ad..01e2a55 100644
--- a/src/test/test_bitcoin.cpp
+++ b/src/test/test_bitcoin.cpp
@@ -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);
diff --git a/src/test/test_bitcoin.h b/src/test/test_bitcoin.h
index 5a39f8a..642be47 100644
--- a/src/test/test_bitcoin.h
+++ b/src/test/test_bitcoin.h
@@ -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;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-bitcoin/bitcoin.git
More information about the Pkg-bitcoin-commits
mailing list