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
|
|
|
|
::
|
2019-06-29 00:26:40 +03:00
|
|
|
=/ alice-sym (derive-symmetric-key:vane bob-pub alice-sec)
|
|
|
|
=/ bob-sym (derive-symmetric-key:vane alice-pub bob-sec)
|
2019-06-26 01:35:22 +03:00
|
|
|
::
|
|
|
|
?> =(alice-sym bob-sym)
|
|
|
|
::
|
|
|
|
=. life.ames-state.alice 2
|
|
|
|
=. peers.ames-state.alice
|
|
|
|
%+ ~(put by peers.ames-state.alice) ~doznec-doznec
|
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]]
|
2019-06-26 02:29:17 +03:00
|
|
|
[%known 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
|
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]]
|
2019-06-26 02:29:17 +03:00
|
|
|
[%known peer-state]
|
2019-06-29 00:26:40 +03:00
|
|
|
:: metamorphose
|
2019-06-26 01:35:22 +03:00
|
|
|
::
|
2019-06-29 00:26:40 +03:00
|
|
|
=> .(alice +:(call:(alice) ~[//unix] ** %born ~))
|
|
|
|
=> .(bob +:(call:(bob) ~[//unix] ** %born ~))
|
|
|
|
:: helper core
|
|
|
|
::
|
|
|
|
=>
|
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-29 00:26:40 +03:00
|
|
|
::
|
|
|
|
++ call
|
|
|
|
|= [vane=_alice =duct =task:alef]
|
|
|
|
^- [moves=(list move:alef) _alice]
|
|
|
|
::
|
|
|
|
=/ vane-core (vane(now `@da`(add ~s1 now.vane)))
|
|
|
|
::
|
|
|
|
(call:vane-core duct ** task)
|
|
|
|
::
|
|
|
|
++ take
|
|
|
|
|= [vane=_alice =wire =duct =sign:alef]
|
|
|
|
^- [moves=(list move:alef) _alice]
|
|
|
|
::
|
|
|
|
=/ vane-core (vane(now `@da`(add ~s1 now.vane)))
|
|
|
|
::
|
|
|
|
(take:vane-core wire duct ** sign)
|
2019-06-21 04:36:16 +03:00
|
|
|
--
|
2019-06-29 00:26:40 +03:00
|
|
|
:: test core
|
|
|
|
::
|
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]
|
|
|
|
==
|
|
|
|
::
|
2019-06-29 00:26:40 +03:00
|
|
|
=/ encoded (encode-packet:vane packet)
|
|
|
|
=/ decoded (decode-packet:vane encoded)
|
2019-05-25 05:03:33 +03:00
|
|
|
::
|
|
|
|
%+ expect-eq
|
|
|
|
!> packet
|
|
|
|
!> decoded
|
2019-05-28 06:39:42 +03:00
|
|
|
::
|
|
|
|
++ test-alien-encounter ^- tang
|
2019-06-26 04:34:43 +03:00
|
|
|
::
|
|
|
|
=/ lane-foo=lane:alef [%| `@ux``@`%lane-foo]
|
2019-05-28 06:39:42 +03:00
|
|
|
::
|
2019-07-29 14:05:52 +03:00
|
|
|
=/ =plea:ames [%g /talk [%first %post]]
|
2019-06-26 04:52:50 +03:00
|
|
|
::
|
|
|
|
=/ =shut-packet:alef
|
|
|
|
:* sndr-life=4
|
|
|
|
rcvr-life=3
|
|
|
|
bone=1
|
|
|
|
message-num=1
|
2019-07-29 14:05:52 +03:00
|
|
|
[%& num-fragments=1 fragment-num=0 (jam plea)]
|
2019-06-26 04:52:50 +03:00
|
|
|
==
|
|
|
|
::
|
2019-05-28 06:39:42 +03:00
|
|
|
=/ =packet:alef
|
2019-06-26 04:34:43 +03:00
|
|
|
:* [sndr=~bus rcvr=~doznec-doznec]
|
2019-05-28 06:39:42 +03:00
|
|
|
encrypted=%.y
|
|
|
|
origin=~
|
2019-06-29 00:26:40 +03:00
|
|
|
content=(encrypt:vane alice-sym shut-packet)
|
2019-05-28 06:39:42 +03:00
|
|
|
==
|
2019-06-22 03:07:19 +03:00
|
|
|
::
|
2019-06-29 00:26:40 +03:00
|
|
|
=/ =blob:alef (encode-packet:vane packet)
|
2019-06-26 04:34:43 +03:00
|
|
|
=^ moves1 bob (call bob ~[//unix] %hear lane-foo blob)
|
2019-06-26 04:52:50 +03:00
|
|
|
=^ moves2 bob
|
|
|
|
=/ =point:alef
|
|
|
|
:* rift=1
|
|
|
|
life=4
|
2019-07-29 14:05:52 +03:00
|
|
|
keys=[[life=4 [crypto-suite=1 `@`alice-pub]] ~ ~]
|
2019-06-26 04:52:50 +03:00
|
|
|
sponsor=`~bus
|
|
|
|
==
|
|
|
|
%- take
|
2019-07-29 14:05:52 +03:00
|
|
|
:^ bob /public-keys ~[//unix]
|
2019-06-26 04:52:50 +03:00
|
|
|
^- sign:alef
|
2019-07-29 14:05:52 +03:00
|
|
|
[%k %public-keys %full [n=[~bus point] ~ ~]]
|
2019-05-28 06:39:42 +03:00
|
|
|
::
|
|
|
|
;: weld
|
|
|
|
%+ expect-eq
|
2019-07-29 14:05:52 +03:00
|
|
|
!> [~[//unix] %pass /public-keys %k %public-keys [~bus ~ ~]]~
|
2019-06-26 04:34:43 +03:00
|
|
|
!> moves1
|
2019-05-28 06:39:42 +03:00
|
|
|
::
|
|
|
|
%+ expect-eq
|
2019-07-29 14:05:52 +03:00
|
|
|
!> [~[//unix] %pass /bone/~bus/1 %g %plea ~bus %g /talk [%first %post]]~
|
2019-06-26 04:52:50 +03:00
|
|
|
!> moves2
|
2019-05-28 06:39:42 +03:00
|
|
|
==
|
2019-06-11 23:22:24 +03:00
|
|
|
::
|
2019-06-26 02:39:10 +03:00
|
|
|
++ test-message-flow ^- tang
|
2019-06-11 23:22:24 +03:00
|
|
|
::
|
2019-06-26 02:03:30 +03:00
|
|
|
=^ moves1 alice
|
2019-07-29 14:05:52 +03:00
|
|
|
(call alice ~[/alice] %plea ~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
|
2019-07-29 14:05:52 +03:00
|
|
|
(take bob /bone/~nec/1 ~[/bob] %g %boon [%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-26 02:39:10 +03:00
|
|
|
;: weld
|
|
|
|
%+ expect-eq
|
|
|
|
!> :~ :+ ~[/alice] %give [%done error=~]
|
|
|
|
:+ ~[/alice] %pass
|
|
|
|
[/pump/~doznec-doznec/0 %b %rest ~1111.1.1..00.00.06]
|
|
|
|
==
|
|
|
|
!> moves4
|
|
|
|
::
|
|
|
|
%+ expect-eq
|
2019-07-29 14:05:52 +03:00
|
|
|
!> [~[/alice] %give %boon [%post 'first1!!']]
|
2019-06-26 02:39:10 +03:00
|
|
|
!> (snag 1 `(list move:alef)`moves6)
|
|
|
|
==
|
2019-06-21 04:36:16 +03:00
|
|
|
::
|
|
|
|
++ test-nack ^- tang
|
2019-06-26 02:03:30 +03:00
|
|
|
=^ moves1 alice
|
2019-07-29 14:05:52 +03:00
|
|
|
(call alice ~[/alice] %plea ~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:58:42 +03:00
|
|
|
%+ expect-eq
|
|
|
|
!> [~[/alice] %give %done `error]
|
|
|
|
!> (snag 1 `(list move:alef)`moves5)
|
2019-05-25 05:03:33 +03:00
|
|
|
--
|