Add solo5 tests
This commit is contained in:
parent
403e54878c
commit
5f45f76452
|
@ -127,10 +127,10 @@
|
||||||
"taps"
|
"taps"
|
||||||
],
|
],
|
||||||
"path": "/nix/store/n86g5fw60z1k53bn35zvrwlwmyk3ixdn-source",
|
"path": "/nix/store/n86g5fw60z1k53bn35zvrwlwmyk3ixdn-source",
|
||||||
"rev": "756cb07b4f874181ad34c370cad6082ee65f646d",
|
"rev": "6ec1491c178bd37491ca55c012675bd525391e29",
|
||||||
"sha256": "0dp7ml3kj2fi6isvjkkxf02hwj0gshx6qra0ghnk2cbfykbcgfp8",
|
"sha256": "0dp7ml3kj2fi6isvjkkxf02hwj0gshx6qra0ghnk2cbfykbcgfp8",
|
||||||
"srcDir": "src",
|
"srcDir": "src",
|
||||||
"url": "https://git.sr.ht/~ehmry/nim_taps/archive/756cb07b4f874181ad34c370cad6082ee65f646d.tar.gz"
|
"url": "https://git.sr.ht/~ehmry/nim_taps/archive/6ec1491c178bd37491ca55c012675bd525391e29.tar.gz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"date": "2024-04-02T15:38:57+01:00",
|
"date": "2024-04-02T15:38:57+01:00",
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
# SPDX-FileCopyrightText: ☭ Emery Hemingway
|
||||||
|
# SPDX-License-Identifier: Unlicense
|
||||||
|
|
||||||
|
import taps
|
||||||
|
import solo5
|
||||||
|
import syndicate, syndicate/relays
|
||||||
|
import preserves
|
||||||
|
|
||||||
|
acquireDevices([("relay", netBasic)], netAcquireHook)
|
||||||
|
|
||||||
|
type Netif {.preservesRecord: "netif"} = object
|
||||||
|
device, ipAddr: string
|
||||||
|
|
||||||
|
proc spawnNetifActor(turn: var Turn; ds: Cap) =
|
||||||
|
spawnActor(turn, "netif") do (turn: var Turn):
|
||||||
|
let facet = turn.facet
|
||||||
|
onInterfaceUp do (device: string; ip: IpAddress):
|
||||||
|
run(facet) do (turn: var Turn):
|
||||||
|
if not ip.isLinkLocal:
|
||||||
|
discard publish(turn, ds, Netif(device: device, ipAddr: $ip))
|
||||||
|
|
||||||
|
runActor("relay-test") do (turn: var Turn):
|
||||||
|
let root = turn.facet
|
||||||
|
onStop(turn) do (turn: var Turn):
|
||||||
|
quit()
|
||||||
|
let ds = newDataspace(turn)
|
||||||
|
spawnNetifActor(turn, ds)
|
||||||
|
spawnRelays(turn, ds)
|
||||||
|
var
|
||||||
|
route: Route
|
||||||
|
pr = parsePreserves $solo5_start_info.cmdline
|
||||||
|
if route.fromPreserves pr:
|
||||||
|
echo "parsed route ", route.toPreserves
|
||||||
|
during(turn, ds, Netif?:{1: grab()}) do (ip: string):
|
||||||
|
echo "Acquired address ", ip
|
||||||
|
resolve(turn, ds, route) do (turn: var Turn; ds: Cap):
|
||||||
|
echo "route resolved!"
|
||||||
|
echo "stopping root facet"
|
||||||
|
stop(turn, root)
|
|
@ -0,0 +1,3 @@
|
||||||
|
define:ipv6Enabled
|
||||||
|
define:traceSyndicate
|
||||||
|
import:"std/assertions"
|
|
@ -0,0 +1,25 @@
|
||||||
|
# SPDX-FileCopyrightText: ☭ Emery Hemingway
|
||||||
|
# SPDX-License-Identifier: Unlicense
|
||||||
|
|
||||||
|
import std/times
|
||||||
|
import solo5
|
||||||
|
import syndicate, syndicate/drivers/timers
|
||||||
|
|
||||||
|
acquireDevices()
|
||||||
|
|
||||||
|
runActor("timer-test") do (turn: var Turn):
|
||||||
|
let timers = newDataspace(turn)
|
||||||
|
spawnTimerDriver(turn, timers)
|
||||||
|
|
||||||
|
onPublish(turn, timers, ?LaterThan(seconds: 1356100000)):
|
||||||
|
echo "now in 13th bʼakʼtun"
|
||||||
|
|
||||||
|
after(turn, timers, initDuration(seconds = 3)) do (turn: var Turn):
|
||||||
|
echo "third timer expired"
|
||||||
|
stopActor(turn)
|
||||||
|
|
||||||
|
after(turn, timers, initDuration(seconds = 1)) do (turn: var Turn):
|
||||||
|
echo "first timer expired"
|
||||||
|
|
||||||
|
after(turn, timers, initDuration(seconds = 2)) do (turn: var Turn):
|
||||||
|
echo "second timer expired"
|
|
@ -0,0 +1,2 @@
|
||||||
|
define:ipv6Enabled
|
||||||
|
import:"std/assertions"
|
Loading…
Reference in New Issue