def test_add_contact_with_full_replacement_cache(self):
        parent_node_id = '0xdeadbeef'
        r = RoutingTable(parent_node_id)
        # Fill up the bucket and replacement cache
        for i in range(40):
            contact = PeerNode(PUBLIC_KEY, "192.168.0.%d" % i, 9999,
                               self.version, 0)
            contact.network_id = hex(i)
            r.add_contact(contact)
        # Sanity check of the replacement cache.
        self.assertEqual(len(r._replacement_cache[0]), 20)
        self.assertEqual(hex(20), r._replacement_cache[0][0].network_id)
        # Create a new contact that will be added to the replacement cache.
        new_contact = PeerNode(PUBLIC_KEY, "192.168.0.20", 9999, self.version,
                               0)
        new_contact.network_id = hex(40)
        r.add_contact(new_contact)
        self.assertEqual(len(r._replacement_cache[0]), 20)
        self.assertEqual(new_contact, r._replacement_cache[0][19])
        self.assertEqual(hex(21), r._replacement_cache[0][0].network_id)
Ensures that if the replacement cache is full (length = k) then the
dataset/ETHPy150Open ntoll/p4p2p/test/dht/test_routingtable.py/TestRoutingTable.test_add_contact_with_full_replacement_cache