author | Boris Feld <boris.feld@octobus.net> |
Wed, 19 Dec 2018 15:45:29 +0100 | |
changeset 41036 | 73da729ccfef |
parent 40482 | 07b87ee2ea75 |
child 41119 | 685cf59a134f |
permissions | -rw-r--r-- |
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 |
from __future__ import absolute_import |
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 |
|
40482
07b87ee2ea75
tests: skip wireproto clientreactor tests on Python 3.6.0-3.6.3 inclusive
Augie Fackler <augie@google.com>
parents:
40132
diff
changeset
|
3 |
import sys |
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 |
import unittest |
40132
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
5 |
import zlib |
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 |
|
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
7 |
from mercurial import ( |
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 |
error, |
40129
293835e0fff7
wireprotov2: pass ui into clientreactor and serverreactor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40128
diff
changeset
|
9 |
ui as uimod, |
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
10 |
wireprotoframing as framing, |
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
11 |
) |
40128
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
12 |
from mercurial.utils import ( |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
13 |
cborutil, |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
14 |
) |
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
15 |
|
40132
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
16 |
try: |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
17 |
from mercurial import zstd |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
18 |
zstd.__version__ |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
19 |
except ImportError: |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
20 |
zstd = None |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
21 |
|
37544
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
22 |
ffs = framing.makeframefromhumanstring |
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
23 |
|
40129
293835e0fff7
wireprotov2: pass ui into clientreactor and serverreactor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40128
diff
changeset
|
24 |
globalui = uimod.ui() |
293835e0fff7
wireprotov2: pass ui into clientreactor and serverreactor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40128
diff
changeset
|
25 |
|
37544
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
26 |
def sendframe(reactor, frame): |
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
27 |
"""Send a frame bytearray to a reactor.""" |
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
28 |
header = framing.parseheader(frame) |
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
29 |
payload = frame[framing.FRAME_HEADER_SIZE:] |
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
30 |
assert len(payload) == header.length |
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
31 |
|
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
32 |
return reactor.onframerecv(framing.frame(header.requestid, |
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
33 |
header.streamid, |
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
34 |
header.streamflags, |
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
35 |
header.typeid, |
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
36 |
header.flags, |
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
37 |
payload)) |
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
38 |
|
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
39 |
class SingleSendTests(unittest.TestCase): |
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
40 |
"""A reactor that can only send once rejects subsequent sends.""" |
37715
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37682
diff
changeset
|
41 |
|
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37682
diff
changeset
|
42 |
if not getattr(unittest.TestCase, 'assertRaisesRegex', False): |
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37682
diff
changeset
|
43 |
# Python 3.7 deprecates the regex*p* version, but 2.7 lacks |
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37682
diff
changeset
|
44 |
# the regex version. |
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37682
diff
changeset
|
45 |
assertRaisesRegex = (# camelcase-required |
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37682
diff
changeset
|
46 |
unittest.TestCase.assertRaisesRegexp) |
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37682
diff
changeset
|
47 |
|
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
48 |
def testbasic(self): |
40129
293835e0fff7
wireprotov2: pass ui into clientreactor and serverreactor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40128
diff
changeset
|
49 |
reactor = framing.clientreactor(globalui, |
293835e0fff7
wireprotov2: pass ui into clientreactor and serverreactor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40128
diff
changeset
|
50 |
hasmultiplesend=False, |
293835e0fff7
wireprotov2: pass ui into clientreactor and serverreactor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40128
diff
changeset
|
51 |
buffersends=True) |
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
52 |
|
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
53 |
request, action, meta = reactor.callcommand(b'foo', {}) |
37682
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
54 |
self.assertEqual(request.state, b'pending') |
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
55 |
self.assertEqual(action, b'noop') |
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
56 |
|
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
57 |
action, meta = reactor.flushcommands() |
37682
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
58 |
self.assertEqual(action, b'sendframes') |
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
59 |
|
37682
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
60 |
for frame in meta[b'framegen']: |
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
61 |
self.assertEqual(request.state, b'sending') |
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
62 |
|
37682
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
63 |
self.assertEqual(request.state, b'sent') |
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
64 |
|
37715
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37682
diff
changeset
|
65 |
with self.assertRaisesRegex(error.ProgrammingError, |
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
66 |
'cannot issue new commands'): |
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
67 |
reactor.callcommand(b'foo', {}) |
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
68 |
|
37715
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37682
diff
changeset
|
69 |
with self.assertRaisesRegex(error.ProgrammingError, |
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
70 |
'cannot issue new commands'): |
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
71 |
reactor.callcommand(b'foo', {}) |
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
72 |
|
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
73 |
class NoBufferTests(unittest.TestCase): |
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
74 |
"""A reactor without send buffering sends requests immediately.""" |
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
75 |
def testbasic(self): |
40129
293835e0fff7
wireprotov2: pass ui into clientreactor and serverreactor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40128
diff
changeset
|
76 |
reactor = framing.clientreactor(globalui, |
293835e0fff7
wireprotov2: pass ui into clientreactor and serverreactor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40128
diff
changeset
|
77 |
hasmultiplesend=True, |
293835e0fff7
wireprotov2: pass ui into clientreactor and serverreactor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40128
diff
changeset
|
78 |
buffersends=False) |
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
79 |
|
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
80 |
request, action, meta = reactor.callcommand(b'command1', {}) |
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
81 |
self.assertEqual(request.requestid, 1) |
37682
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
82 |
self.assertEqual(action, b'sendframes') |
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
83 |
|
37682
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
84 |
self.assertEqual(request.state, b'pending') |
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
85 |
|
37682
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
86 |
for frame in meta[b'framegen']: |
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
87 |
self.assertEqual(request.state, b'sending') |
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
88 |
|
37682
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
89 |
self.assertEqual(request.state, b'sent') |
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
90 |
|
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
91 |
action, meta = reactor.flushcommands() |
37682
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
92 |
self.assertEqual(action, b'noop') |
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
93 |
|
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
94 |
# And we can send another command. |
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
95 |
request, action, meta = reactor.callcommand(b'command2', {}) |
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
96 |
self.assertEqual(request.requestid, 3) |
37682
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
97 |
self.assertEqual(action, b'sendframes') |
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
98 |
|
37682
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
99 |
for frame in meta[b'framegen']: |
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
100 |
self.assertEqual(request.state, b'sending') |
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
101 |
|
37682
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
102 |
self.assertEqual(request.state, b'sent') |
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
103 |
|
37544
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
104 |
class BadFrameRecvTests(unittest.TestCase): |
37715
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37682
diff
changeset
|
105 |
if not getattr(unittest.TestCase, 'assertRaisesRegex', False): |
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37682
diff
changeset
|
106 |
# Python 3.7 deprecates the regex*p* version, but 2.7 lacks |
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37682
diff
changeset
|
107 |
# the regex version. |
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37682
diff
changeset
|
108 |
assertRaisesRegex = (# camelcase-required |
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37682
diff
changeset
|
109 |
unittest.TestCase.assertRaisesRegexp) |
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37682
diff
changeset
|
110 |
|
37544
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
111 |
def testoddstream(self): |
40129
293835e0fff7
wireprotov2: pass ui into clientreactor and serverreactor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40128
diff
changeset
|
112 |
reactor = framing.clientreactor(globalui) |
37544
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
113 |
|
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
114 |
action, meta = sendframe(reactor, ffs(b'1 1 0 1 0 foo')) |
37682
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
115 |
self.assertEqual(action, b'error') |
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
116 |
self.assertEqual(meta[b'message'], |
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
117 |
b'received frame with odd numbered stream ID: 1') |
37544
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
118 |
|
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
119 |
def testunknownstream(self): |
40129
293835e0fff7
wireprotov2: pass ui into clientreactor and serverreactor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40128
diff
changeset
|
120 |
reactor = framing.clientreactor(globalui) |
37544
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
121 |
|
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
122 |
action, meta = sendframe(reactor, ffs(b'1 0 0 1 0 foo')) |
37682
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
123 |
self.assertEqual(action, b'error') |
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
124 |
self.assertEqual(meta[b'message'], |
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
125 |
b'received frame on unknown stream without beginning ' |
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
126 |
b'of stream flag set') |
37544
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
127 |
|
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
128 |
def testunhandledframetype(self): |
40129
293835e0fff7
wireprotov2: pass ui into clientreactor and serverreactor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40128
diff
changeset
|
129 |
reactor = framing.clientreactor(globalui, buffersends=False) |
37544
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
130 |
|
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
131 |
request, action, meta = reactor.callcommand(b'foo', {}) |
37682
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
132 |
for frame in meta[b'framegen']: |
37544
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
133 |
pass |
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
134 |
|
37715
1859b9a7ddef
cleanup: polyfill assertRaisesRegex so we can avoid assertRaisesRegexp
Augie Fackler <augie@google.com>
parents:
37682
diff
changeset
|
135 |
with self.assertRaisesRegex(error.ProgrammingError, |
37544
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
136 |
'unhandled frame type'): |
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
137 |
sendframe(reactor, ffs(b'1 0 stream-begin text-output 0 foo')) |
55b5ba8d4e68
wireproto: client reactor support for receiving frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37543
diff
changeset
|
138 |
|
37656
e6870bca1f47
wireprotoframing: record when new stream is encountered
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37544
diff
changeset
|
139 |
class StreamTests(unittest.TestCase): |
e6870bca1f47
wireprotoframing: record when new stream is encountered
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37544
diff
changeset
|
140 |
def testmultipleresponseframes(self): |
40129
293835e0fff7
wireprotov2: pass ui into clientreactor and serverreactor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40128
diff
changeset
|
141 |
reactor = framing.clientreactor(globalui, buffersends=False) |
37656
e6870bca1f47
wireprotoframing: record when new stream is encountered
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37544
diff
changeset
|
142 |
|
e6870bca1f47
wireprotoframing: record when new stream is encountered
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37544
diff
changeset
|
143 |
request, action, meta = reactor.callcommand(b'foo', {}) |
e6870bca1f47
wireprotoframing: record when new stream is encountered
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37544
diff
changeset
|
144 |
|
37682
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
145 |
self.assertEqual(action, b'sendframes') |
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
146 |
for f in meta[b'framegen']: |
37656
e6870bca1f47
wireprotoframing: record when new stream is encountered
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37544
diff
changeset
|
147 |
pass |
e6870bca1f47
wireprotoframing: record when new stream is encountered
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37544
diff
changeset
|
148 |
|
e6870bca1f47
wireprotoframing: record when new stream is encountered
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37544
diff
changeset
|
149 |
action, meta = sendframe( |
e6870bca1f47
wireprotoframing: record when new stream is encountered
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37544
diff
changeset
|
150 |
reactor, |
37724
deff7cf7eefd
wireprotov2: change frame type and name for command response
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37715
diff
changeset
|
151 |
ffs(b'%d 0 stream-begin command-response 0 foo' % |
deff7cf7eefd
wireprotov2: change frame type and name for command response
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37715
diff
changeset
|
152 |
request.requestid)) |
37682
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
153 |
self.assertEqual(action, b'responsedata') |
37656
e6870bca1f47
wireprotoframing: record when new stream is encountered
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37544
diff
changeset
|
154 |
|
e6870bca1f47
wireprotoframing: record when new stream is encountered
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37544
diff
changeset
|
155 |
action, meta = sendframe( |
e6870bca1f47
wireprotoframing: record when new stream is encountered
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37544
diff
changeset
|
156 |
reactor, |
37724
deff7cf7eefd
wireprotov2: change frame type and name for command response
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37715
diff
changeset
|
157 |
ffs(b'%d 0 0 command-response eos bar' % request.requestid)) |
37682
cb71e0f9ac6f
tests: add all missing b prefixes in reactor tests
Augie Fackler <augie@google.com>
parents:
37656
diff
changeset
|
158 |
self.assertEqual(action, b'responsedata') |
37656
e6870bca1f47
wireprotoframing: record when new stream is encountered
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37544
diff
changeset
|
159 |
|
40024
86b22a4cfab1
wireprotov2: client support for advertising redirect targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37724
diff
changeset
|
160 |
class RedirectTests(unittest.TestCase): |
86b22a4cfab1
wireprotov2: client support for advertising redirect targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37724
diff
changeset
|
161 |
def testredirect(self): |
40129
293835e0fff7
wireprotov2: pass ui into clientreactor and serverreactor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40128
diff
changeset
|
162 |
reactor = framing.clientreactor(globalui, buffersends=False) |
40024
86b22a4cfab1
wireprotov2: client support for advertising redirect targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37724
diff
changeset
|
163 |
|
86b22a4cfab1
wireprotov2: client support for advertising redirect targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37724
diff
changeset
|
164 |
redirect = { |
86b22a4cfab1
wireprotov2: client support for advertising redirect targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37724
diff
changeset
|
165 |
b'targets': [b'a', b'b'], |
86b22a4cfab1
wireprotov2: client support for advertising redirect targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37724
diff
changeset
|
166 |
b'hashes': [b'sha256'], |
86b22a4cfab1
wireprotov2: client support for advertising redirect targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37724
diff
changeset
|
167 |
} |
86b22a4cfab1
wireprotov2: client support for advertising redirect targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37724
diff
changeset
|
168 |
|
86b22a4cfab1
wireprotov2: client support for advertising redirect targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37724
diff
changeset
|
169 |
request, action, meta = reactor.callcommand( |
86b22a4cfab1
wireprotov2: client support for advertising redirect targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37724
diff
changeset
|
170 |
b'foo', {}, redirect=redirect) |
86b22a4cfab1
wireprotov2: client support for advertising redirect targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37724
diff
changeset
|
171 |
|
86b22a4cfab1
wireprotov2: client support for advertising redirect targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37724
diff
changeset
|
172 |
self.assertEqual(action, b'sendframes') |
86b22a4cfab1
wireprotov2: client support for advertising redirect targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37724
diff
changeset
|
173 |
|
86b22a4cfab1
wireprotov2: client support for advertising redirect targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37724
diff
changeset
|
174 |
frames = list(meta[b'framegen']) |
86b22a4cfab1
wireprotov2: client support for advertising redirect targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37724
diff
changeset
|
175 |
self.assertEqual(len(frames), 1) |
86b22a4cfab1
wireprotov2: client support for advertising redirect targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37724
diff
changeset
|
176 |
|
86b22a4cfab1
wireprotov2: client support for advertising redirect targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37724
diff
changeset
|
177 |
self.assertEqual(frames[0], |
86b22a4cfab1
wireprotov2: client support for advertising redirect targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37724
diff
changeset
|
178 |
ffs(b'1 1 stream-begin command-request new ' |
86b22a4cfab1
wireprotov2: client support for advertising redirect targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37724
diff
changeset
|
179 |
b"cbor:{b'name': b'foo', " |
86b22a4cfab1
wireprotov2: client support for advertising redirect targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37724
diff
changeset
|
180 |
b"b'redirect': {b'targets': [b'a', b'b'], " |
86b22a4cfab1
wireprotov2: client support for advertising redirect targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37724
diff
changeset
|
181 |
b"b'hashes': [b'sha256']}}")) |
86b22a4cfab1
wireprotov2: client support for advertising redirect targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37724
diff
changeset
|
182 |
|
40128
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
183 |
class StreamSettingsTests(unittest.TestCase): |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
184 |
def testnoflags(self): |
40129
293835e0fff7
wireprotov2: pass ui into clientreactor and serverreactor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40128
diff
changeset
|
185 |
reactor = framing.clientreactor(globalui, buffersends=False) |
40128
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
186 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
187 |
request, action, meta = reactor.callcommand(b'foo', {}) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
188 |
for f in meta[b'framegen']: |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
189 |
pass |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
190 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
191 |
action, meta = sendframe(reactor, |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
192 |
ffs(b'1 2 stream-begin stream-settings 0 ')) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
193 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
194 |
self.assertEqual(action, b'error') |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
195 |
self.assertEqual(meta, { |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
196 |
b'message': b'stream encoding settings frame must have ' |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
197 |
b'continuation or end of stream flag set', |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
198 |
}) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
199 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
200 |
def testconflictflags(self): |
40129
293835e0fff7
wireprotov2: pass ui into clientreactor and serverreactor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40128
diff
changeset
|
201 |
reactor = framing.clientreactor(globalui, buffersends=False) |
40128
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
202 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
203 |
request, action, meta = reactor.callcommand(b'foo', {}) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
204 |
for f in meta[b'framegen']: |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
205 |
pass |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
206 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
207 |
action, meta = sendframe(reactor, |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
208 |
ffs(b'1 2 stream-begin stream-settings continuation|eos ')) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
209 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
210 |
self.assertEqual(action, b'error') |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
211 |
self.assertEqual(meta, { |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
212 |
b'message': b'stream encoding settings frame cannot have both ' |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
213 |
b'continuation and end of stream flags set', |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
214 |
}) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
215 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
216 |
def testemptypayload(self): |
40129
293835e0fff7
wireprotov2: pass ui into clientreactor and serverreactor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40128
diff
changeset
|
217 |
reactor = framing.clientreactor(globalui, buffersends=False) |
40128
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
218 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
219 |
request, action, meta = reactor.callcommand(b'foo', {}) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
220 |
for f in meta[b'framegen']: |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
221 |
pass |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
222 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
223 |
action, meta = sendframe(reactor, |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
224 |
ffs(b'1 2 stream-begin stream-settings eos ')) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
225 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
226 |
self.assertEqual(action, b'error') |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
227 |
self.assertEqual(meta, { |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
228 |
b'message': b'stream encoding settings frame did not contain ' |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
229 |
b'CBOR data' |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
230 |
}) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
231 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
232 |
def testbadcbor(self): |
40129
293835e0fff7
wireprotov2: pass ui into clientreactor and serverreactor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40128
diff
changeset
|
233 |
reactor = framing.clientreactor(globalui, buffersends=False) |
40128
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
234 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
235 |
request, action, meta = reactor.callcommand(b'foo', {}) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
236 |
for f in meta[b'framegen']: |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
237 |
pass |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
238 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
239 |
action, meta = sendframe(reactor, |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
240 |
ffs(b'1 2 stream-begin stream-settings eos badvalue')) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
241 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
242 |
self.assertEqual(action, b'error') |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
243 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
244 |
def testsingleobject(self): |
40129
293835e0fff7
wireprotov2: pass ui into clientreactor and serverreactor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40128
diff
changeset
|
245 |
reactor = framing.clientreactor(globalui, buffersends=False) |
40128
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
246 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
247 |
request, action, meta = reactor.callcommand(b'foo', {}) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
248 |
for f in meta[b'framegen']: |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
249 |
pass |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
250 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
251 |
action, meta = sendframe(reactor, |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
252 |
ffs(b'1 2 stream-begin stream-settings eos cbor:b"identity"')) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
253 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
254 |
self.assertEqual(action, b'noop') |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
255 |
self.assertEqual(meta, {}) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
256 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
257 |
def testmultipleobjects(self): |
40129
293835e0fff7
wireprotov2: pass ui into clientreactor and serverreactor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40128
diff
changeset
|
258 |
reactor = framing.clientreactor(globalui, buffersends=False) |
40128
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
259 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
260 |
request, action, meta = reactor.callcommand(b'foo', {}) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
261 |
for f in meta[b'framegen']: |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
262 |
pass |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
263 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
264 |
data = b''.join([ |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
265 |
b''.join(cborutil.streamencode(b'identity')), |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
266 |
b''.join(cborutil.streamencode({b'foo', b'bar'})), |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
267 |
]) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
268 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
269 |
action, meta = sendframe(reactor, |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
270 |
ffs(b'1 2 stream-begin stream-settings eos %s' % data)) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
271 |
|
40132
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
272 |
self.assertEqual(action, b'error') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
273 |
self.assertEqual(meta, { |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
274 |
b'message': b'error setting stream decoder: identity decoder ' |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
275 |
b'received unexpected additional values', |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
276 |
}) |
40128
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
277 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
278 |
def testmultipleframes(self): |
40129
293835e0fff7
wireprotov2: pass ui into clientreactor and serverreactor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40128
diff
changeset
|
279 |
reactor = framing.clientreactor(globalui, buffersends=False) |
40128
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
280 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
281 |
request, action, meta = reactor.callcommand(b'foo', {}) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
282 |
for f in meta[b'framegen']: |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
283 |
pass |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
284 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
285 |
data = b''.join(cborutil.streamencode(b'identity')) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
286 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
287 |
action, meta = sendframe(reactor, |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
288 |
ffs(b'1 2 stream-begin stream-settings continuation %s' % |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
289 |
data[0:3])) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
290 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
291 |
self.assertEqual(action, b'noop') |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
292 |
self.assertEqual(meta, {}) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
293 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
294 |
action, meta = sendframe(reactor, |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
295 |
ffs(b'1 2 0 stream-settings eos %s' % data[3:])) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
296 |
|
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
297 |
self.assertEqual(action, b'noop') |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
298 |
self.assertEqual(meta, {}) |
57782791b7e9
wireprotov2: handle stream encoding settings frames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40024
diff
changeset
|
299 |
|
40132
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
300 |
def testinvalidencoder(self): |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
301 |
reactor = framing.clientreactor(globalui, buffersends=False) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
302 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
303 |
request, action, meta = reactor.callcommand(b'foo', {}) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
304 |
for f in meta[b'framegen']: |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
305 |
pass |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
306 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
307 |
action, meta = sendframe(reactor, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
308 |
ffs(b'1 2 stream-begin stream-settings eos cbor:b"badvalue"')) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
309 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
310 |
self.assertEqual(action, b'error') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
311 |
self.assertEqual(meta, { |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
312 |
b'message': b'error setting stream decoder: unknown stream ' |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
313 |
b'decoder: badvalue', |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
314 |
}) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
315 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
316 |
def testzlibencoding(self): |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
317 |
reactor = framing.clientreactor(globalui, buffersends=False) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
318 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
319 |
request, action, meta = reactor.callcommand(b'foo', {}) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
320 |
for f in meta[b'framegen']: |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
321 |
pass |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
322 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
323 |
action, meta = sendframe(reactor, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
324 |
ffs(b'%d 2 stream-begin stream-settings eos cbor:b"zlib"' % |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
325 |
request.requestid)) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
326 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
327 |
self.assertEqual(action, b'noop') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
328 |
self.assertEqual(meta, {}) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
329 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
330 |
result = { |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
331 |
b'status': b'ok', |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
332 |
} |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
333 |
encoded = b''.join(cborutil.streamencode(result)) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
334 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
335 |
compressed = zlib.compress(encoded) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
336 |
self.assertEqual(zlib.decompress(compressed), encoded) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
337 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
338 |
action, meta = sendframe(reactor, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
339 |
ffs(b'%d 2 encoded command-response eos %s' % |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
340 |
(request.requestid, compressed))) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
341 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
342 |
self.assertEqual(action, b'responsedata') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
343 |
self.assertEqual(meta[b'data'], encoded) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
344 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
345 |
def testzlibencodingsinglebyteframes(self): |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
346 |
reactor = framing.clientreactor(globalui, buffersends=False) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
347 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
348 |
request, action, meta = reactor.callcommand(b'foo', {}) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
349 |
for f in meta[b'framegen']: |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
350 |
pass |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
351 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
352 |
action, meta = sendframe(reactor, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
353 |
ffs(b'%d 2 stream-begin stream-settings eos cbor:b"zlib"' % |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
354 |
request.requestid)) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
355 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
356 |
self.assertEqual(action, b'noop') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
357 |
self.assertEqual(meta, {}) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
358 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
359 |
result = { |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
360 |
b'status': b'ok', |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
361 |
} |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
362 |
encoded = b''.join(cborutil.streamencode(result)) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
363 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
364 |
compressed = zlib.compress(encoded) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
365 |
self.assertEqual(zlib.decompress(compressed), encoded) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
366 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
367 |
chunks = [] |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
368 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
369 |
for i in range(len(compressed)): |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
370 |
char = compressed[i:i + 1] |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
371 |
if char == b'\\': |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
372 |
char = b'\\\\' |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
373 |
action, meta = sendframe(reactor, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
374 |
ffs(b'%d 2 encoded command-response continuation %s' % |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
375 |
(request.requestid, char))) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
376 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
377 |
self.assertEqual(action, b'responsedata') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
378 |
chunks.append(meta[b'data']) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
379 |
self.assertTrue(meta[b'expectmore']) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
380 |
self.assertFalse(meta[b'eos']) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
381 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
382 |
# zlib will have the full data decoded at this point, even though |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
383 |
# we haven't flushed. |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
384 |
self.assertEqual(b''.join(chunks), encoded) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
385 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
386 |
# End the stream for good measure. |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
387 |
action, meta = sendframe(reactor, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
388 |
ffs(b'%d 2 stream-end command-response eos ' % request.requestid)) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
389 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
390 |
self.assertEqual(action, b'responsedata') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
391 |
self.assertEqual(meta[b'data'], b'') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
392 |
self.assertFalse(meta[b'expectmore']) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
393 |
self.assertTrue(meta[b'eos']) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
394 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
395 |
def testzlibmultipleresponses(self): |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
396 |
# We feed in zlib compressed data on the same stream but belonging to |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
397 |
# 2 different requests. This tests our flushing behavior. |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
398 |
reactor = framing.clientreactor(globalui, buffersends=False, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
399 |
hasmultiplesend=True) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
400 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
401 |
request1, action, meta = reactor.callcommand(b'foo', {}) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
402 |
for f in meta[b'framegen']: |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
403 |
pass |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
404 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
405 |
request2, action, meta = reactor.callcommand(b'foo', {}) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
406 |
for f in meta[b'framegen']: |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
407 |
pass |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
408 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
409 |
outstream = framing.outputstream(2) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
410 |
outstream.setencoder(globalui, b'zlib') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
411 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
412 |
response1 = b''.join(cborutil.streamencode({ |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
413 |
b'status': b'ok', |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
414 |
b'extra': b'response1' * 10, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
415 |
})) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
416 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
417 |
response2 = b''.join(cborutil.streamencode({ |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
418 |
b'status': b'error', |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
419 |
b'extra': b'response2' * 10, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
420 |
})) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
421 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
422 |
action, meta = sendframe(reactor, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
423 |
ffs(b'%d 2 stream-begin stream-settings eos cbor:b"zlib"' % |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
424 |
request1.requestid)) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
425 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
426 |
self.assertEqual(action, b'noop') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
427 |
self.assertEqual(meta, {}) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
428 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
429 |
# Feeding partial data in won't get anything useful out. |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
430 |
action, meta = sendframe(reactor, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
431 |
ffs(b'%d 2 encoded command-response continuation %s' % ( |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
432 |
request1.requestid, outstream.encode(response1)))) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
433 |
self.assertEqual(action, b'responsedata') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
434 |
self.assertEqual(meta[b'data'], b'') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
435 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
436 |
# But flushing data at both ends will get our original data. |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
437 |
action, meta = sendframe(reactor, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
438 |
ffs(b'%d 2 encoded command-response eos %s' % ( |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
439 |
request1.requestid, outstream.flush()))) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
440 |
self.assertEqual(action, b'responsedata') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
441 |
self.assertEqual(meta[b'data'], response1) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
442 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
443 |
# We should be able to reuse the compressor/decompressor for the |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
444 |
# 2nd response. |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
445 |
action, meta = sendframe(reactor, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
446 |
ffs(b'%d 2 encoded command-response continuation %s' % ( |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
447 |
request2.requestid, outstream.encode(response2)))) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
448 |
self.assertEqual(action, b'responsedata') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
449 |
self.assertEqual(meta[b'data'], b'') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
450 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
451 |
action, meta = sendframe(reactor, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
452 |
ffs(b'%d 2 encoded command-response eos %s' % ( |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
453 |
request2.requestid, outstream.flush()))) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
454 |
self.assertEqual(action, b'responsedata') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
455 |
self.assertEqual(meta[b'data'], response2) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
456 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
457 |
@unittest.skipUnless(zstd, 'zstd not available') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
458 |
def testzstd8mbencoding(self): |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
459 |
reactor = framing.clientreactor(globalui, buffersends=False) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
460 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
461 |
request, action, meta = reactor.callcommand(b'foo', {}) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
462 |
for f in meta[b'framegen']: |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
463 |
pass |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
464 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
465 |
action, meta = sendframe(reactor, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
466 |
ffs(b'%d 2 stream-begin stream-settings eos cbor:b"zstd-8mb"' % |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
467 |
request.requestid)) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
468 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
469 |
self.assertEqual(action, b'noop') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
470 |
self.assertEqual(meta, {}) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
471 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
472 |
result = { |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
473 |
b'status': b'ok', |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
474 |
} |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
475 |
encoded = b''.join(cborutil.streamencode(result)) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
476 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
477 |
encoder = framing.zstd8mbencoder(globalui) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
478 |
compressed = encoder.encode(encoded) + encoder.finish() |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
479 |
self.assertEqual(zstd.ZstdDecompressor().decompress( |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
480 |
compressed, max_output_size=len(encoded)), encoded) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
481 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
482 |
action, meta = sendframe(reactor, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
483 |
ffs(b'%d 2 encoded command-response eos %s' % |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
484 |
(request.requestid, compressed))) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
485 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
486 |
self.assertEqual(action, b'responsedata') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
487 |
self.assertEqual(meta[b'data'], encoded) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
488 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
489 |
@unittest.skipUnless(zstd, 'zstd not available') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
490 |
def testzstd8mbencodingsinglebyteframes(self): |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
491 |
reactor = framing.clientreactor(globalui, buffersends=False) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
492 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
493 |
request, action, meta = reactor.callcommand(b'foo', {}) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
494 |
for f in meta[b'framegen']: |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
495 |
pass |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
496 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
497 |
action, meta = sendframe(reactor, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
498 |
ffs(b'%d 2 stream-begin stream-settings eos cbor:b"zstd-8mb"' % |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
499 |
request.requestid)) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
500 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
501 |
self.assertEqual(action, b'noop') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
502 |
self.assertEqual(meta, {}) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
503 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
504 |
result = { |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
505 |
b'status': b'ok', |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
506 |
} |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
507 |
encoded = b''.join(cborutil.streamencode(result)) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
508 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
509 |
compressed = zstd.ZstdCompressor().compress(encoded) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
510 |
self.assertEqual(zstd.ZstdDecompressor().decompress(compressed), |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
511 |
encoded) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
512 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
513 |
chunks = [] |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
514 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
515 |
for i in range(len(compressed)): |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
516 |
char = compressed[i:i + 1] |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
517 |
if char == b'\\': |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
518 |
char = b'\\\\' |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
519 |
action, meta = sendframe(reactor, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
520 |
ffs(b'%d 2 encoded command-response continuation %s' % |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
521 |
(request.requestid, char))) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
522 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
523 |
self.assertEqual(action, b'responsedata') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
524 |
chunks.append(meta[b'data']) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
525 |
self.assertTrue(meta[b'expectmore']) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
526 |
self.assertFalse(meta[b'eos']) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
527 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
528 |
# zstd decompressor will flush at frame boundaries. |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
529 |
self.assertEqual(b''.join(chunks), encoded) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
530 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
531 |
# End the stream for good measure. |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
532 |
action, meta = sendframe(reactor, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
533 |
ffs(b'%d 2 stream-end command-response eos ' % request.requestid)) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
534 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
535 |
self.assertEqual(action, b'responsedata') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
536 |
self.assertEqual(meta[b'data'], b'') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
537 |
self.assertFalse(meta[b'expectmore']) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
538 |
self.assertTrue(meta[b'eos']) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
539 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
540 |
@unittest.skipUnless(zstd, 'zstd not available') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
541 |
def testzstd8mbmultipleresponses(self): |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
542 |
# We feed in zstd compressed data on the same stream but belonging to |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
543 |
# 2 different requests. This tests our flushing behavior. |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
544 |
reactor = framing.clientreactor(globalui, buffersends=False, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
545 |
hasmultiplesend=True) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
546 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
547 |
request1, action, meta = reactor.callcommand(b'foo', {}) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
548 |
for f in meta[b'framegen']: |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
549 |
pass |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
550 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
551 |
request2, action, meta = reactor.callcommand(b'foo', {}) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
552 |
for f in meta[b'framegen']: |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
553 |
pass |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
554 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
555 |
outstream = framing.outputstream(2) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
556 |
outstream.setencoder(globalui, b'zstd-8mb') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
557 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
558 |
response1 = b''.join(cborutil.streamencode({ |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
559 |
b'status': b'ok', |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
560 |
b'extra': b'response1' * 10, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
561 |
})) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
562 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
563 |
response2 = b''.join(cborutil.streamencode({ |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
564 |
b'status': b'error', |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
565 |
b'extra': b'response2' * 10, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
566 |
})) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
567 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
568 |
action, meta = sendframe(reactor, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
569 |
ffs(b'%d 2 stream-begin stream-settings eos cbor:b"zstd-8mb"' % |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
570 |
request1.requestid)) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
571 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
572 |
self.assertEqual(action, b'noop') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
573 |
self.assertEqual(meta, {}) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
574 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
575 |
# Feeding partial data in won't get anything useful out. |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
576 |
action, meta = sendframe(reactor, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
577 |
ffs(b'%d 2 encoded command-response continuation %s' % ( |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
578 |
request1.requestid, outstream.encode(response1)))) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
579 |
self.assertEqual(action, b'responsedata') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
580 |
self.assertEqual(meta[b'data'], b'') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
581 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
582 |
# But flushing data at both ends will get our original data. |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
583 |
action, meta = sendframe(reactor, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
584 |
ffs(b'%d 2 encoded command-response eos %s' % ( |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
585 |
request1.requestid, outstream.flush()))) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
586 |
self.assertEqual(action, b'responsedata') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
587 |
self.assertEqual(meta[b'data'], response1) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
588 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
589 |
# We should be able to reuse the compressor/decompressor for the |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
590 |
# 2nd response. |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
591 |
action, meta = sendframe(reactor, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
592 |
ffs(b'%d 2 encoded command-response continuation %s' % ( |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
593 |
request2.requestid, outstream.encode(response2)))) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
594 |
self.assertEqual(action, b'responsedata') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
595 |
self.assertEqual(meta[b'data'], b'') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
596 |
|
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
597 |
action, meta = sendframe(reactor, |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
598 |
ffs(b'%d 2 encoded command-response eos %s' % ( |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
599 |
request2.requestid, outstream.flush()))) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
600 |
self.assertEqual(action, b'responsedata') |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
601 |
self.assertEqual(meta[b'data'], response2) |
e67522413ca8
wireprotov2: define and use stream encoders
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40129
diff
changeset
|
602 |
|
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
603 |
if __name__ == '__main__': |
40482
07b87ee2ea75
tests: skip wireproto clientreactor tests on Python 3.6.0-3.6.3 inclusive
Augie Fackler <augie@google.com>
parents:
40132
diff
changeset
|
604 |
if (3, 6, 0) <= sys.version_info <= (3, 6, 3): |
07b87ee2ea75
tests: skip wireproto clientreactor tests on Python 3.6.0-3.6.3 inclusive
Augie Fackler <augie@google.com>
parents:
40132
diff
changeset
|
605 |
# Python 3.6.0 through 3.6.3 inclusive shipped with |
07b87ee2ea75
tests: skip wireproto clientreactor tests on Python 3.6.0-3.6.3 inclusive
Augie Fackler <augie@google.com>
parents:
40132
diff
changeset
|
606 |
# https://bugs.python.org/issue31825 and we can't run these |
07b87ee2ea75
tests: skip wireproto clientreactor tests on Python 3.6.0-3.6.3 inclusive
Augie Fackler <augie@google.com>
parents:
40132
diff
changeset
|
607 |
# tests on those specific versions of Python. Sigh. |
07b87ee2ea75
tests: skip wireproto clientreactor tests on Python 3.6.0-3.6.3 inclusive
Augie Fackler <augie@google.com>
parents:
40132
diff
changeset
|
608 |
sys.exit(80) |
37543
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
609 |
import silenttestrunner |
01361be9e2dc
wireproto: introduce a reactor for client-side state
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
610 |
silenttestrunner.main(__name__) |