research/erasure_code/ec65536/test_ec65536.py

28 lines
836 B
Python
Raw Normal View History

import ec65536
import rlp
2017-04-18 11:26:05 +00:00
import time
# 12.8 kilobyte test string
testdata = 'the cow jumped over the moon!!! ' * 400
2017-04-18 11:26:05 +00:00
t1 = time.time()
prover = ec65536.Prover(testdata)
2017-04-18 11:26:05 +00:00
t2 = time.time()
print("Created prover in %.2f sec" % (t2 - t1))
assert ec65536.verify_proof(prover.merkle_root, prover.prove(13), 13)
2017-04-18 11:26:05 +00:00
t3 = time.time()
print("Created and verified a proof in %.2f sec" % (t3 - t2))
proofs = [prover.prove(i) for i in range(0, prover.length, 2)]
print("Created merkle proofs")
2017-04-18 11:26:05 +00:00
t4 = time.time()
print("Starting to attempt fill")
response = ec65536.fill(prover.merkle_root, prover.length // 2, proofs, list(range(0, prover.length, 2)))
2017-04-18 11:26:05 +00:00
t5 = time.time()
print("Completed fill in %.2f sec" % (t5 - t4))
assert response is not False
assert b''.join(response)[:len(rlp.encode(testdata))] == rlp.encode(testdata)
print("Fill successful")