upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/selftest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/selftest.cpp')
-rw-r--r--src/selftest.cpp37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/selftest.cpp b/src/selftest.cpp
index a0d9edd..4cb872e 100644
--- a/src/selftest.cpp
+++ b/src/selftest.cpp
@@ -11,6 +11,7 @@
11#include "proxy.h" 11#include "proxy.h"
12#include "selftest.h" 12#include "selftest.h"
13#include "sockcount.h" 13#include "sockcount.h"
14#include "tor.h"
14#include "walletcmd.h" 15#include "walletcmd.h"
15 16
16extern int RunPoolStratumSelfTest(); 17extern int RunPoolStratumSelfTest();
@@ -1565,6 +1566,38 @@ static int RunSocks5ProxySelfTest()
1565 return nFail == 0 ? 0 : 1; 1566 return nFail == 0 ? 0 : 1;
1566} 1567}
1567 1568
1569static int RunManagedTorSelfTest()
1570{
1571 printf("managed-tor self-test\n");
1572 int nFail = 0;
1573
1574 std::string torrc = BtfBuildManagedTorrcForTest("C:/Bitflash Managed Tor/data",
1575 "C:/Bitflash Managed Tor/onion-service",
1576 19050, 8433);
1577 nFail += Check(torrc.find("DataDirectory \"C:/Bitflash Managed Tor/data\"") != std::string::npos,
1578 "quotes the Tor data directory") ? 0 : 1;
1579 nFail += Check(torrc.find("SocksPort 127.0.0.1:19050") != std::string::npos,
1580 "binds SOCKS5 to localhost only") ? 0 : 1;
1581 nFail += Check(torrc.find("IsolateSOCKSAuth") != std::string::npos &&
1582 torrc.find("IsolateClientAddr") != std::string::npos &&
1583 torrc.find("IsolateDestAddr") != std::string::npos &&
1584 torrc.find("IsolateDestPort") != std::string::npos,
1585 "enables strict Tor stream isolation") ? 0 : 1;
1586 nFail += Check(torrc.find("HiddenServiceDir \"C:/Bitflash Managed Tor/onion-service\"") != std::string::npos,
1587 "writes a hidden service directory") ? 0 : 1;
1588 nFail += Check(torrc.find("HiddenServiceVersion 3") != std::string::npos,
1589 "requests a v3 onion service") ? 0 : 1;
1590 nFail += Check(torrc.find("HiddenServicePort 8433 127.0.0.1:8433") != std::string::npos,
1591 "maps the onion service to the Bitflash P2P listener") ? 0 : 1;
1592 nFail += Check(BtfManagedTorStatus() == "disabled",
1593 "managed Tor starts disabled") ? 0 : 1;
1594
1595 printf("%s (%d failure%s)\n", nFail == 0 ? "ALL TESTS PASSED" : "TESTS FAILED",
1596 nFail, nFail == 1 ? "" : "s");
1597 fflush(stdout);
1598 return nFail == 0 ? 0 : 1;
1599}
1600
1568int RunSelfTest(const std::string& name) 1601int RunSelfTest(const std::string& name)
1569{ 1602{
1570 AttachTerminal(); 1603 AttachTerminal();
@@ -1589,8 +1622,10 @@ int RunSelfTest(const std::string& name)
1589 return RunParseMoneySelfTest(); 1622 return RunParseMoneySelfTest();
1590 if (name == "socks5-proxy") 1623 if (name == "socks5-proxy")
1591 return RunSocks5ProxySelfTest(); 1624 return RunSocks5ProxySelfTest();
1625 if (name == "managed-tor")
1626 return RunManagedTorSelfTest();
1592 1627
1593 printf("Unknown self-test '%s'\n", name.c_str()); 1628 printf("Unknown self-test '%s'\n", name.c_str());
1594 printf("Known self-tests: wallet-keypool, wallet-hd, wallet-format, wallet-crypto, wallet-encrypt, net-message, consensus-limits, pool-stratum, parse-money, socks5-proxy\n"); 1629 printf("Known self-tests: wallet-keypool, wallet-hd, wallet-format, wallet-crypto, wallet-encrypt, net-message, consensus-limits, pool-stratum, parse-money, socks5-proxy, managed-tor\n");
1595 return 1; 1630 return 1;
1596} 1631}