2022-02-22 19:46:08 +01:00
|
|
|
import unittest
|
|
|
|
from lbry import utils
|
|
|
|
|
|
|
|
|
|
|
|
class UtilsTestCase(unittest.TestCase):
|
|
|
|
|
|
|
|
def test_get_colliding_prefix_bits(self):
|
|
|
|
self.assertEqual(
|
2022-02-23 02:38:04 +01:00
|
|
|
0, utils.get_colliding_prefix_bits(0xffffffff.to_bytes(4, "big"), 0x0000000000.to_bytes(4, "big")))
|
2022-02-22 19:46:08 +01:00
|
|
|
self.assertEqual(
|
2022-02-23 02:38:04 +01:00
|
|
|
1, utils.get_colliding_prefix_bits(0x7fffffff.to_bytes(4, "big"), 0x0000000000.to_bytes(4, "big")))
|
2022-02-22 19:46:08 +01:00
|
|
|
self.assertEqual(
|
2022-02-23 02:38:04 +01:00
|
|
|
8, utils.get_colliding_prefix_bits(0x00ffffff.to_bytes(4, "big"), 0x0000000000.to_bytes(4, "big")))
|
2022-02-22 19:46:08 +01:00
|
|
|
self.assertEqual(
|
2022-02-23 02:38:04 +01:00
|
|
|
8, utils.get_colliding_prefix_bits(0x00ffffff.to_bytes(4, "big"), 0x0000000000.to_bytes(4, "big")))
|
2022-02-22 19:46:08 +01:00
|
|
|
self.assertEqual(
|
2022-02-23 02:38:04 +01:00
|
|
|
1, utils.get_colliding_prefix_bits(0x7fffffff.to_bytes(4, "big"), 0x0000000000.to_bytes(4, "big")))
|
2022-02-22 19:46:08 +01:00
|
|
|
self.assertEqual(
|
2022-02-23 02:38:04 +01:00
|
|
|
1, utils.get_colliding_prefix_bits(0x7fffffff.to_bytes(4, "big"), 0x0000000000.to_bytes(4, "big")))
|