aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFabian Jahr <fjahr@protonmail.com>2020-08-11 00:01:53 +0200
committerFabian Jahr <fjahr@protonmail.com>2020-08-11 14:04:02 +0200
commita51d0ad2de89b9757d158df95ddeba2bfcb23935 (patch)
treec7dde24190e668e26b2e86cd88ca4d8f251e18d1 /test
parentf306384f5a9006307eec7ace9fc8433aa1a8ed84 (diff)
downloadbitcoin-a51d0ad2de89b9757d158df95ddeba2bfcb23935.tar.xz
rpc: Improve addnode remove command error message
This also adds test coverage for the remove command which was uncovered before.
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/rpc_net.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/functional/rpc_net.py b/test/functional/rpc_net.py
index 3336246c8b..674e034809 100755
--- a/test/functional/rpc_net.py
+++ b/test/functional/rpc_net.py
@@ -131,6 +131,13 @@ class NetTest(BitcoinTestFramework):
added_nodes = self.nodes[0].getaddednodeinfo(ip_port)
assert_equal(len(added_nodes), 1)
assert_equal(added_nodes[0]['addednode'], ip_port)
+ # check that node cannot be added again
+ assert_raises_rpc_error(-23, "Node already added", self.nodes[0].addnode, node=ip_port, command='add')
+ # check that node can be removed
+ self.nodes[0].addnode(node=ip_port, command='remove')
+ assert_equal(self.nodes[0].getaddednodeinfo(), [])
+ # check that trying to remove the node again returns an error
+ assert_raises_rpc_error(-24, "Node could not be removed", self.nodes[0].addnode, node=ip_port, command='remove')
# check that a non-existent node returns an error
assert_raises_rpc_error(-24, "Node has not been added", self.nodes[0].getaddednodeinfo, '1.1.1.1')