Skip to content

Commit 5e3fa67

Browse files
committed
test: Check that v1 connections to clearnet peers don't work
when `-v2onlyclearnet` is turned on: - v1 connections to clearnet peers don't work - v2 connections to clearnet peers work - v1 conneections to tor/i2p/cjdns peer works a proxy is used because otherwise NET_UNROUTABLE is the default network in the tests.
1 parent 25eb4d0 commit 5e3fa67

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/functional/p2p_v2_encrypted.py

+23
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
assert_equal,
1919
assert_greater_than,
2020
check_node_connections,
21+
p2p_port,
2122
)
2223
from test_framework.crypto.chacha20 import REKEY_INTERVAL
24+
from test_framework.socks5 import Socks5Configuration, Socks5Server
2325

2426

2527
class P2PEncrypted(BitcoinTestFramework):
@@ -129,6 +131,27 @@ def run_test(self):
129131
assert_equal(node0.getpeerinfo()[-1]["transport_protocol_type"], "v1")
130132
check_node_connections(node=node0, num_in=1, num_out=0)
131133

134+
conf = Socks5Configuration()
135+
conf.auth = True
136+
conf.unauth = True
137+
conf.addr = ('127.0.0.1', p2p_port(self.num_nodes))
138+
conf.keep_alive = True
139+
proxy = Socks5Server(conf)
140+
proxy.start()
141+
args = ['-listen', f'-proxy={conf.addr[0]}:{conf.addr[1]}', '-proxyrandomize=0', '-v2onlyclearnet=1', '-v2transport=1']
142+
self.restart_node(0, extra_args=args)
143+
self.log.info("Test -v2onlyclearnet=1 behaviour")
144+
self.log.info("Check that outbound v2 connection to an ipv4 peer is successful")
145+
node0.addnode("15.61.23.23:1234", "onetry", True)
146+
assert_equal(node0.getpeerinfo()[-1]["addr"], "15.61.23.23:1234")
147+
self.log.info("Check that outbound v1 connection to an ipv4 peer is unsuccessful")
148+
node0.addnode("8.8.8.8:1234", "onetry", False)
149+
assert all(peer["addr"] != "8.8.8.8:1234" for peer in node0.getpeerinfo())
150+
self.log.info("Check that outbound v1 connection to an onion peer is successful")
151+
addr = "pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion:8333"
152+
node0.addnode(addr, "onetry", False)
153+
assert_equal(node0.getpeerinfo()[-1]["addr"], addr)
154+
132155

133156
if __name__ == '__main__':
134157
P2PEncrypted(__file__).main()

0 commit comments

Comments
 (0)