syndicate-nim/tests/test_protocols.nim

30 lines
897 B
Nim
Raw Permalink Normal View History

2022-10-21 16:13:17 +00:00
import std/[streams, strutils, unittest]
import preserves
import syndicate/relays
2023-08-16 08:35:48 +00:00
import syndicate/protocols/sturdy
2022-12-14 04:25:43 +00:00
2023-12-31 17:15:06 +00:00
type WireRef = sturdy.WireRef
2022-10-21 16:13:17 +00:00
suite "protocols":
test "PDiscard":
var pd: PDiscard
check $pd == "<_>"
test "stuff":
const
data = parseHexStr "b5b590b4b306617373657274b4b3074f627365727665b4b303726563b3067274742d6d73b5b4b3036c697483406805604189374c84b4b3036c6974b3062e3134342e3184b4b30462696e64b4b3015f8484b4b30462696e64b4b3015f8484b4b30462696e64b4b3015f8484b4b30462696e64b4b3015f8484848486b590908484a2132403848484b5b590b4b30772657472616374a2132403848484"
var
str = newStringStream(data)
while not str.atEnd:
var pos = str.getPosition
echo "decode position: ", pos
try:
2024-01-01 18:46:48 +00:00
var a = decodePreserves(str)
2022-10-21 16:13:17 +00:00
echo a
2023-08-16 08:35:48 +00:00
except CatchableError:
2022-10-21 16:13:17 +00:00
str.setPosition pos
echo str.readAll.toHex
break