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

Method test_parse

code-ch13/network.py:94–104  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

92class NetworkEnvelopeTest(TestCase):
93
94 def test_parse(self):
95 msg = bytes.fromhex('f9beb4d976657261636b000000000000000000005df6e0e2')
96 stream = BytesIO(msg)
97 envelope = NetworkEnvelope.parse(stream)
98 self.assertEqual(envelope.command, b'verack')
99 self.assertEqual(envelope.payload, b'')
100 msg = bytes.fromhex('f9beb4d976657273696f6e0000000000650000005f1a69d2721101000100000000000000bc8f5e5400000000010000000000000000000000000000000000ffffc61b6409208d010000000000000000000000000000000000ffffcb0071c0208d128035cbc97953f80f2f5361746f7368693a302e392e332fcf05050001')
101 stream = BytesIO(msg)
102 envelope = NetworkEnvelope.parse(stream)
103 self.assertEqual(envelope.command, b'version')
104 self.assertEqual(envelope.payload, msg[24:])
105
106 def test_serialize(self):
107 msg = bytes.fromhex('f9beb4d976657261636b000000000000000000005df6e0e2')

Callers

nothing calls this directly

Calls 1

parseMethod · 0.45

Tested by

no test coverage detected