Gora Khargosh avatar Gora Khargosh committed 318bc05

Speed up tests.

Signed-off-by: Gora Khargosh <gora.khargosh@gmail.com>;

Comments (0)

Files changed (3)

tests/test_mom_codec_base58.py

 from mom.codec import hex_decode, base58_decode, base58_encode
 from mom.codec._alt_base import b58decode_naive
 from mom.codec.base58 import b58encode, b58decode, ALT58_CHARSET, ASCII58_CHARSET
-from mom.codec.integer import bytes_to_uint, uint_to_bytes
 from mom.security.random import generate_random_bytes
 
-random_bytes_len_4093 = generate_random_bytes(4093)
+random_bytes = generate_random_bytes(384)
 
 zero_bytes = b('\x00\x00\x00\x00')
 one_zero_byte = b('\x00')
         self.assertEqual(len(ALT58_CHARSET), 58)
 
     def test_codec_identity(self):
-        self.assertEqual(
-            b58decode(b58encode(random_bytes_len_4093)),
-            random_bytes_len_4093
-        )
-        self.assertEqual(
-            b58decode_naive(b58encode(random_bytes_len_4093)),
-            random_bytes_len_4093
-        )
-        self.assertEqual(
-            base58_decode(base58_encode(random_bytes_len_4093)),
-            random_bytes_len_4093
-        )
+        self.assertEqual(b58decode(b58encode(random_bytes)), random_bytes)
+        self.assertEqual(b58decode_naive(b58encode(random_bytes)), random_bytes)
+        self.assertEqual(base58_decode(base58_encode(random_bytes)),
+                         random_bytes)
 
     def test_encodes_zero_prefixed_padding(self):
         self.assertEqual(b58decode(b58encode(padding_raw)), padding_raw)

tests/test_mom_codec_base62.py

 from mom.codec.base62 import b62encode, b62decode, ASCII62_CHARSET, ALT62_CHARSET
 from mom.security.random import generate_random_bytes
 
-random_bytes_len_4093 = generate_random_bytes(4093)
+random_bytes_len_512 = generate_random_bytes(512)
 
 zero_bytes = b('\x00\x00\x00\x00')
 one_zero_byte = b('\x00')
 
     def test_codec_identity(self):
         self.assertEqual(
-            b62decode(b62encode(random_bytes_len_4093)),
-            random_bytes_len_4093
+            b62decode(b62encode(random_bytes_len_512)),
+            random_bytes_len_512
         )
         self.assertEqual(
-            b62decode_naive(b62encode(random_bytes_len_4093)),
-            random_bytes_len_4093
+            b62decode_naive(b62encode(random_bytes_len_512)),
+            random_bytes_len_512
         )
         self.assertEqual(
-            base62_decode(base62_encode(random_bytes_len_4093)),
-            random_bytes_len_4093
+            base62_decode(base62_encode(random_bytes_len_512)),
+            random_bytes_len_512
         )
 
     def test_encodes_zero_prefixed_padding(self):

tests/test_mom_math.py

 class Test_generate_random_safe_prime(unittest2.TestCase):
     def test_generate_random_safe_prime(self):
         for x in range(20):
-            self.assertTrue(is_prime(generate_random_safe_prime(64)))
+            self.assertTrue(is_prime(generate_random_safe_prime(32)))
         
 
 class Test_gcd(unittest2.TestCase):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.