shrub/pkg/arvo/lib/test/ames-gall.hoon

168 lines
5.0 KiB
Plaintext
Raw Normal View History

/+ *test, test-pub, test-sub
2022-08-19 15:33:39 +03:00
/= ames-raw /sys/vane/ames
/= gall-raw /sys/vane/gall
::
2022-08-19 15:33:39 +03:00
=/ ames-bunt (ames-raw ~zod)
=/ gall-bunt (gall-raw ~zod)
2022-08-12 00:04:01 +03:00
::
|%
2022-08-19 15:33:39 +03:00
+$ gall-gate _(make-gall ~zod)
+$ ames-gate _nec:ames-nec-bud
++ nec-bud
=/ a ames-nec-bud
=/ gall-nec (make-gall ~nec)
=. gall-nec (load-agent ~nec gall-nec %sub test-sub)
=/ gall-bud (make-gall ~bud)
=. gall-bud (load-agent ~bud gall-bud %pub test-pub)
:* nec=[ames=nec.a gall=gall-nec]
bud=[ames=bud.a gall=gall-bud]
==
:: +gall-check-call: run gall task, assert produces expected-moves
::
++ gall-check-call
|= $: =gall-gate
[now=@da eny=@ =roof]
[=duct task=(hobo task:gall)]
expected-moves=(list move:gall-bunt)
==
^- [tang ^gall-gate]
=/ gall-core (gall-gate now eny roof)
=^ moves gall-gate (call:gall-core duct dud=~ task)
[(expect-eq !>(expected-moves) !>(moves)) gall-gate]
::
++ gall-call
|= [=gall-gate =duct task=(hobo task:gall) =roof]
%. [duct dud=~ task]
call:(gall-gate now=~1111.1.1 eny=`@`0xdead.beef roof)
:: +gall-check-take: run gall sign, assert produces expected-moves
::
++ gall-check-take
|= $: =gall-gate
[now=@da eny=@ =roof]
[=wire =duct =sign-arvo]
expected-moves=(list move:gall-bunt)
==
^- [tang ^gall-gate]
=/ gall-core (gall-gate now eny roof)
=^ moves gall-gate (take:gall-core wire duct dud=~ sign-arvo)
[(expect-eq !>(expected-moves) !>(moves)) gall-gate]
::
++ gall-take
|= [=gall-gate =wire =duct =sign-arvo =roof]
%. [wire duct dud=~ sign-arvo]
take:(gall-gate now=~1111.1.1 eny=`@`0xdead.beef roof)
2022-08-19 15:33:39 +03:00
:: +ames-check-call: run gall task, assert produces expected-moves
::
++ ames-check-call
|= $: =ames-gate
[now=@da eny=@ =roof]
[=duct task=(hobo task:ames)]
expected-moves=(list move:ames-bunt)
==
^- [tang ^ames-gate]
=/ ames-core (ames-gate now eny roof)
=^ moves ames-gate (call:ames-core duct dud=~ task)
[(expect-eq !>(expected-moves) !>(moves)) ames-gate]
::
++ ames-call
|= [=ames-gate =duct task=(hobo task:ames) =roof]
%. [duct dud=~ task]
call:(ames-gate now=~1111.1.1 eny=`@`0xdead.beef roof)
:: +ames: run ames sign, assert produces expected-moves
::
++ ames-check-take
|= $: =ames-gate
[now=@da eny=@ =roof]
[=wire =duct =sign:ames-bunt]
expected-moves=(list move:ames-bunt)
==
^- [tang ^ames-gate]
=/ ames-core (ames-gate now eny roof)
=^ moves ames-gate (take:ames-core wire duct dud=~ sign)
[(expect-eq !>(moves) !>(expected-moves)) ames-gate]
::
2022-08-12 00:04:01 +03:00
++ ames-nec-bud
:: create ~nec
::
2022-08-19 15:33:39 +03:00
=/ nec (ames-raw ~nec)
2022-08-12 00:04:01 +03:00
=. now.nec ~1111.1.1
=. eny.nec 0xdead.beef
=. life.ames-state.nec 2
=. rof.nec |=(* ``[%noun !>(*(list turf))])
=. crypto-core.ames-state.nec (pit:nu:crub:crypto 512 (shaz 'nec'))
=/ nec-pub pub:ex:crypto-core.ames-state.nec
=/ nec-sec sec:ex:crypto-core.ames-state.nec
:: create ~bud
::
2022-08-19 15:33:39 +03:00
=/ bud (ames-raw ~bud)
2022-08-12 00:04:01 +03:00
=. now.bud ~1111.1.1
=. eny.bud 0xbeef.dead
=. life.ames-state.bud 3
=. rof.bud |=(* ``[%noun !>(*(list turf))])
=. crypto-core.ames-state.bud (pit:nu:crub:crypto 512 (shaz 'bud'))
=/ bud-pub pub:ex:crypto-core.ames-state.bud
=/ bud-sec sec:ex:crypto-core.ames-state.bud
::
2022-08-19 15:33:39 +03:00
=/ nec-sym (derive-symmetric-key:ames-raw bud-pub nec-sec)
=/ bud-sym (derive-symmetric-key:ames-raw nec-pub bud-sec)
2022-08-12 00:04:01 +03:00
?> =(nec-sym bud-sym)
:: tell ~nec about ~bud
::
=. peers.ames-state.nec
%+ ~(put by peers.ames-state.nec) ~bud
=| =peer-state:ames
=. -.peer-state
:* symmetric-key=bud-sym
life=3
rift=0
public-key=bud-pub
sponsor=~nec
==
=. route.peer-state `[direct=%.y `lane:ames`[%& ~nec]]
[%known peer-state]
:: tell ~bud about ~nec
::
=. peers.ames-state.bud
%+ ~(put by peers.ames-state.bud) ~nec
=| =peer-state:ames
=. -.peer-state
:* symmetric-key=nec-sym
life=2
rift=0
public-key=nec-pub
sponsor=~nec
==
=. route.peer-state `[direct=%.y `lane:ames`[%| `@`%lane-bar]]
[%known peer-state]
:: metamorphose
::
=> .(nec +:(call:(nec) ~[//unix] ~ %born ~))
=> .(bud +:(call:(bud) ~[//unix] ~ %born ~))
::
[nec=nec bud=bud]
::
++ make-gall
|= =ship
=/ gall-pupa (gall-raw ship)
=/ gall-core (gall-pupa now=~1111.1.1 eny=`@`0xdead.beef scry=*roof)
=+ [out adult]=(call:gall-core duct=~[/init] dud=~ task=[%init ~])
adult
::
++ load-agent
|= [=ship =gall-gate =dude:gall =agent:gall]
=^ * gall-gate
(gall-call gall-gate ~[/jolt] [%jolt %base dude] *roof)
=^ * gall-gate
=/ =sign-arvo
:+ %clay %writ
`[[%a da+~1111.1.1 %base] /app/[dude]/hoon vase+!>(!>(agent))]
%: gall-take
gall-gate
/sys/cor/[dude]/(scot %p ship)/base/(scot %da ~1111.1.1)
~[/jolt]
sign-arvo
*roof
==
gall-gate
2022-08-12 00:04:01 +03:00
--