diff options
| author | Bitflash <admin@bitflash.network> | 2026-08-13 14:21:15 -0300 |
|---|---|---|
| committer | Bitflash <admin@bitflash.network> | 2026-08-13 14:21:15 -0300 |
| commit | 5dec9b16a5b98ed0e24ec7113b867f22be2d0026 (patch) | |
| tree | e06544e9e7516203bc4309460438a0486b0328e4 /src/selftest.cpp | |
| parent | c009e7cc0c5093f4c4add741cb9d131d19956871 (diff) | |
| parent | 1bf78c53404d83638177889590ce199c87af63bc (diff) | |
Merge pull request 'net: add managed Tor hidden service bootstrap' (#33) from embedded-tor-manager into main
Diffstat (limited to 'src/selftest.cpp')
| -rw-r--r-- | src/selftest.cpp | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/selftest.cpp b/src/selftest.cpp index a0d9edd..3c93927 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 | ||
| 16 | extern int RunPoolStratumSelfTest(); | 17 | extern int RunPoolStratumSelfTest(); |
| @@ -1565,6 +1566,41 @@ static int RunSocks5ProxySelfTest() | |||
| 1565 | return nFail == 0 ? 0 : 1; | 1566 | return nFail == 0 ? 0 : 1; |
| 1566 | } | 1567 | } |
| 1567 | 1568 | ||
| 1569 | static 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, 19051, 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("ControlPort 127.0.0.1:19051") != std::string::npos && | ||
| 1582 | torrc.find("CookieAuthentication 1") != std::string::npos, | ||
| 1583 | "binds an authenticated Tor control port to localhost only") ? 0 : 1; | ||
| 1584 | nFail += Check(torrc.find("IsolateSOCKSAuth") != std::string::npos && | ||
| 1585 | torrc.find("IsolateClientAddr") != std::string::npos && | ||
| 1586 | torrc.find("IsolateDestAddr") != std::string::npos && | ||
| 1587 | torrc.find("IsolateDestPort") != std::string::npos, | ||
| 1588 | "enables strict Tor stream isolation") ? 0 : 1; | ||
| 1589 | nFail += Check(torrc.find("HiddenServiceDir \"C:/Bitflash Managed Tor/onion-service\"") != std::string::npos, | ||
| 1590 | "writes a hidden service directory") ? 0 : 1; | ||
| 1591 | nFail += Check(torrc.find("HiddenServiceVersion 3") != std::string::npos, | ||
| 1592 | "requests a v3 onion service") ? 0 : 1; | ||
| 1593 | nFail += Check(torrc.find("HiddenServicePort 8433 127.0.0.1:8433") != std::string::npos, | ||
| 1594 | "maps the onion service to the Bitflash P2P listener") ? 0 : 1; | ||
| 1595 | nFail += Check(BtfManagedTorStatus() == "disabled", | ||
| 1596 | "managed Tor starts disabled") ? 0 : 1; | ||
| 1597 | |||
| 1598 | printf("%s (%d failure%s)\n", nFail == 0 ? "ALL TESTS PASSED" : "TESTS FAILED", | ||
| 1599 | nFail, nFail == 1 ? "" : "s"); | ||
| 1600 | fflush(stdout); | ||
| 1601 | return nFail == 0 ? 0 : 1; | ||
| 1602 | } | ||
| 1603 | |||
| 1568 | int RunSelfTest(const std::string& name) | 1604 | int RunSelfTest(const std::string& name) |
| 1569 | { | 1605 | { |
| 1570 | AttachTerminal(); | 1606 | AttachTerminal(); |
| @@ -1589,8 +1625,10 @@ int RunSelfTest(const std::string& name) | |||
| 1589 | return RunParseMoneySelfTest(); | 1625 | return RunParseMoneySelfTest(); |
| 1590 | if (name == "socks5-proxy") | 1626 | if (name == "socks5-proxy") |
| 1591 | return RunSocks5ProxySelfTest(); | 1627 | return RunSocks5ProxySelfTest(); |
| 1628 | if (name == "managed-tor") | ||
| 1629 | return RunManagedTorSelfTest(); | ||
| 1592 | 1630 | ||
| 1593 | printf("Unknown self-test '%s'\n", name.c_str()); | 1631 | 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"); | 1632 | 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; | 1633 | return 1; |
| 1596 | } | 1634 | } |