summaryrefslogtreecommitdiff
path: root/tools/testcase1.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/testcase1.py')
-rwxr-xr-xtools/testcase1.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/testcase1.py b/tools/testcase1.py
index 415d475..ce322f1 100755
--- a/tools/testcase1.py
+++ b/tools/testcase1.py
@@ -84,8 +84,15 @@ def get_and_validate_proof(timestamp, chain, leaf_index, nentries):
leaf_hash = get_leaf_hash(merkle_tree_leaf)
sth = get_sth(baseurl)
proof = get_proof_by_hash(baseurl, leaf_hash, sth["tree_size"])
- assert_equal(proof["leaf_index"], leaf_index, "leaf_index")
- assert_equal(len(proof["audit_path"]), nentries, "audit_path length")
+ leaf_index = proof["leaf_index"]
+ inclusion_proof = [base64.b64decode(e) for e in proof["audit_path"]]
+ assert_equal(leaf_index, leaf_index, "leaf_index")
+ assert_equal(len(inclusion_proof), nentries, "audit_path length")
+
+ calc_root_hash = verify_inclusion_proof(inclusion_proof, leaf_index, sth["tree_size"], leaf_hash)
+ root_hash = base64.b64decode(sth["sha256_root_hash"])
+
+ assert_equal(root_hash, calc_root_hash, "verified root hash", nodata=True)
get_and_check_entry(timestamp, chain, leaf_index)
def get_and_check_entry(timestamp, chain, leaf_index):