def test_consistency(self): """ Test if when given the same input in different times the user will get the same checksum. """ with open("/dev/urandom", "rb") as f: data = f.read(50) assert sm.checksum(data, 16) == sm.checksum(data, 16)
def test_good_checksum(self): msg = b"x" * sm.MESSAGE_SIZE padding = sm.MAILBOX_SIZE - sm.MESSAGE_SIZE - sm.CHECKSUM_BYTES data = msg + padding * b"\0" n = sm.checksum(data, sm.CHECKSUM_BYTES) checksum = struct.pack('<l', n) mailbox = data + checksum assert sm.SPM_MailMonitor.validateMailbox(mailbox, 7)
def test_sanity(self, data, result, packed_result): assert sm.checksum(data) == result assert sm.packed_checksum(data) == packed_result