Skip to content

Commit 97c112d

Browse files
committed
Declare TorReply parsing functions in torcontrol_tests
Rather than including the implementation file into the test, which is bad practice.
1 parent d82c5d1 commit 97c112d

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/test/torcontrol_tests.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,18 @@
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44
//
55
#include <test/test_bitcoin.h>
6-
#include <torcontrol.cpp>
6+
#include <torcontrol.h>
77

88
#include <boost/test/unit_test.hpp>
99

10+
#include <map>
11+
#include <string>
12+
#include <utility>
13+
14+
15+
std::pair<std::string, std::string> SplitTorReplyLine(const std::string& s);
16+
std::map<std::string, std::string> ParseTorReplyMapping(const std::string& s);
17+
1018

1119
BOOST_FIXTURE_TEST_SUITE(torcontrol_tests, BasicTestingSetup)
1220

src/torcontrol.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ bool TorControlConnection::Command(const std::string &cmd, const ReplyHandlerCB&
251251
* Grammar is implicitly defined in https://spec.torproject.org/control-spec by
252252
* the server reply formats for PROTOCOLINFO (S3.21) and AUTHCHALLENGE (S3.24).
253253
*/
254-
static std::pair<std::string,std::string> SplitTorReplyLine(const std::string &s)
254+
std::pair<std::string,std::string> SplitTorReplyLine(const std::string &s)
255255
{
256256
size_t ptr=0;
257257
std::string type;
@@ -270,7 +270,7 @@ static std::pair<std::string,std::string> SplitTorReplyLine(const std::string &s
270270
* the server reply formats for PROTOCOLINFO (S3.21), AUTHCHALLENGE (S3.24),
271271
* and ADD_ONION (S3.27). See also sections 2.1 and 2.3.
272272
*/
273-
static std::map<std::string,std::string> ParseTorReplyMapping(const std::string &s)
273+
std::map<std::string,std::string> ParseTorReplyMapping(const std::string &s)
274274
{
275275
std::map<std::string,std::string> mapping;
276276
size_t ptr=0;
@@ -773,4 +773,3 @@ void StopTorControl()
773773
gBase = nullptr;
774774
}
775775
}
776-

0 commit comments

Comments
 (0)