Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpc_net.py
Show First 20 Lines • Show All 82 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(ip_port, 'add') | self.nodes[0].addnode(ip_port, '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 a non-existant 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): | ||||
peer_info = [x.getpeerinfo() for x in self.nodes] | peer_info = [x.getpeerinfo() for x in self.nodes] | ||||
# check both sides of bidirectional connection between nodes | # check both sides of bidirectional connection between nodes | ||||
# the address bound to on one side will be the source address for the other node | # the address bound to on one side will be the source address for the other node | ||||
assert_equal(peer_info[0][0]['addrbind'], peer_info[1][0]['addr']) | assert_equal(peer_info[0][0]['addrbind'], peer_info[1][0]['addr']) | ||||
assert_equal(peer_info[1][0]['addrbind'], peer_info[0][0]['addr']) | assert_equal(peer_info[1][0]['addrbind'], peer_info[0][0]['addr']) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
NetTest().main() | NetTest().main() |