1
0
forked from Tank/braga

add tests

This commit is contained in:
Татьяна Фарбер 2026-03-08 23:58:41 +04:00
parent 0ad07a1ad6
commit f69bd423c8
2 changed files with 30 additions and 0 deletions

28
tests/client.lua Normal file
View File

@ -0,0 +1,28 @@
local host, port = "ulgrad.ru", 4999
local json = require('cjson.safe')
local base64 = require('base64')
local socket = require("socket")
local tcp = assert(socket.tcp())
tcp:connect(host, port);
local pack = {}
pack['id'] = 'test'
pack['bme'] = {['temp'] = 10,['press'] = 100,['alt'] = 300}
pack['dht'] = {['temp'] = 12,['humi'] = 67}
pack['uf'] = 5
-- eyJibWUiOnsiYWx0IjozMDAsInRlbXAiOjEwLCJwcmVzcyI6MTAwfSwiZGh0Ijp7Imh1bWkiOjY3LCJ0ZW1wIjoxMn0sInVmIjo1LCJpZCI6InRlc3QifQ==
tcp:send(base64.encode(json.encode(pack)))
print(base64.encode(json.encode(pack)))
while true do
local s, status, partial = tcp:receive()
print(s or partial)
print(status)
if status == "closed" then break end
end
tcp:close()

2
tests/tcp.test Normal file
View File

@ -0,0 +1,2 @@
nc meteo.ulgrad.ru 4999
nc 5.187.7.142 4999