def test(self, hash_func_for_type, _): # Setup isd_as = ISD_AS("1-11") if_ids = [1, 2, 3] hashes = [ b"s10", b"10s10", b"s20", b"20s20", b"s30", b"30s30", b"0", b"30s300", b"10s1020s20", b"10s1020s2030s300", b"s20" ] hash_func = create_mock_full(side_effect=hashes) hash_func_for_type.return_value = hash_func inst = HashTree(isd_as, if_ids, b"s", 1, HashType.SHA256) inst._depth = 2 inst.create_tree(if_ids) # Call proof = inst.get_proof(2, 0, "prev", "next") # Tests ntools.eq_(proof.p.isdas, int(isd_as)) ntools.eq_(proof.p.nonce, b"s20") ntools.eq_(proof.p.siblings[0].isLeft, True) ntools.eq_(proof.p.siblings[0].hash, b"10s10") ntools.eq_(proof.p.siblings[1].isLeft, False) ntools.eq_(proof.p.siblings[1].hash, b"30s300")
def test(self, _): # Setup isd_as = ISD_AS("1-11") if_ids = [1, 2, 3] hashes = [ b"s10", b"10s10", b"s20", b"20s20", b"s30", b"30s30", b"0", b"30s300", b"10s1020s20", b"10s1020s2030s300", b"s20" ] hash_new = create_mock_full({"digest()...": hashes}) hash_func = create_mock_full({"new()": hash_new}) inst = HashTree(isd_as, if_ids, b"s", hash_func) inst._n_epochs = 1 inst._depth = 2 inst.create_tree(if_ids) # Call proof = inst.get_proof(2, 0, "prev", "next") # Tests ntools.eq_(proof.p.isdas, int(isd_as)) ntools.eq_(proof.p.nonce, b"s20") ntools.eq_(proof.p.siblings[0].isLeft, True) ntools.eq_(proof.p.siblings[0].hash, b"10s10") ntools.eq_(proof.p.siblings[1].isLeft, False) ntools.eq_(proof.p.siblings[1].hash, b"30s300")