Skip to content
Bitcoin Roots

v29.4-roots.3 · Commit 3: [PATCH 03/30] policy: restore conservative relay and network controls

test/functional/p2p_v2_encrypted.py

Before: test/functional/p2p_v2_encrypted.py · After: test/functional/p2p_v2_encrypted.py

File metadata
index 3e8ce09d24d54a2bf1b6c988df46bfa36c49e749..acb5bf0c226503825e97b8536d2df321a9ec9484 100755

Download original patch · Release notes

Diff rows 1–37 of 37. Line numbers refer to the original before/after files.

+ Added− RemovedUnmarked lines are context.

Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.

test/functional/p2p_v2_encrypted.py CHANGED
@@ -18,8 +18,10 @@ from test_framework.util import (
18
18
  assert_equal,
19
19
  assert_greater_than,
20
20
  check_node_connections,
21
+ p2p_port,
21
22
  )
22
23
  from test_framework.crypto.chacha20 import REKEY_INTERVAL
24
+ from test_framework.socks5 import Socks5Configuration, Socks5Server
23
25
 
24
26
 
25
27
  class P2PEncrypted(BitcoinTestFramework):
@@ -129,6 +131,27 @@ class P2PEncrypted(BitcoinTestFramework):
129
131
  assert_equal(node0.getpeerinfo()[-1]["transport_protocol_type"], "v1")
130
132
  check_node_connections(node=node0, num_in=1, num_out=0)
131
133
 
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
+
132
155
 
133
156
  if __name__ == '__main__':
134
157
  P2PEncrypted(__file__).main()