예제 #1
0
 def _test_getpeerinfo(self):
     self.log.info("Test getpeerinfo")
     connect_nodes(self.nodes, 0, 1)
     res = self.nodes[0].getpeerinfo()
     assert_equal(len(res), 1)
     assert_equal(len(self.nodes[1].getpeerinfo()), 1)
     assert_equal(res[0]['addr'], get_peer_addr(self.nodes[1]))
     self.nodes[0].removenode(self.nodes[1].key, get_peer_addr(self.nodes[1]))
     try:
         wait_until(lambda: len(self.nodes[0].getpeerinfo()) == 0, timeout=10)
     except Exception:
         assert False
예제 #2
0
    def test_disconnect_with_remove(self, client0: RpcClient):
        n = self.connect_nodes(client0, 3)

        assert client0.disconnect_peer(self.nodes[3].key, client0.UPDATE_NODE_OP_REMOVE)

        # On node 0: node 3 is blacklisted, and cannot immediately add it again
        assert client0.get_node(self.nodes[3].key) is None
        self.nodes[0].addnode(self.nodes[3].key, get_peer_addr(self.nodes[3]))
        assert client0.get_node(self.nodes[3].key) is None

        # On node 3: add node 0 as trusted node, so that try to create
        # outgoing connection to node 0.
        client3 = RpcClient(self.nodes[3])
        self.nodes[3].addnode(self.nodes[0].key, get_peer_addr(self.nodes[0]))
        node0 = client3.get_node(self.nodes[0].key)
        assert node0[0] == "trusted"

        # Node 3 create more outgoing connection, but it's blacklisted in node 0.
        time.sleep((self.test_house_keeping_ms + 100) / 1000)
        peer0 = client3.get_peer(self.nodes[0].key)
        # refused during handshake or not handshaked yet
        assert peer0 is None or len(peer0["protocols"]) == 0