Add assert to RandomContentFile, ensure size >= digest_size

It clearly will not work to have the size smaller than the digest
size, so we shouldn't allow it.
This commit is contained in:
Wesley Spikes 2011-07-15 13:19:01 -07:00
parent d0bb148dea
commit fb8f110e69

View file

@ -17,6 +17,11 @@ class RandomContentFile(object):
self.digest = None self.digest = None
self.last_read = 0 self.last_read = 0
assert self.size >= self.digest_size, "Can not create RandomContentFile: size ({size}) must be >= digest_size ({digest_size})".format(
size=self.size,
digest_size=self.digest_size
)
def seek(self, offset): def seek(self, offset):
assert offset == 0 assert offset == 0
self.random.seed(self.seed) self.random.seed(self.seed)