Mercurial > public > mercurial-scm > hg
diff tests/test-wireproto-serverreactor.py @ 37061:884a0c1604ad
wireproto: define attr-based classes for representing frames
When frames only had 3 attributes, it was reasonable to
represent them as a tuple. With them growing more attributes,
it will be easier to pass them around as a more formal type.
So let's define attr-based classes to represent frame headers and
full frames.
Differential Revision: https://phab.mercurial-scm.org/D2899
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 15 Mar 2018 16:03:14 -0700 |
parents | 0a6c5cc09a88 |
children | 39304dd63589 |
line wrap: on
line diff
--- a/tests/test-wireproto-serverreactor.py Wed Mar 14 22:19:00 2018 -0700 +++ b/tests/test-wireproto-serverreactor.py Thu Mar 15 16:03:14 2018 -0700 @@ -18,11 +18,14 @@ Emits a generator of results from ``onframerecv()`` calls. """ for frame in gen: - rid, frametype, frameflags, framelength = framing.parseheader(frame) + header = framing.parseheader(frame) payload = frame[framing.FRAME_HEADER_SIZE:] - assert len(payload) == framelength + assert len(payload) == header.length - yield reactor.onframerecv(rid, frametype, frameflags, payload) + yield reactor.onframerecv(framing.frame(header.requestid, + header.typeid, + header.flags, + payload)) def sendcommandframes(reactor, rid, cmd, args, datafh=None): """Generate frames to run a command and send them to a reactor."""