def test_load_slice(self): safe = pol.safe.Safe.generate(precomputed_gp=True, n_blocks=10) sl = safe._new_slice(5) sl.store('key', '!!!!', annex=True) self.assertEqual(safe._load_slice('key', sl.first_index).value, '!!!!') randfunc = Crypto.Random.new().read sl.store('key', 'abcd'*(sl.size/4)) self.assertEqual(safe._load_slice('key', sl.first_index).value, 'abcd'*(sl.size/4)) data = randfunc(sl.size) sl.store('key', data) self.assertEqual(safe._load_slice('key', sl.first_index).value, data)
def test_large_slice(self): safe = pol.safe.Safe.generate(precomputed_gp=True, n_blocks=70) sl = safe._new_slice(70) randfunc = Crypto.Random.new().read data = randfunc(sl.size) sl.store('key', data, annex=True) self.assertEqual(safe._load_slice('key', sl.first_index).value, data)