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