MCPcopy
hub / github.com/petertodd/python-bitcoinlib / test_encode_decode

Method test_encode_decode

bitcoin/tests/test_bech32.py:42–52  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

40 self.fail('Wrong witver: %d' % witver)
41
42 def test_encode_decode(self):
43 for exp_bin, exp_bech32 in load_test_vectors('bech32_encode_decode.json'):
44 exp_bin = unhexlify(exp_bin.encode('utf8'))
45 witver = self.op_decode(exp_bin[0])
46 hrp = exp_bech32[:exp_bech32.rindex('1')].lower()
47 self.assertEqual(exp_bin[1], len(exp_bin[2:]))
48 act_bech32 = encode(hrp, witver, exp_bin[2:])
49 act_bin = decode(hrp, exp_bech32)
50
51 self.assertEqual(act_bech32.lower(), exp_bech32.lower())
52 self.assertEqual(to_scriptPubKey(*act_bin), bytes(exp_bin))
53
54class Test_CBech32Data(unittest.TestCase):
55 def test_from_data(self):

Callers

nothing calls this directly

Calls 5

op_decodeMethod · 0.95
encodeFunction · 0.90
decodeFunction · 0.90
to_scriptPubKeyFunction · 0.85
load_test_vectorsFunction · 0.70

Tested by

no test coverage detected