Browse Source

add large orderbook to test BigString, remove BigUnicode

master
Adam Gibson 10 years ago
parent
commit
f1ae5d8ecf
No known key found for this signature in database
GPG Key ID: B3AE09F1E9A3197A
  1. 21
      jmbase/jmbase/bigstring.py
  2. 4
      jmbase/test/test_commands.py

21
jmbase/jmbase/bigstring.py

@ -1,7 +1,7 @@
try: try:
from cStringIO import StringIO from cStringIO import StringIO
except ImportError: except ImportError: #pragma: no cover
from StringIO import StringIO from StringIO import StringIO #pragma: no cover
from itertools import count from itertools import count
from twisted.protocols import amp from twisted.protocols import amp
@ -45,20 +45,3 @@ class BigString(amp.Argument):
def fromvalue(self, value): def fromvalue(self, value):
return value return value
class BigUnicode(BigString):
"""
A unicode-string amp.Argument with no 65,535 length limit.
Each value for a key/value pair in an AMP box may not
exceed 65,535 bytes in length. So if we *really* want to
send potentially larger values, this class will implicitly
encode/decode them to/from an arbitrary additional
number of key/value pairs that are given automatic key
names by prefixing this Argument's key name to a counter.
"""
def buildvalue(self, value):
return value.decode('utf-8')
def fromvalue(self, value):
return value.encode('utf-8')

4
jmbase/test/test_commands.py

@ -84,8 +84,10 @@ class JMTestServerProtocol(JMBaseProtocol):
@JMRequestOffers.responder @JMRequestOffers.responder
def on_JM_REQUEST_OFFERS(self): def on_JM_REQUEST_OFFERS(self):
show_receipt("JMREQUESTOFFERS") show_receipt("JMREQUESTOFFERS")
#build a huge orderbook to test BigString Argument
orderbook = ["aaaa" for _ in range(2**15)]
d = self.callRemote(JMOffers, d = self.callRemote(JMOffers,
orderbook=json.dumps(["This", "is", "an", "orderbook"])) orderbook=json.dumps(orderbook))
self.defaultCallbacks(d) self.defaultCallbacks(d)
return {'accepted': True} return {'accepted': True}

Loading…
Cancel
Save