fix anonvdf tests
This commit is contained in:
parent
505eee6aa3
commit
fb0bc2351b
@ -27,11 +27,12 @@ class TestAnonVDF(unittest.TestCase):
|
|||||||
anonvdf.AnonVDFGenerator.validate_id(test_id, test_data, rounds=rds)
|
anonvdf.AnonVDFGenerator.validate_id(test_id, test_data, rounds=rds)
|
||||||
|
|
||||||
def test_vdf_block_validate_not_enough(self):
|
def test_vdf_block_validate_not_enough(self):
|
||||||
|
|
||||||
rds = 133240
|
rds = 133240
|
||||||
t = floor(time()) - 60
|
t = floor(time()) - 60
|
||||||
test_data = kasten.generator.pack.pack(b"test", "tst", app_metadata=None, timestamp=t)
|
test_data = kasten.generator.pack.pack(b"test", "tst", app_metadata=None, timestamp=t)
|
||||||
test_id = mimcvdf.vdf_create(test_data, rds)
|
test_id = mimcvdf.vdf_create(test_data, rds)
|
||||||
self.assertRaises(anonvdf.NotEnoughRounds, anonvdf.AnonVDFGenerator.validate_id, test_id, test_data, rounds=rds)
|
self.assertRaises(anonvdf.InvalidID, anonvdf.AnonVDFGenerator.validate_id, test_id, test_data, rounds=rds-1)
|
||||||
|
|
||||||
def test_vdf_incermental(self):
|
def test_vdf_incermental(self):
|
||||||
last = 1
|
last = 1
|
||||||
@ -46,27 +47,31 @@ class TestAnonVDF(unittest.TestCase):
|
|||||||
self.assertGreater(newT - t, last)
|
self.assertGreater(newT - t, last)
|
||||||
|
|
||||||
def test_block_embedded_vdf_rounds(self):
|
def test_block_embedded_vdf_rounds(self):
|
||||||
|
|
||||||
t = floor(time())
|
t = floor(time())
|
||||||
rds = 90000 + (4000 * 1000)
|
test_data = kasten.generator.pack.pack(b"test", "tst", app_metadata={"rds": 900000}, timestamp=t)
|
||||||
|
rds = (3600 * 26) + (len(test_data) * 1000) - 1000
|
||||||
test_data = kasten.generator.pack.pack(b"test", "tst", app_metadata={"rds": rds}, timestamp=t)
|
test_data = kasten.generator.pack.pack(b"test", "tst", app_metadata={"rds": rds}, timestamp=t)
|
||||||
test_vdf = anonvdf.AnonVDFGenerator.generate(test_data, None)
|
test_vdf = anonvdf.AnonVDFGenerator.generate(test_data, None)
|
||||||
anonvdf.AnonVDFGenerator.validate_id(test_vdf.id, test_data, rounds=None)
|
anonvdf.AnonVDFGenerator.validate_id(test_vdf.id, test_data, rounds=None)
|
||||||
|
|
||||||
def test_block_embedded_vdf_rounds_invalid(self):
|
def test_block_embedded_vdf_rounds_invalid(self):
|
||||||
t = floor(time())
|
t = floor(time())
|
||||||
rds = 90000
|
test_data = kasten.generator.pack.pack(b"test", "tst", app_metadata={"rds": 900000}, timestamp=t)
|
||||||
|
rds = (3600 * 26) + (len(test_data) * 1000) - 2000
|
||||||
|
|
||||||
test_data = kasten.generator.pack.pack(b"test", "tst", app_metadata={"rds": rds}, timestamp=t)
|
test_data = kasten.generator.pack.pack(b"test", "tst", app_metadata={"rds": rds}, timestamp=t)
|
||||||
test_vdf = anonvdf.AnonVDFGenerator.generate(test_data, None)
|
test_vdf = anonvdf.AnonVDFGenerator.generate(test_data)
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
anonvdf.NotEnoughRounds,
|
anonvdf.InvalidID,
|
||||||
anonvdf.AnonVDFGenerator.validate_id, test_vdf.id, test_data, rounds=None)
|
anonvdf.AnonVDFGenerator.validate_id, test_vdf.id, test_data, rounds=50000)
|
||||||
|
|
||||||
def test_vdf_rounds_seconds(self):
|
def test_vdf_rounds_seconds(self):
|
||||||
size = 10000
|
size = 10000
|
||||||
per_byte = 1000
|
per_byte = 1000
|
||||||
per_second = 25
|
per_second = 26
|
||||||
expected_rounds = (3600 * 25) + 100000
|
expected_rounds = (3600 * per_second) + (size * per_byte)
|
||||||
self.assertEqual(anonvdf.AnonVDFGenerator.get_rounds_for_ttl_seconds(3600, 100), expected_rounds)
|
self.assertEqual(anonvdf.AnonVDFGenerator.get_rounds_for_ttl_seconds(3600, size), expected_rounds)
|
||||||
|
|
||||||
unittest.main()
|
unittest.main()
|
Loading…
Reference in New Issue
Block a user