diff --git a/lock.json b/lock.json index 27592ff..4b570ab 100644 --- a/lock.json +++ b/lock.json @@ -127,10 +127,10 @@ "taps" ], "path": "/nix/store/n86g5fw60z1k53bn35zvrwlwmyk3ixdn-source", - "rev": "756cb07b4f874181ad34c370cad6082ee65f646d", + "rev": "6ec1491c178bd37491ca55c012675bd525391e29", "sha256": "0dp7ml3kj2fi6isvjkkxf02hwj0gshx6qra0ghnk2cbfykbcgfp8", "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", diff --git a/tests/solo5_relays_test.nim b/tests/solo5_relays_test.nim new file mode 100644 index 0000000..bd92680 --- /dev/null +++ b/tests/solo5_relays_test.nim @@ -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) diff --git a/tests/solo5_relays_test.nim.cfg b/tests/solo5_relays_test.nim.cfg new file mode 100644 index 0000000..0d0831c --- /dev/null +++ b/tests/solo5_relays_test.nim.cfg @@ -0,0 +1,3 @@ +define:ipv6Enabled +define:traceSyndicate +import:"std/assertions" diff --git a/tests/solo5_test.nim b/tests/solo5_test.nim new file mode 100644 index 0000000..7be9c60 --- /dev/null +++ b/tests/solo5_test.nim @@ -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" diff --git a/tests/solo5_test.nim.cfg b/tests/solo5_test.nim.cfg new file mode 100644 index 0000000..e672819 --- /dev/null +++ b/tests/solo5_test.nim.cfg @@ -0,0 +1,2 @@ +define:ipv6Enabled +import:"std/assertions"