Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpc_net.py
Show First 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | def test_getaddednodeinfo(self): | ||||
assert_equal(self.nodes[0].getaddednodeinfo(), []) | assert_equal(self.nodes[0].getaddednodeinfo(), []) | ||||
# add a node (node2) to node0 | # add a node (node2) to node0 | ||||
ip_port = "127.0.0.1:{}".format(p2p_port(2)) | ip_port = "127.0.0.1:{}".format(p2p_port(2)) | ||||
self.nodes[0].addnode(node=ip_port, command='add') | self.nodes[0].addnode(node=ip_port, command='add') | ||||
# check that the node has indeed been added | # check that the node has indeed been added | ||||
added_nodes = self.nodes[0].getaddednodeinfo(ip_port) | added_nodes = self.nodes[0].getaddednodeinfo(ip_port) | ||||
assert_equal(len(added_nodes), 1) | assert_equal(len(added_nodes), 1) | ||||
assert_equal(added_nodes[0]['addednode'], ip_port) | 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 | # check that a non-existent node returns an error | ||||
assert_raises_rpc_error(-24, "Node has not been added", | assert_raises_rpc_error(-24, "Node has not been added", | ||||
self.nodes[0].getaddednodeinfo, '1.1.1.1') | self.nodes[0].getaddednodeinfo, '1.1.1.1') | ||||
def test_getpeerinfo(self): | def test_getpeerinfo(self): | ||||
self.log.info("Test getpeerinfo") | self.log.info("Test getpeerinfo") | ||||
# Create a few getpeerinfo last_block/last_transaction/last_proof | # Create a few getpeerinfo last_block/last_transaction/last_proof | ||||
# values. | # values. | ||||
▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines |