basic node (cas/ns client impl)

This commit is contained in:
Oskar Thoren 2019-09-06 10:09:16 +02:00
parent f24163427f
commit b417312871
No known key found for this signature in database
GPG Key ID: B2ECCFD3BC2EF77E
1 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,53 @@
import os
import strformat
import strutils
import cas_service_pb
import cas_service_twirp
import ns_service_pb
import ns_service_twirp
import strutils
import byteutils
# CAS
var content = newvac_cas_Content()
try:
content.data = hexToSeqByte("foo".toHex())
except:
echo("Unable to create Content data")
quit(QuitFailure)
let casClient = newCASClient("http://localhost:8001")
# XXX: resp is wrong here
try:
let resp = Add(casClient, content)
let str = parseHexStr(toHex(resp.id))
echo(&"I got a new post: {str}")
except Exception as e:
echo(&"Exception: {e.msg}")
# NS
var req = newvac_ns_NameUpdate()
try:
req.name = "foo.com"
req.content = hexToSeqByte("foo ns entry".toHex())
except:
echo("Unable to create NameUpdate req")
quit(QuitFailure)
# XXX
let nsClient = newNSClient("http://localhost:8002")
# XXX: resp is wrong here
try:
let resp = Update(nsClient, req)
let str = parseHexStr(toHex(resp.data))
echo(&"I got a new post: {str}")
except Exception as e:
echo(&"Exception: {e.msg}")
echo("Done")