def test_zero_bytes(self): self.assertEqual(uint_to_bytes(bytes_to_uint(zero_bytes)), one_zero_byte) self.assertEqual(uint_to_bytes(bytes_to_uint_naive(zero_bytes)), one_zero_byte) self.assertEqual(uint_to_bytes(bytes_to_uint_simple(zero_bytes)), one_zero_byte)
def test_zero_bytes(self): self.assertEqual(integer.uint_to_bytes(integer.bytes_to_uint(ZERO_BYTES)), ONE_ZERO_BYTE) self.assertEqual(integer.uint_to_bytes(_alt_integer.bytes_to_uint_naive(ZERO_BYTES)), ONE_ZERO_BYTE) self.assertEqual(integer.uint_to_bytes(_alt_integer.bytes_to_uint_simple(ZERO_BYTES)), ONE_ZERO_BYTE)
def test_codec_equivalence(self): # Padding bytes are not preserved (it is acceptable here). random_bytes = b("\x00\xbcE\x9a\xda]") expected_bytes = b("\xbcE\x9a\xda]") self.assertEqual(uint_to_bytes(bytes_to_uint(random_bytes)), expected_bytes) self.assertEqual(uint_to_bytes(bytes_to_uint_naive(random_bytes)), expected_bytes) self.assertEqual(uint_to_bytes(bytes_to_uint_simple(random_bytes)), expected_bytes)
def test_codec_equivalence(self): # Padding bytes are not preserved (it is acceptable here). random_bytes = b("\x00\xbcE\x9a\xda]") expected_bytes = b("\xbcE\x9a\xda]") self.assertEqual(integer.uint_to_bytes(integer.bytes_to_uint(random_bytes)), expected_bytes) self.assertEqual(integer.uint_to_bytes(_alt_integer.bytes_to_uint_naive(random_bytes)), expected_bytes) self.assertEqual(integer.uint_to_bytes(_alt_integer.bytes_to_uint_simple(random_bytes)), expected_bytes)