Skip to content
Bitcoin Roots

v31.1-roots.1 · Commit 17: [PATCH 17/17] fix(release): preserve notice bytes and integrate nightly fixes

test/functional/p2p_disconnect_ban.py

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

File metadata
index a829e316faf41d3827484fbef43803b4ba7e53bd..8a4ba48ac87bdfe083c4c535abbb26a8b22dc8b2 100755

Download original patch · Release notes

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

+ Added− RemovedUnmarked lines are context.

Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.

test/functional/p2p_disconnect_ban.py CHANGED
@@ -11,6 +11,8 @@ from test_framework.test_framework import BitcoinTestFramework
11
  from test_framework.util import (
12
  assert_equal,
13
  assert_raises_rpc_error,
 
 
14
  )
15
 
16
  class DisconnectBanTest(BitcoinTestFramework):
@@ -129,6 +131,17 @@ class DisconnectBanTest(BitcoinTestFramework):
129
  self.log.info("disconnectnode: fail to disconnect when calling with junk address")
130
  assert_raises_rpc_error(-29, "Node not found in connected nodes", self.nodes[0].disconnectnode, address="221B Baker Street")
131
 
 
 
 
 
 
 
 
 
 
 
 
132
  self.log.info("disconnectnode: successfully disconnect node by address")
133
  address1 = self.nodes[0].getpeerinfo()[0]['addr']
134
  self.nodes[0].disconnectnode(address=address1)
 
11
  from test_framework.util import (
12
  assert_equal,
13
  assert_raises_rpc_error,
14
+ get_rpc_proxy,
15
+ rpc_url,
16
  )
17
 
18
  class DisconnectBanTest(BitcoinTestFramework):
 
131
  self.log.info("disconnectnode: fail to disconnect when calling with junk address")
132
  assert_raises_rpc_error(-29, "Node not found in connected nodes", self.nodes[0].disconnectnode, address="221B Baker Street")
133
 
134
+ self.log.info("disconnectnode: fail to disconnect when calling with invalid subnet containing NUL")
135
+ # Process arguments cannot carry NUL bytes, so use JSON-RPC for this input even with --usecli.
136
+ node = self.nodes[0]
137
+ rpc = get_rpc_proxy(
138
+ rpc_url(node.datadir_path, node.index, self.chain, node.rpchost),
139
+ node.index,
140
+ timeout=node.rpc_timeout,
141
+ coveragedir=node.coverage_dir,
142
+ )
143
+ assert_raises_rpc_error(-8, "Invalid subnet", rpc.disconnectnode, address="1.2.3.0/24\0")
144
+
145
  self.log.info("disconnectnode: successfully disconnect node by address")
146
  address1 = self.nodes[0].getpeerinfo()[0]['addr']
147
  self.nodes[0].disconnectnode(address=address1)