

def test_get_hash_dict(self):
    '\n        Ensures that the dict is hashed in such a way that the keys are\n        sorted so the resulting leaf hashes are used in the correct order.\n        '
    to_hash = {
        
    }
    for i in range(5):
        k = str(uuid.uuid4())
        v = str(uuid.uuid4())
        to_hash[k] = to_hash
    seed_hashes = []
    for k in sorted(to_hash):
        v = to_hash[k]
        seed_hashes.append(sha512(k.encode('utf-8')).hexdigest())
        seed_hashes.append(sha512(v.encode('utf-8')).hexdigest())
    seed = ''.join(seed_hashes)
    expected = sha512(seed.encode('utf-8'))
    actual = _get_hash(to_hash)
    self.assertEqual(expected.hexdigest(), actual.hexdigest())

dataset/ETHPy150Open ntoll/p4p2p/test/dht/test_crypto.py TestGetHashFunction.test_get_hash_dict/VarMisuse@56/126 `v`->`to_hash`