示例#1
0
 def test_valid_checksum(self):
     """Test checksum creation and validation."""
     for test in VALID_CHECKSUM:
         hrp, _ = segwit_addr.bech32_decode(test)
         self.assertIsNotNone(hrp)
         pos = test.rfind('1')
         test = test[:pos + 1] + chr(ord(test[pos + 1]) ^ 1) + test[pos +
                                                                    2:]
         hrp, _ = segwit_addr.bech32_decode(test)
         self.assertIsNone(hrp)
示例#2
0
 def test_valid_checksum(self):
     """Test checksum creation and validation."""
     for encoding in segwit_addr.Encoding:
         tests = VALID_BECH32 if encoding == segwit_addr.Encoding.BECH32 else VALID_BECH32M
         for test in tests:
             dencoding, hrp, _ = segwit_addr.bech32_decode(test)
             self.assertTrue(hrp is not None and dencoding == encoding)
             pos = test.rfind('1')
             test = test[:pos + 1] + chr(ord(test[pos + 1]) ^ 1) + test[pos + 2:]
             decoding, hrp, _ = segwit_addr.bech32_decode(test)
             self.assertIsNone(hrp)
示例#3
0
 def test_invalid_checksum(self):
     """Test validation of invalid checksums."""
     for encoding in segwit_addr.Encoding:
         tests = INVALID_BECH32 if encoding == segwit_addr.Encoding.BECH32 else INVALID_BECH32M
         for test in tests:
             dencoding, hrp, _ = segwit_addr.bech32_decode(test)
             self.assertTrue(hrp is None or dencoding != encoding)
示例#4
0
 def test_invalid_checksum(self):
     """Test validation of invalid checksums."""
     for test in INVALID_CHECKSUM:
         hrp, _ = segwit_addr.bech32_decode(test)
         self.assertIsNone(hrp)