mirror of https://github.com/vacp2p/research.git
CAS basic test mock
This commit is contained in:
parent
f92903f15b
commit
ec0b3a85bc
|
@ -9,5 +9,10 @@ nsserver: src/nsserver.nim src/ns_service_pb.nim src/ns_service_twirp.nim
|
|||
node: src/node.nim
|
||||
nim c -o:bin/node src/node.nim
|
||||
|
||||
castest: tests/castest.nim
|
||||
nim c --r o:bin/castest tests/castest.nim
|
||||
|
||||
test: castest
|
||||
|
||||
%_pb.nim %_twirp.nim: %.proto
|
||||
nimtwirp_build -I:. --out:. $^
|
||||
|
|
|
@ -14,18 +14,21 @@ import remote_log_pb
|
|||
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)
|
||||
# CAS util
|
||||
proc createContent*(s: string): vac_cas_Content =
|
||||
var content = newvac_cas_Content()
|
||||
try:
|
||||
content.data = hexToSeqByte(s.toHex())
|
||||
except:
|
||||
echo("Unable to create Content data")
|
||||
quit(QuitFailure)
|
||||
return content
|
||||
|
||||
let casClient = newCASClient("http://localhost:8001")
|
||||
|
||||
# XXX: resp is wrong here
|
||||
try:
|
||||
let content = createContent("foo")
|
||||
let resp = Add(casClient, content)
|
||||
let str = parseHexStr(toHex(resp.id))
|
||||
echo(&"I got a new post: {str}")
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
import cas_service_pb
|
||||
import cas_service_twirp
|
||||
import strutils
|
||||
import byteutils
|
||||
import strformat
|
||||
|
||||
# XXX: Hacky tests
|
||||
# Can retrieve and post node
|
||||
|
||||
# CAS util
|
||||
proc createContent*(s: string): vac_cas_Content =
|
||||
var content = newvac_cas_Content()
|
||||
try:
|
||||
content.data = hexToSeqByte(s.toHex())
|
||||
except:
|
||||
echo("Unable to create Content data")
|
||||
quit(QuitFailure)
|
||||
return content
|
||||
|
||||
var content = createContent("hello")
|
||||
|
||||
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}")
|
||||
|
||||
when isMainModule:
|
||||
echo("Running CAS tests")
|
||||
doAssert 1 == 1
|
||||
# doAssert 1 == 2
|
|
@ -0,0 +1 @@
|
|||
--path:"../src"
|
Loading…
Reference in New Issue