Ejemplo n.º 1
0
    def test_index_higher_than_15_bits(self):
        hash = '000000000000000000000000' + \
             'aaaaaaaaaaaaaaaa000000000000000000000000'

        dont_ignore_low_values = int('00000001', 16)
        self.assertEqual(checksum(hash, dont_ignore_low_values),
                         0xaaaaaaaaaaaa8001)

        ignore_high_values = int('10000000', 16)
        self.assertEqual(checksum(hash, ignore_high_values),
                         0xaaaaaaaaaaaa8000)
Ejemplo n.º 2
0
    def test_drop_high(self):
        hash = 'ffffffffffffffffffffffff' + \
             'aaaaaaaaaaaaaaaa' + \
             '000000000000000000000000'
        index = 0
        self.assertEqual(checksum(hash, index), 0xaaaaaaaaaaaa8000)

        hash = 'ffffffffffffffffffffffff' + \
            'aaaaaaaaaaaaaaaa' + \
            '000000000000000000000000'
        self.assertEqual(checksum(hash, index), 0xaaaaaaaaaaaa8000)
Ejemplo n.º 3
0
 def test_pattern(self):
     hash = '000000000000000000000000' + \
         '01234567aaaaaaaa' + \
         'ffffffffffffffffffffffff'
     index = int('89abcdef', 16)
     self.assertEqual(hex(checksum(hash, index)), '0x1234567aaaacdef')
Ejemplo n.º 4
0
 def test_index(self):
     hash = 'ffffffffffffffffffffffff' + \
          'aaaaaaaaaaaaaaaa000000000000000000000000'
     index = 1
     self.assertEqual(checksum(hash, index), 0xaaaaaaaaaaaa8001)
Ejemplo n.º 5
0
 def test_all_zeros(self):
     hash = '000000000000000000000000' + \
         '0000000000000000' + \
         '000000000000000000000000'
     index = int('00000000', 16)
     self.assertEqual(checksum(hash, index), 0)
Ejemplo n.º 6
0
 def test_all_ones(self):
     hash = 'ffffffffffffffffffffffff' + \
         'ffffffffffffffff' + \
         'ffffffffffffffffffffffff'
     index = int('ffffffff', 16)
     self.assertEqual(checksum(hash, index), 0xffffffffffffffff)