ENcode arbitrarly many bytes in testsuite

This commit is contained in:
Tristan B. Kildaire 2020-04-26 13:18:54 +02:00
parent 1428249568
commit aeb02ea84d
1 changed files with 4 additions and 4 deletions

View File

@ -7,7 +7,7 @@ def basicTest():
d.connect(("127.0.0.1",2221)) d.connect(("127.0.0.1",2221))
bys=json.dumps({"header":{"authentication":{"username":"tbk", "password":"passwd"}, "scope":"client"},"payload":{"data":"ABBA","type":"type1"}}) bys=json.dumps({"header":{"authentication":{"username":"tbk", "password":"passwd"}, "scope":"client"},"payload":{"data":"ABBA","type":"type1"}})
print(bys) print(bys)
d.send(bytes([len(bys),0,0,0])) d.send(len(bys).to_bytes(4, "little"))
d.send(bys.encode()) d.send(bys.encode())
d.close() d.close()
@ -19,7 +19,7 @@ def commandBuiltInClose():
"command" : {"type" : "close", "args" : None} "command" : {"type" : "close", "args" : None}
},"type":"builtin"}}) },"type":"builtin"}})
print(bys) print(bys)
d.send(bytes([len(bys),0,0,0])) d.send(len(bys).to_bytes(4, "little"))
d.send(bys.encode()) d.send(bys.encode())
d.close() d.close()
@ -31,7 +31,7 @@ def commandAuthTest():
"command" : {"type" : "login", "args" : {"username" :"1", "password":"2"}} "command" : {"type" : "login", "args" : {"username" :"1", "password":"2"}}
},"type":"builtin"}}) },"type":"builtin"}})
print(bys) print(bys)
d.send(bytes([len(bys),0,0,0])) d.send(len(bys).to_bytes(4, "little"))
d.send(bys.encode()) d.send(bys.encode())
d.close() d.close()
@ -42,7 +42,7 @@ def simpleTest():
d.connect(("127.0.0.1",2224)) d.connect(("127.0.0.1",2224))
bys=json.dumps({"name":1}) bys=json.dumps({"name":1})
print(bys) print(bys)
d.send(bytes([len(bys),0,0,0])) d.send(len(bys).to_bytes(4, "little"))
d.send(bys.encode()) d.send(bys.encode())
while True: pass while True: pass
d.close() d.close()