Skip to content
Bitcoin Roots

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

test/functional/p2p_permissions.py

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

File metadata
index c37061c307ca88553e175c79e0acaafb9b01e7cd..305ff31be2cb1d5db7e117c1b6caf13ce1cc685c 100755

Download original patch · Release notes

Diff rows 1–68 of 68. 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_permissions.py CHANGED
@@ -35,7 +35,7 @@ class P2PPermissionsTests(BitcoinTestFramework):
35
35
  # default permissions (no specific permissions)
36
36
  ["-whitelist=127.0.0.1"],
37
37
  # Make sure the default values in the command line documentation match the ones here
38
- ["relay", "noban", "mempool", "download"])
38
+ ["addr", "relay", "noban", "mempool", "download"])
39
39
 
40
40
  self.checkpermission(
41
41
  # no permission (even with forcerelay)
@@ -45,14 +45,14 @@ class P2PPermissionsTests(BitcoinTestFramework):
45
45
  self.checkpermission(
46
46
  # relay permission removed (no specific permissions)
47
47
  ["-whitelist=127.0.0.1", "-whitelistrelay=0"],
48
- ["noban", "mempool", "download"])
48
+ ["addr", "noban", "mempool", "download"])
49
49
 
50
50
  self.checkpermission(
51
51
  # forcerelay and relay permission added
52
52
  # Legacy parameter interaction which set whitelistrelay to true
53
53
  # if whitelistforcerelay is true
54
54
  ["-whitelist=127.0.0.1", "-whitelistforcerelay"],
55
- ["forcerelay", "relay", "noban", "mempool", "download"])
55
+ ["addr", "forcerelay", "relay", "noban", "mempool", "download"])
56
56
 
57
57
  # Let's make sure permissions are merged correctly
58
58
  # For this, we need to use whitebind instead of bind
@@ -86,9 +86,18 @@ class P2PPermissionsTests(BitcoinTestFramework):
86
86
  self.checkpermission(
87
87
  # all permission added
88
88
  ["-whitelist=all@127.0.0.1"],
89
- ["forcerelay", "noban", "mempool", "bloomfilter", "relay", "download", "addr"])
90
-
91
- for flag, permissions in [(["-whitelist=noban,out@127.0.0.1"], ["noban", "download"]), (["-whitelist=noban@127.0.0.1"], [])]:
89
+ [
90
+ "blockfilters",
91
+ "forcerelay",
92
+ "noban",
93
+ "mempool",
94
+ "bloomfilter",
95
+ "relay",
96
+ "download",
97
+ "addr",
98
+ ])
99
+
100
+ for flag, permissions in [(["-whitelist=noban,out@127.0.0.1"], ["bloomfilter", "noban", "download"]), (["-whitelist=noban@127.0.0.1"], ["bloomfilter"])]:
92
101
  self.restart_node(0, flag)
93
102
  self.connect_nodes(0, 1)
94
103
  peerinfo = self.nodes[0].getpeerinfo()[0]
@@ -100,6 +109,15 @@ class P2PPermissionsTests(BitcoinTestFramework):
100
109
  self.nodes[1].assert_start_raises_init_error(["-whitelist=noban@127.0.0.1:230"], "Invalid netmask specified in", match=ErrorMatch.PARTIAL_REGEX)
101
110
  self.nodes[1].assert_start_raises_init_error(["-whitebind=noban@127.0.0.1/10"], "Cannot resolve -whitebind address", match=ErrorMatch.PARTIAL_REGEX)
102
111
  self.nodes[1].assert_start_raises_init_error(["-whitebind=noban@127.0.0.1", "-bind=127.0.0.1", "-listen=0"], "Cannot set -bind or -whitebind together with -listen=0", match=ErrorMatch.PARTIAL_REGEX)
112
+ for permission_arg in [
113
+ "-whitelist=blockfilters@127.0.0.1",
114
+ f"-whitebind=blockfilters@127.0.0.1:{p2p_port(self.nodes[1].index)}",
115
+ ]:
116
+ self.nodes[1].assert_start_raises_init_error(
117
+ [permission_arg],
118
+ "Cannot grant blockfilters permission without -blockfilterindex.",
119
+ match=ErrorMatch.PARTIAL_REGEX,
120
+ )
103
121
 
104
122
  def check_tx_relay(self):
105
123
  self.log.debug("Create a connection from a forcerelay peer that rebroadcasts raw txs")
@@ -145,7 +163,7 @@ class P2PPermissionsTests(BitcoinTestFramework):
145
163
  )
146
164
 
147
165
  def checkpermission(self, args, expectedPermissions):
148
- self.restart_node(1, args)
166
+ self.restart_node(1, ['-peerbloomfilters=0'] + args)
149
167
  self.connect_nodes(0, 1)
150
168
  peerinfo = self.nodes[1].getpeerinfo()[0]
151
169
  assert_equal(len(expectedPermissions), len(peerinfo['permissions']))