2019-05-25 05:03:33 +03:00
|
|
|
/+ *test
|
|
|
|
/= alef /: /===/sys/vane/alef
|
|
|
|
/!noun/
|
2019-06-26 01:35:22 +03:00
|
|
|
:: construct some test fixtures
|
2019-05-25 05:03:33 +03:00
|
|
|
::
|
2019-05-28 06:39:42 +03:00
|
|
|
=/ vane (alef !>(..zuse))
|
|
|
|
::
|
2019-06-26 01:35:22 +03:00
|
|
|
=/ alice vane
|
|
|
|
=/ bob vane
|
|
|
|
::
|
2019-06-26 02:03:30 +03:00
|
|
|
=. our.alice ~nec
|
|
|
|
=. now.alice ~1111.1.1
|
|
|
|
=. eny.alice 0xdead.beef
|
|
|
|
::
|
|
|
|
=. our.bob ~doznec-doznec
|
|
|
|
=. now.bob ~1111.1.1
|
|
|
|
=. eny.bob 0xbeef.dead
|
|
|
|
::
|
2019-06-26 01:35:22 +03:00
|
|
|
=. crypto-core.ames-state.alice (pit:nu:crub:crypto 512 (shaz 'alice'))
|
|
|
|
=. crypto-core.ames-state.bob (pit:nu:crub:crypto 512 (shaz 'bob'))
|
|
|
|
::
|
|
|
|
=/ alice-pub pub:ex:crypto-core.ames-state.alice
|
|
|
|
=/ alice-sec sec:ex:crypto-core.ames-state.alice
|
|
|
|
=/ bob-pub pub:ex:crypto-core.ames-state.bob
|
|
|
|
=/ bob-sec sec:ex:crypto-core.ames-state.bob
|
|
|
|
::
|
|
|
|
=/ alice-sym (derive-symmetric-key:alef bob-pub alice-sec)
|
|
|
|
=/ bob-sym (derive-symmetric-key:alef alice-pub bob-sec)
|
|
|
|
::
|
|
|
|
?> =(alice-sym bob-sym)
|
|
|
|
::
|
|
|
|
=. life.ames-state.alice 2
|
|
|
|
=. peers.ames-state.alice
|
|
|
|
%+ ~(put by peers.ames-state.alice) ~doznec-doznec
|
|
|
|
:- %known
|
|
|
|
^- peer-state:alef
|
2019-06-26 02:27:50 +03:00
|
|
|
=| =peer-state:alef
|
|
|
|
=. -.peer-state
|
|
|
|
:* symmetric-key=bob-sym
|
|
|
|
life=3
|
|
|
|
public-key=bob-pub
|
|
|
|
sponsor=~marzod
|
|
|
|
==
|
|
|
|
=. route.peer-state `[direct=%.y `lane:alef`[%& ~nec]]
|
|
|
|
peer-state
|
2019-06-26 01:35:22 +03:00
|
|
|
::
|
|
|
|
=. life.ames-state.bob 3
|
|
|
|
=. peers.ames-state.bob
|
|
|
|
%+ ~(put by peers.ames-state.bob) ~nec
|
|
|
|
:- %known
|
|
|
|
^- peer-state:alef
|
2019-06-26 02:27:50 +03:00
|
|
|
=| =peer-state:alef
|
|
|
|
=. -.peer-state
|
|
|
|
:* symmetric-key=alice-sym
|
|
|
|
life=2
|
|
|
|
public-key=alice-pub
|
|
|
|
sponsor=~nec
|
|
|
|
==
|
|
|
|
=. route.peer-state `[direct=%.y `lane:alef`[%| `@`%lane-bar]]
|
|
|
|
peer-state
|
2019-06-26 01:35:22 +03:00
|
|
|
::
|
2019-06-21 04:36:16 +03:00
|
|
|
|%
|
|
|
|
++ move-to-packet
|
|
|
|
|= =move:alef
|
|
|
|
^- [=lane:alef =blob:alef]
|
|
|
|
::
|
|
|
|
?> ?=([%give %send *] +.move)
|
|
|
|
[lane blob]:+>+.move
|
|
|
|
::
|
|
|
|
++ is-move-send
|
|
|
|
|= =move:alef
|
|
|
|
^- ?
|
|
|
|
?=([%give %send *] card.move)
|
2019-06-26 01:26:52 +03:00
|
|
|
::
|
|
|
|
++ snag-packet
|
|
|
|
|= [index=@ud moves=(list move:alef)]
|
|
|
|
^- [=lane:alef =blob:alef]
|
|
|
|
::
|
|
|
|
%- move-to-packet
|
|
|
|
%+ snag index
|
|
|
|
(skim moves is-move-send)
|
2019-06-21 04:36:16 +03:00
|
|
|
--
|
2019-05-25 05:03:33 +03:00
|
|
|
|%
|
|
|
|
++ test-packet-encoding ^- tang
|
|
|
|
::
|
|
|
|
=/ =packet:alef
|
|
|
|
:* [sndr=~nec rcvr=~doznec-doznec]
|
|
|
|
encrypted=%.n
|
|
|
|
origin=~
|
|
|
|
content=[12 13]
|
|
|
|
==
|
|
|
|
::
|
|
|
|
=/ encoded (encode-packet:alef packet)
|
|
|
|
=/ decoded (decode-packet:alef encoded)
|
|
|
|
::
|
|
|
|
%+ expect-eq
|
|
|
|
!> packet
|
|
|
|
!> decoded
|
2019-05-28 06:39:42 +03:00
|
|
|
::
|
|
|
|
++ test-alien-encounter ^- tang
|
|
|
|
::
|
|
|
|
=/ =packet:alef
|
|
|
|
:* [sndr=~nec rcvr=~doznec-doznec]
|
|
|
|
encrypted=%.y
|
|
|
|
origin=~
|
2019-05-28 06:59:53 +03:00
|
|
|
content=%double-secret
|
2019-05-28 06:39:42 +03:00
|
|
|
==
|
|
|
|
=/ =blob:alef (encode-packet:alef packet)
|
|
|
|
::
|
|
|
|
=/ event-args
|
|
|
|
[our=~doznec-doznec eny=0xdead.beef now=~2222.2.2 *sley]
|
|
|
|
::
|
2019-06-22 03:07:19 +03:00
|
|
|
=/ lane-foo=lane:alef [%| `@ux``@`%lane-foo]
|
|
|
|
::
|
2019-05-28 06:39:42 +03:00
|
|
|
=/ res
|
|
|
|
(call:(vane event-args) ~[//unix] *type %hear lane-foo blob)
|
|
|
|
::
|
|
|
|
;: weld
|
|
|
|
%+ expect-eq
|
2019-06-25 02:52:22 +03:00
|
|
|
!> [~[//unix] %pass /alien %j %public-keys ~nec]~
|
2019-05-28 06:39:42 +03:00
|
|
|
!> -.res
|
|
|
|
::
|
|
|
|
%+ expect-eq
|
2019-06-22 03:07:19 +03:00
|
|
|
!> [%alien [lane-foo packet]~ ~ ~]
|
2019-05-28 06:39:42 +03:00
|
|
|
!> (~(got by peers.ames-state.+.res) ~nec)
|
|
|
|
==
|
2019-06-11 23:22:24 +03:00
|
|
|
::
|
|
|
|
++ test-send-rcv-message ^- tang
|
|
|
|
::
|
2019-06-26 02:03:30 +03:00
|
|
|
=^ moves1 alice
|
|
|
|
(call alice ~[/alice] %memo ~doznec-doznec /g/talk [%get %post])
|
2019-06-21 00:52:44 +03:00
|
|
|
::
|
2019-06-26 02:03:30 +03:00
|
|
|
=^ moves2 bob (call bob ~[/bob] %hear (snag-packet 0 moves1))
|
|
|
|
=^ moves3 bob (take bob /bone/~nec/1 ~[/bob] %g %done ~)
|
|
|
|
=^ moves4 alice (call alice ~[/alice] %hear (snag-packet 0 moves3))
|
|
|
|
=^ moves5 bob
|
|
|
|
(take bob /bone/~nec/1 ~[/bob] %g %memo /g/talk [%post 'first1!!'])
|
2019-06-21 00:52:44 +03:00
|
|
|
::
|
2019-06-26 02:03:30 +03:00
|
|
|
=^ moves6 alice (call alice ~[/alice] %hear (snag-packet 0 moves5))
|
|
|
|
=^ moves7 bob (call bob ~[/bob] %hear (snag-packet 0 moves6))
|
2019-06-21 00:52:44 +03:00
|
|
|
::
|
2019-06-20 03:49:22 +03:00
|
|
|
%+ expect-eq
|
2019-06-20 10:21:37 +03:00
|
|
|
!> :~ :+ ~[/alice] %give [%done error=~]
|
2019-06-20 03:49:22 +03:00
|
|
|
:+ ~[/alice] %pass
|
2019-06-26 02:03:30 +03:00
|
|
|
[/pump/~doznec-doznec/0 %b %rest ~1111.1.1..00.00.06]
|
2019-06-20 03:49:22 +03:00
|
|
|
==
|
2019-06-26 02:03:30 +03:00
|
|
|
!> moves4
|
2019-06-21 04:36:16 +03:00
|
|
|
::
|
|
|
|
++ test-nack ^- tang
|
2019-06-26 02:03:30 +03:00
|
|
|
=^ moves1 alice
|
|
|
|
(call alice ~[/alice] %memo ~doznec-doznec /g/talk [%get %post])
|
2019-06-21 04:36:16 +03:00
|
|
|
::
|
2019-06-26 02:03:30 +03:00
|
|
|
=^ moves2 bob (call bob ~[/bob] %hear (snag-packet 0 moves1))
|
|
|
|
=/ =error:alef [%flub [%leaf "sinusoidal repleneration"]~]
|
|
|
|
=^ moves3 bob (take bob /bone/~nec/1 ~[/bob] %g %done `error)
|
|
|
|
=^ moves4 alice (call alice ~[/alice] %hear (snag-packet 0 moves3))
|
|
|
|
=^ moves5 alice (call alice ~[/alice] %hear (snag-packet 1 moves3))
|
|
|
|
=^ moves6 bob (call bob ~[/bob] %hear (snag-packet 0 moves5))
|
2019-06-21 04:36:16 +03:00
|
|
|
::
|
2019-06-26 02:03:30 +03:00
|
|
|
~
|
|
|
|
::
|
|
|
|
++ call
|
|
|
|
|= [vane=_alice =duct =task:alef]
|
|
|
|
^- [moves=(list move:alef) _alice]
|
2019-06-21 04:36:16 +03:00
|
|
|
::
|
2019-06-26 02:03:30 +03:00
|
|
|
=/ vane-core (vane(now `@da`(add ~s1 now.vane)))
|
2019-06-21 04:36:16 +03:00
|
|
|
::
|
2019-06-26 02:03:30 +03:00
|
|
|
(call:vane-core duct ** task)
|
|
|
|
::
|
|
|
|
++ take
|
|
|
|
|= [vane=_alice =wire =duct =sign:alef]
|
|
|
|
^- [moves=(list move:alef) _alice]
|
2019-06-21 04:36:16 +03:00
|
|
|
::
|
2019-06-26 02:03:30 +03:00
|
|
|
=/ vane-core (vane(now `@da`(add ~s1 now.vane)))
|
2019-06-21 04:36:16 +03:00
|
|
|
::
|
2019-06-26 02:03:30 +03:00
|
|
|
(take:vane-core wire duct ** sign)
|
2019-05-25 05:03:33 +03:00
|
|
|
--
|