示例#1
0
 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"
     ]
     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
     # Call
     inst.create_tree(if_ids)
     # Tests
     expected = [
         b"10s1020s2030s300", b"10s1020s20", b"30s300", b"10s10", b"20s20",
         b"30s30", b"0"
     ]
     ntools.eq_(inst._nodes, expected)
示例#2
0
 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")