v30.3-roots.1 · Commit 3: [PATCH 03/68] feat(policy): preserve Roots relay and network controls on Core 30.3
test/functional/p2p_permissions.py
Before: test/functional/p2p_permissions.py · After: test/functional/p2p_permissions.py
File metadata
index 543cd3194b49baae40b5f6ae7bfbb33ffbc71111..01738abf623cbe24b85d2b314f4a6487b75849fc 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']))
|