MCPcopy
hub / github.com/jimmysong/programmingbitcoin / test_parse

Method test_parse

code-ch08/script.py:214–220  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

212class ScriptTest(TestCase):
213
214 def test_parse(self):
215 script_pubkey = BytesIO(bytes.fromhex('6a47304402207899531a52d59a6de200179928ca900254a36b8dff8bb75f5f5d71b1cdc26125022008b422690b8461cb52c3cc30330b23d574351872b7c361e9aae3649071c1a7160121035d5c93d9ac96881f19ba1f686f15f009ded7c62efe85a872e6a19b43c15a2937'))
216 script = Script.parse(script_pubkey)
217 want = bytes.fromhex('304402207899531a52d59a6de200179928ca900254a36b8dff8bb75f5f5d71b1cdc26125022008b422690b8461cb52c3cc30330b23d574351872b7c361e9aae3649071c1a71601')
218 self.assertEqual(script.cmds[0].hex(), want.hex())
219 want = bytes.fromhex('035d5c93d9ac96881f19ba1f686f15f009ded7c62efe85a872e6a19b43c15a2937')
220 self.assertEqual(script.cmds[1], want)
221
222 def test_serialize(self):
223 want = '6a47304402207899531a52d59a6de200179928ca900254a36b8dff8bb75f5f5d71b1cdc26125022008b422690b8461cb52c3cc30330b23d574351872b7c361e9aae3649071c1a7160121035d5c93d9ac96881f19ba1f686f15f009ded7c62efe85a872e6a19b43c15a2937'

Callers

nothing calls this directly

Calls 2

parseMethod · 0.45
hexMethod · 0.45

Tested by

no test coverage detected