Skip to content

Commit effd1ef

Browse files
committed
test: addnode with an invalid command should throw an error
1 parent 56b27b8 commit effd1ef

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

test/functional/rpc_net.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def run_test(self):
6161
self.test_getpeerinfo()
6262
self.test_getnettotals()
6363
self.test_getnetworkinfo()
64-
self.test_getaddednodeinfo()
64+
self.test_addnode_getaddednodeinfo()
6565
self.test_service_flags()
6666
self.test_getnodeaddresses()
6767
self.test_addpeeraddress()
@@ -203,8 +203,8 @@ def test_getnetworkinfo(self):
203203
# Check dynamically generated networks list in getnetworkinfo help output.
204204
assert "(ipv4, ipv6, onion, i2p, cjdns)" in self.nodes[0].help("getnetworkinfo")
205205

206-
def test_getaddednodeinfo(self):
207-
self.log.info("Test getaddednodeinfo")
206+
def test_addnode_getaddednodeinfo(self):
207+
self.log.info("Test addnode and getaddednodeinfo")
208208
assert_equal(self.nodes[0].getaddednodeinfo(), [])
209209
# add a node (node2) to node0
210210
ip_port = "127.0.0.1:{}".format(p2p_port(2))
@@ -218,6 +218,8 @@ def test_getaddednodeinfo(self):
218218
# check that node can be removed
219219
self.nodes[0].addnode(node=ip_port, command='remove')
220220
assert_equal(self.nodes[0].getaddednodeinfo(), [])
221+
# check that an invalid command returns an error
222+
assert_raises_rpc_error(-1, 'addnode "node" "command"', self.nodes[0].addnode, node=ip_port, command='abc')
221223
# check that trying to remove the node again returns an error
222224
assert_raises_rpc_error(-24, "Node could not be removed", self.nodes[0].addnode, node=ip_port, command='remove')
223225
# check that a non-existent node returns an error

0 commit comments

Comments
 (0)