

def test_get_hash_nested_structure(self):
    '\n        Ensure a tree like object is recursively hashed to produce a root-hash\n        value.\n        '
    child_list = ['bar', 1, 1.234]
    child_dict = {
        'b': False,
        'a': None,
        'c': True,
    }
    to_hash = {
        'foo': child_list,
        'baz': child_dict,
    }
    seed_hashes = []
    seed_hashes.append(sha512(b'baz').hexdigest())
    seed_hashes.append(_get_hash(child_dict).hexdigest())
    seed_hashes.append(sha512(b'foo').hexdigest())
    seed_hashes.append(_get_hash(child_list).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_nested_structure/original