diff --git a/desk/app/contacts.hoon b/desk/app/contacts.hoon deleted file mode 100644 index 4ba1bd94..00000000 --- a/desk/app/contacts.hoon +++ /dev/null @@ -1,804 +0,0 @@ -/- activity -/+ default-agent, dbug, verb, neg=negotiate -/+ *contacts -:: -:: performance, keep warm -/+ j0=contacts-json-0, j1=contacts-json-1, mark-warmer -:: -|% -:: conventions -:: -:: .con: a contact -:: .rof: our profile -:: .rol: [legacy] our full rolodex -:: .far: foreign peer -:: .for: foreign profile -:: .sag: foreign subscription state -:: -+| %types -+$ card card:agent:gall -+$ state-2 $: %2 - rof=profile - =book - =peers - retry=(map ship @da) :: retry sub at time - == --- -%- %^ agent:neg - notify=| - [~.contacts^%1 ~ ~] - [~.contacts^[~.contacts^%1 ~ ~] ~ ~] -%- agent:dbug -%+ verb | -^- agent:gall -=| state-2 -=* state - -=< |_ =bowl:gall - +* this . - def ~(. (default-agent this %|) bowl) - cor ~(. raw bowl) - :: - ++ on-init - ^- (quip card _this) - =^ cards state abet:init:cor - [cards this] - :: - ++ on-save !>([state okay]) - :: - ++ on-load - |= old=vase - ^- (quip card _this) - =^ cards state abet:(load:cor old) - [cards this] - :: - ++ on-watch - |= =path - ^- (quip card _this) - =^ cards state abet:(peer:cor path) - [cards this] - :: - ++ on-poke - |= [=mark =vase] - ^- (quip card _this) - =^ cards state abet:(poke:cor mark vase) - [cards this] - :: - ++ on-peek peek:cor - ++ on-leave on-leave:def - :: - ++ on-agent - |= [=wire =sign:agent:gall] - ^- (quip card _this) - =^ cards state abet:(agent:cor wire sign) - [cards this] - :: - ++ on-arvo - |= [=wire sign=sign-arvo] - =^ cards state abet:(arvo:cor wire sign) - [cards this] - :: - ++ on-fail on-fail:def - -- - -|% -:: -+| %state -:: -:: namespaced to avoid accidental direct reference -:: -++ raw - =| out=(list card) - |_ =bowl:gall - :: - +| %generic - :: - ++ abet [(flop out) state] - ++ cor . - ++ emit |=(c=card cor(out [c out])) - ++ emil |=(c=(list card) cor(out (weld (flop c) out))) - ++ give |=(=gift:agent:gall (emit %give gift)) - ++ pass |=([=wire =note:agent:gall] (emit %pass wire note)) - :: - +| %operations - :: - ++ pass-activity - |= [who=ship field=(pair @tas value)] - ^- card - =/ =cage activity-action+!>(`action:activity`[%add %contact who field]) - [%pass /activity %agent [our.bowl %activity] %poke cage] - :: - :: +pub: publication management - :: - :: - /v1/news: local updates to our profile and rolodex - :: - /v1/contact: updates to our profile - :: - :: as these publications are trivial, |pub does *not* - :: make use of the +abet pattern. the only behavior of note - :: is wrt the /contact/at/$date path, which exists to minimize - :: redundant network traffic. - :: - :: /epic protocol versions are even more trivial, - :: published ad-hoc, elsewhere. - :: - :: Facts are always send in the following order: - :: 1. [legacy] /news - :: 2. /v1/news - :: 3. /v1/contact - :: - ++ pub - => |% - :: if this proves to be too slow, the set of paths - :: should be maintained statefully: put on +p-init:pub, - :: filtered at some interval (on +load?) to avoid a space leak. - :: - :: XX number of peers is usually around 5.000. - :: this means that the number of subscribers is about the - :: same. Thus on each contact update we need to filter - :: over 5.000 elements: do some benchmarking. - :: - ++ subs - ^- (set path) - %- ~(rep by sup.bowl) - :: default .acc prevents invalid empty fact path in the case - :: of no subscribers - :: - |= [[duct ship pat=path] acc=_(sy `path`/v1/contact ~)] - ?.(?=([%v1 %contact *] pat) acc (~(put in acc) pat)) - ++ fact - |= [pat=(set path) u=update] - ^- gift:agent:gall - [%fact ~(tap in pat) %contact-update-1 !>(u)] - -- - :: - |% - :: +p-anon: delete our profile - :: - ++ p-anon ?.(?=([@ ^] rof) cor (p-commit-self ~)) - :: +p-self: edit our profile - :: - ++ p-self - |= con=(map @tas value) - =/ old=contact - ?.(?=([@ ^] rof) *contact con.rof) - =/ new=contact - (do-edit old con) - ?: =(old new) - cor - ?> (sane-contact new) - (p-commit-self new) - :: +p-page-spot: add ship as a contact - :: - ++ p-page-spot - |= [who=ship mod=contact] - ?: (~(has by book) who) - ~| "peer {} is already a contact" !! - =/ con=contact - ~| "peer {} not found" - =/ far=foreign - (~(got by peers) who) - ?~ for.far *contact - con.for.far - ?> (sane-contact mod) - (p-commit-page who con mod) - :: +p-page: create new contact page - :: - ++ p-page - |= [=kip mod=contact] - ?@ kip - (p-page-spot kip mod) - ?: (~(has by book) kip) - ~| "contact page {} already exists" !! - ?> (sane-contact mod) - (p-commit-page kip ~ mod) - :: +p-edit: edit contact page overlay - :: - ++ p-edit - |= [=kip mod=contact] - =/ =page - ~| "contact page {} does not exist" - (~(got by book) kip) - =/ old=contact - mod.page - =/ new=contact - (do-edit old mod) - ?: =(old new) - cor - ?> (sane-contact new) - (p-commit-edit kip con.page new) - :: +p-wipe: delete a contact page - :: - ++ p-wipe - |= wip=(list kip) - %+ roll wip - |= [=kip acc=_cor] - (p-commit-wipe kip) - :: +p-commit-self: publish modified profile - :: - ++ p-commit-self - |= con=contact - =/ p=profile [(mono wen.rof now.bowl) con] - =. rof p - =. cor - (p-news-0 our.bowl (contact:to-0 con)) - =. cor - (p-response [%self con]) - (give (fact subs [%full p])) - :: +p-commit-page: publish new contact page - :: - ++ p-commit-page - |= [=kip =page] - =. book (~(put by book) kip page) - (p-response [%page kip page]) - :: +p-commit-edit: publish contact page update - :: - ++ p-commit-edit - |= [=kip =page] - =. book - (~(put by book) kip page) - (p-response [%page kip page]) - :: +p-commit-wipe: publish contact page wipe - :: - ++ p-commit-wipe - |= =kip - =. book - (~(del by book) kip) - (p-response [%wipe kip]) - :: +p-init: publish our profile - :: - ++ p-init - |= wen=(unit @da) - ?~ wen (give (fact ~ full+rof)) - ?: =(u.wen wen.rof) cor - :: - :: no future subs - ?>((lth u.wen wen.rof) (give (fact ~ full+rof))) - :: +p-news-0: [legacy] publish news - :: - ++ p-news-0 - |= n=news-0:c0 - (give %fact ~[/news] %contact-news !>(n)) - :: +p-response: publish response - :: - ++ p-response - |= r=response - (give %fact ~[/v1/news] %contact-response-0 !>(r)) - -- - :: - :: +sub: subscription mgmt - :: - :: /contact/*: foreign profiles, _s-impl - :: - :: subscription state is tracked per peer in .sag - :: - :: ~: no subscription - :: %want: /contact/* requested - :: - :: for a given peer, we always have at most one subscription, - :: to /contact/* - :: - ++ sub - |^ |= who=ship - ^+ s-impl - ?< =(our.bowl who) - =/ old (~(get by peers) who) - ~(. s-impl who %live ?=(~ old) (fall old *foreign)) - :: - ++ s-many - |= [l=(list ship) f=$-(_s-impl _s-impl)] - ^+ cor - %+ roll l - |= [who=@p acc=_cor] - ?: =(our.bowl who) acc - si-abet:(f (sub:acc who)) - :: - ++ s-impl - |_ [who=ship sas=?(%dead %live) new=? foreign] - :: - ++ si-cor . - :: - ++ si-abet - ^+ cor - ?- sas - %live =. peers (~(put by peers) who [for sag]) - ?. new cor - :: NB: this assumes con.for is only set in +si-hear - :: - =. cor (p-news-0:pub who ~) - (p-response:pub [%peer who ~]) - :: - %dead ?: new cor - =. peers (~(del by peers) who) - :: - :: this is not quite right, reflecting *total* deletion - :: as *contact* deletion. but it's close, and keeps /news simpler - :: - =. cor (p-news-0:pub who ~) - (p-response:pub [%peer who ~]) - == - :: - ++ si-take - |= [=wire =sign:agent:gall] - ^+ si-cor - ?- -.sign - %poke-ack ~|(strange-poke-ack+wire !!) - :: - %watch-ack ~| strange-watch-ack+wire - ?> ?=(%want sag) - ?~ p.sign si-cor - %- (slog 'contact-fail' u.p.sign) - =/ wake=@da (add now.bowl ~m30) - =. retry (~(put by retry) who wake) - %_ si-cor cor - (pass /retry/(scot %p who) %arvo %b %wait wake) - == - :: - %kick si-meet(sag ~) - :: - %fact ?+ p.cage.sign ~|(strange-fact+wire !!) - %contact-update-1 - (si-hear !<(update q.cage.sign)) - == == - :: - ++ si-hear - |= u=update - ^+ si-cor - ?. (sane-contact con.u) - si-cor - ?: &(?=(^ for) (lte wen.u wen.for)) - si-cor - %_ si-cor - for +.u - cor =. cor - (p-news-0:pub who (contact:to-0 con.u)) - =/ page=(unit page) (~(get by book) who) - :: update contact book and send notification - :: - =? cor ?=(^ page) - ?: =(con.u.page con.u) cor - =. book (~(put by book) who u.page(con con.u)) - =? cor ?=(^ for) (emil (send-activity u con.u.page)) - (p-response:pub %page who con.u mod.u.page) - (p-response:pub %peer who con.u) - == - :: - ++ send-activity - |= [u=update con=contact] - ^- (list card) - ?. .^(? %gu /(scot %p our.bowl)/activity/(scot %da now.bowl)/$) - ~ - %- ~(rep by con.u) - |= [field=(pair @tas value) cards=(list card)] - ?> ?=(^ q.field) - :: do not broadcast empty changes - :: - ?: (is-value-empty q.field) - cards - :: - =/ val=(unit value) (~(get by con) p.field) - ?~ val - [(pass-activity who field) cards] - ?< ?=(~ u.val) - ::NOTE currently shouldn't happen in practice - ?. =(-.q.field -.u.val) cards - ?: =(p.q.field p.u.val) cards - ?. ?=(%set -.q.field) - [(pass-activity who field) cards] - =/ diff=(set value) - (~(dif in p.q.field) ?>(?=(%set -.u.val) p.u.val)) - ?~ diff cards - [(pass-activity who p.field set+diff) cards] - :: - ++ si-meet - ^+ si-cor - :: - :: already subscribed - ?: ?=(%want sag) - si-cor - =/ pat [%v1 %contact ?~(for / /at/(scot %da wen.for))] - %_ si-cor - cor (pass /contact %agent [who dap.bowl] %watch pat) - sag %want - == - :: - ++ si-retry - ^+ si-cor - :: - ::XX this works around a gall/behn bug: - :: the timer is identified by the duct. - :: it needn't be the same when gall passes our - :: card to behn. - :: - ?. (~(has by retry) who) - si-cor - =. retry (~(del by retry) who) - si-meet(sag ~) - :: - ++ si-drop si-snub(sas %dead) - :: - ++ si-snub - %_ si-cor - sag ~ - cor ?. ?=(%want sag) cor - :: retry is scheduled, cancel the timer - :: - ?^ when=(~(get by retry) who) - =. retry (~(del by retry) who) - (pass /retry/(scot %p who)/cancel %arvo %b %rest u.when) - (pass /contact %agent [who dap.bowl] %leave ~) - == - -- - -- - :: - :: +migrate: from :contact-store - :: - :: all known ships, non-default profiles, no subscriptions - :: - ++ migrate - => |% - ++ legacy - |% - +$ rolodex (map ship contact) - +$ resource [=entity name=term] - +$ entity ship - +$ contact - $: nickname=@t - bio=@t - status=@t - color=@ux - avatar=(unit @t) - cover=(unit @t) - groups=(set resource) - last-updated=@da - == - -- - -- - :: - ^+ cor - =/ bas /(scot %p our.bowl)/contact-store/(scot %da now.bowl) - ?. .^(? gu+(weld bas /$)) cor - =/ ful .^(rolodex:legacy gx+(weld bas /all/noun)) - :: - |^ - cor(rof us, peers them) - ++ us - %+ fall - (bind (~(get by ful) our.bowl) convert) - *profile - :: - ++ them - ^- ^peers - %- ~(rep by (~(del by ful) our.bowl)) - |= [[who=ship con=contact:legacy] =^peers] - (~(put by peers) who (convert con) ~) - :: - ++ convert - |= con=contact:legacy - ^- profile - %- profile:from-0 - [last-updated.con con(|6 groups.con)] - -- - :: - +| %implementation - :: - ++ init - =. wen.rof now.bowl - (emit %pass /migrate %agent [our dap]:bowl %poke noun+!>(%migrate)) - :: - ++ load - |= old-vase=vase - ^+ cor - |^ =+ !<([old=versioned-state cool=epic] old-vase) - =? cor !=(okay cool) l-epic - ?- -.old - :: - %2 - =. state old - inflate-io - :: - %1 - =. state old(- %2) - :: fix incorrectly bunted timestamp for - :: an empty profile migrated from %0 - :: - =? cor &(=(*@da wen.rof) ?=(~ con.rof)) - (p-commit-self:pub ~) - inflate-io - :: - %0 - =. rof ?~(rof.old *profile (profile:from-0 rof.old)) - :: migrate peers. for each peer - :: 1. leave /epic, if any - :: 2. subscribe if desired - :: 3. put into peers - :: - =^ caz=(list card) peers - %+ roll ~(tap by rol.old) - |= [[who=ship foreign-0:c0] caz=(list card) =_peers] - :: leave /epic if any - :: - =? caz (~(has by wex.bowl) [/epic who dap.bowl]) - :_ caz - [%pass /epic %agent [who dap.bowl] %leave ~] - =/ fir=$@(~ profile) - ?~ for ~ - (profile:from-0 for) - :: no intent to connect - :: - ?: =(~ sag) - :- caz - (~(put by peers) who fir ~) - :_ (~(put by peers) who fir %want) - ?: (~(has by wex.bowl) [/contact who dap.bowl]) - caz - =/ =path [%v1 %contact ?~(fir / /at/(scot %da wen.fir))] - :_ caz - [%pass /contact %agent [who dap.bowl] %watch path] - (emil caz) - == - +$ state-0 [%0 rof=$@(~ profile-0:c0) rol=rolodex:c0] - +$ state-1 $: %1 - rof=profile - =^book - =^peers - retry=(map ship @da) :: retry sub at time - == - +$ versioned-state - $% state-2 - state-1 - state-0 - == - :: - ++ l-epic (give %fact [/epic ~] epic+!>(okay)) - :: - ++ inflate-io - ^+ cor - =/ cards - %+ roll ~(tap by peers) - |= [[who=ship foreign] caz=(list card)] - :: intent to connect, resubscribe - :: - ?: ?& =(%want sag) - !(~(has by wex.bowl) [/contact who dap.bowl]) - == - =/ =path [%v1 %contact ?~(for / /at/(scot %da wen.for))] - :_ caz - [%pass /contact %agent [who dap.bowl] %watch path] - caz - (emil cards) - -- - :: - ++ poke - |= [=mark =vase] - ^+ cor - ?+ mark ~|(bad-mark+mark !!) - %noun - ?+ q.vase !! - %migrate migrate - == - $? %contact-action - %contact-action-0 - %contact-action-1 - == - ?> =(our src):bowl - =/ act=action - ?- mark - :: - %contact-action-1 - !<(action vase) - :: upconvert legacy %contact-action - :: - ?(%contact-action %contact-action-0) - =/ act-0 !<(action-0:c0 vase) - ?. ?=(%edit -.act-0) - (to-action act-0) - :: v0 %edit needs special handling to evaluate - :: groups edit - :: - =/ groups=(set $>(%flag value)) - ?~ con.rof ~ - =+ set=(~(ges cy con.rof) groups+%flag) - (fall set ~) - [%self (to-self-edit p.act-0 groups)] - == - ?- -.act - %anon p-anon:pub - %self (p-self:pub p.act) - :: if we add a page for someone who is not a peer, - :: we meet them first - :: - %page =? cor &(?=(ship p.act) !(~(has by peers) p.act)) - si-abet:si-meet:(sub p.act) - (p-page:pub p.act q.act) - %edit (p-edit:pub p.act q.act) - %wipe (p-wipe:pub p.act) - %meet (s-many:sub p.act |=(s=_s-impl:sub si-meet:s)) - %drop (s-many:sub p.act |=(s=_s-impl:sub si-drop:s)) - %snub (s-many:sub p.act |=(s=_s-impl:sub si-snub:s)) - == - == - :: +peek: scry - :: - :: v0 scries - :: - :: /x/all -> $rolodex:c0 - :: /x/contact/her=@ -> $@(~ contact-0:c0) - :: - :: v1 scries - :: - :: /x/v1/self -> $contact - :: /x/v1/book -> $book - :: /x/v1/book/her=@p -> $page - :: /x/v1/book/id/cid=@uv -> $page - :: /x/v1/all -> $directory - :: /x/v1/contact/her=@p -> $contact - :: /x/v1/peer/her=@p -> $contact - :: - ++ peek - |= pat=(pole knot) - ^- (unit (unit cage)) - ?+ pat [~ ~] - :: - [%x %all ~] - =/ rol-0=rolodex:c0 - %- ~(urn by peers) - |= [who=ship far=foreign] - ^- foreign-0:c0 - =/ mod=contact - ?~ page=(~(get by book) who) - ~ - mod.u.page - (foreign:to-0 (foreign-mod far mod)) - =/ lor-0=rolodex:c0 - ?: ?=(~ con.rof) rol-0 - (~(put by rol-0) our.bowl (profile:to-0 rof) ~) - ``contact-rolodex+!>(lor-0) - :: - [%x %contact her=@ ~] - ?~ who=(slaw %p her.pat) - [~ ~] - =/ tac=?(~ contact-0:c0) - ?: =(our.bowl u.who) - ?~(con.rof ~ (contact:to-0 con.rof)) - =+ far=(~(get by peers) u.who) - ?: |(?=(~ far) ?=(~ for.u.far)) ~ - (contact:to-0 con.for.u.far) - ?~ tac [~ ~] - ``contact+!>(`contact-0:c0`tac) - :: - [%x %v1 %self ~] - ``contact-1+!>(`contact`con.rof) - :: - [%x %v1 %book ~] - ``contact-book-0+!>(book) - :: - [%u %v1 %book her=@p ~] - ?~ who=(slaw %p her.pat) - [~ ~] - ``loob+!>((~(has by book) u.who)) - :: - [%x %v1 %book her=@p ~] - ?~ who=(slaw %p her.pat) - [~ ~] - =/ page=(unit page) - (~(get by book) u.who) - ``contact-page-0+!>(`^page`(fall page *^page)) - :: - [%u %v1 %book %id =cid ~] - ?~ id=(slaw %uv cid.pat) - [~ ~] - ``loob+!>((~(has by book) id+u.id)) - :: - [%x %v1 %book %id =cid ~] - ?~ id=(slaw %uv cid.pat) - [~ ~] - =/ page=(unit page) - (~(get by book) id+u.id) - ``contact-page-0+!>(`^page`(fall page *^page)) - :: - [%x %v1 %all ~] - =| dir=directory - :: export all ship contacts - :: - =. dir - %- ~(rep by book) - |= [[=kip =page] =_dir] - ?^ kip - dir - (~(put by dir) kip (contact-uni page)) - :: export all peers - :: - =. dir - %- ~(rep by peers) - |= [[who=ship far=foreign] =_dir] - ?~ for.far dir - ?: (~(has by dir) who) dir - (~(put by dir) who con.for.far) - ``contact-directory-0+!>(dir) - :: - [%u %v1 %contact her=@p ~] - ?~ who=(slaw %p her.pat) - [~ ~] - ?: (~(has by book) u.who) - ``loob+!>(&) - =- ``loob+!>(-) - ?~ far=(~(get by peers) u.who) - | - ?~ for.u.far - | - & - :: - [%x %v1 %contact her=@p ~] - ?~ who=(slaw %p her.pat) - [~ ~] - ?^ page=(~(get by book) u.who) - ``contact-1+!>((contact-uni u.page)) - ?~ far=(~(get by peers) u.who) - [~ ~] - ?~ for.u.far - [~ ~] - ``contact-1+!>(con.for.u.far) - :: - [%u %v1 %peer her=@p ~] - ?~ who=(slaw %p her.pat) - [~ ~] - ``loob+!>((~(has by peers) u.who)) - :: - [%x %v1 %peer her=@p ~] - ?~ who=(slaw %p her.pat) - [~ ~] - ?~ far=(~(get by peers) u.who) - [~ ~] - ``contact-foreign-0+!>(`foreign`u.far) - == - :: - ++ peer - |= pat=(pole knot) - ^+ cor - ?+ pat ~|(bad-watch-path+pat !!) - :: - :: v0 - [%news ~] ~|(local-news+src.bowl ?>(=(our src):bowl cor)) - :: - :: v1 - [%v1 %contact ~] (p-init:pub ~) - [%v1 %contact %at wen=@ ~] (p-init:pub `(slav %da wen.pat)) - [%v1 %news ~] ~|(local-news+src.bowl ?>(=(our src):bowl cor)) - :: - [%epic ~] (give %fact ~ epic+!>(okay)) - == - :: - ++ agent - |= [=wire =sign:agent:gall] - ^+ cor - ?+ wire ~|(evil-agent+wire !!) - [%contact ~] - si-abet:(si-take:(sub src.bowl) wire sign) - :: - [%migrate ~] - ?> ?=(%poke-ack -.sign) - ?~ p.sign cor - %- (slog leaf/"{} failed" u.p.sign) - cor - :: - [%activity ~] - cor - :: - [%epic ~] - cor - == - :: - ++ arvo - |= [=wire sign=sign-arvo] - ^+ cor - ?+ wire ~|(evil-vane+wire !!) - :: - [%retry her=@p ~] - :: XX technically, the timer could fail. - :: it should be ok to still retry. - :: - ?> ?=([%behn %wake *] sign) - =+ who=(slav %p i.t.wire) - si-abet:si-retry:(sub who) - == - -- --- diff --git a/desk/app/docket.hoon b/desk/app/docket.hoon index 01d2ebab..25550f40 100644 --- a/desk/app/docket.hoon +++ b/desk/app/docket.hoon @@ -179,7 +179,7 @@ =/ =charge ~|(no-charge-installed+desk (~(got by charges) desk)) =. charges (~(del by charges) desk) =? by-base ?=(%glob -.href.docket.charge) - (~(del by by-base) base.href.docket) + (~(del by by-base) base.href.docket.charge) =* cha ~(. ch desk) :_ state ~[del-fact:cha uninstall:cha] diff --git a/desk/desk.docket-0 b/desk/desk.docket-0 index 99e6472d..4fa5dacc 100644 --- a/desk/desk.docket-0 +++ b/desk/desk.docket-0 @@ -4,7 +4,7 @@ glob-http+['https://bootstrap.urbit.org/glob-0v7.1sski.vab96.diccf.7nqai.1nntd.glob' 0v7.1sski.vab96.diccf.7nqai.1nntd] ::glob-ames+~zod^0v0 base+'landscape' - version+[1 31 1] + version+[1 32 0] website+'https://tlon.io' license+'MIT' == diff --git a/desk/mar/vitals/qos.hoon b/desk/mar/vitals/qos.hoon index a9c069b0..ffcb1756 100644 --- a/desk/mar/vitals/qos.hoon +++ b/desk/mar/vitals/qos.hoon @@ -3,7 +3,7 @@ |_ =qos:ames ++ grab |% - ++ noun qos + ++ noun qos:ames -- ++ grow |% diff --git a/desk/mar/vitals/result.hoon b/desk/mar/vitals/result.hoon index f1e7eb8b..d7eb861a 100644 --- a/desk/mar/vitals/result.hoon +++ b/desk/mar/vitals/result.hoon @@ -3,7 +3,7 @@ |_ =result ++ grab |% - ++ noun result + ++ noun ^result -- ++ grow |% diff --git a/desk/sys.kelvin b/desk/sys.kelvin index 1ec239e0..30d23d4a 100644 --- a/desk/sys.kelvin +++ b/desk/sys.kelvin @@ -1 +1,3 @@ [%zuse 410] +[%zuse 409] +[%zuse 408] diff --git a/desk/tests/app/bait.hoon b/desk/tests/app/bait.hoon deleted file mode 100644 index e1bc3c3a..00000000 --- a/desk/tests/app/bait.hoon +++ /dev/null @@ -1,165 +0,0 @@ -/- r=reel, spider -/+ *test-agent, reel, strandio, server -/= bait-agent /app/bait -|% -++ dap %bait-test -++ vic 'https://tlon.network/lure/' -++ civ ~loshut-lonreg -++ eny - `@uv`0xffff.ffff.ffff.ffff.ffff.ffff.ffff.ffff -++ nonce `@ta`'~2000.1.1' -++ token `@t`(scot %uv (end [3 16] eny)) -+$ bait-state - $: %2 - metadata=(map token:r metadata:r) - == -++ test-bait-describe - %- eval-mare - =/ m (mare ,~) - ;< * bind:m (do-init dap bait-agent) - ;< * bind:m (jab-bowl |=(b=bowl b(our civ, src ~dev, eny eny))) - =/ =metadata:r [%test (my ['inviter' '~dev'] ['bite-type' '2'] ~)] - =/ describe [nonce metadata] - ;< caz=(list card) bind:m (do-poke %bait-describe !>(describe)) - ;< * bind:m - %+ ex-cards caz - ~[(ex-poke /confirm/[nonce] [~dev %reel] reel-confirmation+!>([nonce token]))] - ;< state=vase bind:m get-save - =+ !<(bait-state state) - (ex-equal !>(metadata) !>((my [token ^metadata] ~))) -++ test-bait-who-get - %- eval-mare - =/ m (mare ,~) - ;< * bind:m (do-init dap bait-agent) - ;< * bind:m (jab-bowl |=(b=bowl b(our ~dev))) - =/ simple-payload - (json-response:gen:server s+(scot %p ~dev)) - :: request 1: test old style tokens - =/ eyre-id %eyre-request-1 - =/ request=[id=@ta inbound-request:eyre] - [eyre-id (eyre-get-request '/lure/bait/who')] - ;< caz=(list card) bind:m (do-poke %handle-http-request !>(request)) - %+ ex-cards caz - (eyre-request-cards eyre-id simple-payload) -++ test-bait-metadata-get - %- eval-mare - =/ m (mare ,~) - ;< * bind:m (do-init dap bait-agent) - ;< * bind:m (jab-bowl |=(b=bowl b(our civ, src civ, eny eny))) - =/ =metadata:r [%test (my ['title' 'test-group'] ~)] - =/ init-state=bait-state - :- %2 - (my ['~zod/test' metadata] [token metadata] ~) - ;< * bind:m (do-load bait-agent `!>(init-state)) - =/ simple-payload - (json-response:gen:server (enjs-metadata:reel metadata)) - :: request 1: test old style tokens - =/ eyre-id %eyre-request-1 - =/ request=[id=@ta inbound-request:eyre] - [eyre-id (eyre-get-request '/lure/~zod/test/metadata')] - ;< caz=(list card) bind:m (do-poke %handle-http-request !>(request)) - ;< * bind:m - %+ ex-cards caz - (eyre-request-cards eyre-id simple-payload) - :: request 2: test new style tokens - =/ eyre-id %eyre-request-2 - =/ request=[id=@ta inbound-request:eyre] - [eyre-id (eyre-get-request (crip "/lure/{(trip token)}/metadata"))] - ;< caz=(list card) bind:m (do-poke %handle-http-request !>(request)) - %+ ex-cards caz - (eyre-request-cards eyre-id simple-payload) -:: -++ test-bait-bite-post - %- eval-mare - =/ m (mare ,~) - ;< * bind:m (do-init dap bait-agent) - ;< * bind:m (jab-bowl |=(b=bowl b(our civ, src civ, eny eny))) - =/ m1=metadata:r [%test (my ['title' 'test-group'] ~)] - =/ m2=metadata:r - :- %test - %- my - :~ ['title' 'test-group'] - ['bite-type' '2'] - ['inviter' '~dev'] - == - =/ init-state=bait-state - :- %2 - (my ['~zod/test' m1] [token m2] ~) - ;< * bind:m (do-load bait-agent `!>(init-state)) - =/ payload (as-octs:mimes:html 'ship=%7Erus') - =/ simple-payload - (manx-response:gen:server (sent-page ~rus)) - :: request 1: test new style tokens - =/ eyre-id %eyre-request-1 - =/ request=[id=@ta inbound-request:eyre] - [eyre-id (eyre-post-request (cat 3 '/lure/' token) payload)] - ;< caz=(list card) bind:m (do-poke %handle-http-request !>(request)) - ;< * bind:m - %+ ex-cards caz - =/ =cage reel-bite+!>([%bite-2 token ~rus m2]) - %+ welp - :~ (ex-poke /bite [~dev %reel] cage) - (ex-poke /bite [civ %reel] cage) - == - (eyre-request-cards eyre-id simple-payload) - :: request 2: test old style tokens - =/ eyre-id %eyre-request-2 - =/ request=[id=@ta inbound-request:eyre] - [eyre-id (eyre-post-request '/lure/~zod/test' payload)] - ;< caz=(list card) bind:m (do-poke %handle-http-request !>(request)) - %+ ex-cards caz - =/ =cage reel-bite+!>([%bite-1 `@ta`'test' ~rus ~zod]) - %+ welp - :~ (ex-poke /bite [~zod %reel] cage) - (ex-poke /bite [civ %reel] cage) - == - (eyre-request-cards eyre-id simple-payload) -++ eyre-get-request - |= url=@t - :* | - & - *address:eyre - :* %'GET' - url - ~ - ~ - == - == -:: -++ eyre-post-request - |= [url=@t payload=octs] - :* | - & - *address:eyre - :* %'POST' - url - ~ - `payload - == - == -++ eyre-request-cards - |= [id=@ta =simple-payload:http] - ^- (list $-(card tang)) - =/ paths ~[/http-response/[id]] - =/ header-cage - [%http-response-header !>(response-header.simple-payload)] - =/ data-cage - [%http-response-data !>(data.simple-payload)] - %- limo - :~ (ex-fact paths header-cage) - (ex-fact paths data-cage) - (ex-card [%give %kick paths ~]) - == -++ sent-page - |= invitee=ship - ^- manx - ;html - ;head - ;title:"Lure" - == - ;body - Your invite has been sent! Go to your ship to accept it. - ;script: document.cookie="ship={(trip (scot %p invitee))}" - == - == --- \ No newline at end of file diff --git a/desk/tests/app/contacts.hoon b/desk/tests/app/contacts.hoon deleted file mode 100644 index a4354215..00000000 --- a/desk/tests/app/contacts.hoon +++ /dev/null @@ -1,1093 +0,0 @@ -/- *contacts, c0=contacts-0 -/+ *test-agent -/+ c=contacts -/= contacts-agent /app/contacts -=* agent contacts-agent -:: XX consider simplifying tests -:: with functional 'micro' strands, that set -:: a contact, subscribe to a peer etc. -:: -|% -:: -+| %help -:: -++ tick ^~((rsh 3^2 ~s1)) -++ mono - |= [old=@da new=@da] - ^- @da - ?: (lth old new) new - (add old tick) -:: +filter: filter unwanted cards -:: -:: ++ filter -:: |= caz=(list card) -:: ^+ caz -:: %+ skip caz -:: |= =card -:: ?. ?=(%pass -.card) | -:: ?+ p.card | -:: [%~.~ %negotiate *] & -:: == -:: ++ ex-cards -:: |= [caz=(list card) exes=(list $-(card tang))] -:: %+ ^ex-cards -:: (filter caz) -:: exes -:: -+| %poke-0 -:: -:: +test-poke-0-anon: v0 delete the profile -:: -++ test-poke-0-anon - %- eval-mare - =/ m (mare ,~) - =* b bind:m - ^- form:m - ;< caz=(list card) b (do-init %contacts contacts-agent) - ;< =bowl b get-bowl - :: - =| con-0=contact-0:c0 - =. nickname.con-0 'Zod' - =. bio.con-0 'The first of the galaxies' - :: - =/ con-1=contact - %- malt - ^- (list (pair @tas value)) - ~[nickname+text/'Zod' bio+text/'The first of the galaxies'] - =/ edit-0=(list field-0:c0) - ^- (list field-0:c0) - :~ nickname+'Zod' - bio+'The first of the galaxies' - == - :: foreign subscriber to /v1/contact - :: - ;< ~ b (set-src ~sun) - ;< caz=(list card) b (do-watch /v1/contact) - :: local subscriber to /news - :: - ;< ~ b (set-src our.bowl) - ;< caz=(list card) b (do-watch /news) - :: - ;< ~ b (set-src our.bowl) - :: action-0:c0 profile %edit - :: - ;< caz=(list card) b (do-poke contact-action+!>([%edit edit-0])) - :: - =/ upd-0=update-0:c0 - [%full (add now.bowl (mul 2 tick)) ~] - =/ upd-1=update - [%full (add now.bowl (mul 2 tick)) ~] - ;< caz=(list card) b (do-poke contact-action+!>([%anon ~])) - %+ ex-cards caz - :~ (ex-fact ~[/news] contact-news+!>([our.bowl ~])) - (ex-fact ~[/v1/news] contact-response-0+!>([%self ~])) - (ex-fact ~[/v1/contact] contact-update-1+!>(upd-1)) - == -:: +test-poke-0-edit: v0 edit the profile -:: -++ test-poke-0-edit - %- eval-mare - =/ m (mare ,~) - =* b bind:m - ^- form:m - ;< caz=(list card) b (do-init %contacts contacts-agent) - ;< =bowl b get-bowl - :: - =| con-0=contact-0:c0 - =. nickname.con-0 'Zod' - =. bio.con-0 'The first of the galaxies' - =. groups.con-0 (silt ~sampel-palnet^%oranges ~) - :: - =/ con=contact - %- malt - ^- (list (pair @tas value)) - :~ nickname+text/'Zod' - bio+text/'The first of the galaxies' - groups+set/(silt flag/~sampel-palnet^%oranges ~) - == - :: - =/ edit-0=(list field-0:c0) - ^- (list field-0:c0) - :~ nickname+'Zod' - bio+'The first of the galaxies' - add-group+~sampel-palnet^%apples - add-group+~sampel-palnet^%oranges - del-group+~sampel-palnet^%apples - == - :: foreign subscriber to /v1/contact - :: - ;< ~ b (set-src ~sun) - ;< caz=(list card) b (do-watch /v1/contact) - :: local subscriber to /news - :: - ;< ~ b (set-src our.bowl) - ;< caz=(list card) b (do-watch /news) - :: local subscriber to /v1/news - :: - ;< ~ b (set-src our.bowl) - ;< caz=(list card) b (do-watch /v1/news) - :: - ;< ~ b (set-src our.bowl) - :: action-0:c0 profile %edit - :: - ;< caz=(list card) b (do-poke %contact-action !>([%edit edit-0])) - ;< ~ b - %+ ex-cards caz - :~ (ex-fact ~[/news] contact-news+!>([our.bowl con-0])) - (ex-fact ~[/v1/news] contact-response-0+!>([%self con])) - (ex-fact ~[/v1/contact] contact-update-1+!>([%full `@da`(add now.bowl tick) con])) - == - :: profile is set - :: - ;< peek=(unit (unit cage)) b - (get-peek /x/v1/self) - =/ cag (need (need peek)) - ;< ~ b - %+ ex-equal - !> cag - !> contact-1+!>(con) - :: change groups - :: - ;< caz=(list card) b - (do-poke %contact-action !>([%edit del-group+~sampel-palnet^%oranges ~])) - =/ new-con - (~(put by con) groups+set/~) - ;< ~ b - %+ ex-cards caz - :~ (ex-fact ~[/news] contact-news+!>([our.bowl con-0(groups ~)])) - (ex-fact ~[/v1/news] contact-response-0+!>([%self new-con])) - (ex-fact ~[/v1/contact] contact-update-1+!>([%full (add now.bowl (mul 2 tick)) new-con])) - == - :: remove bio - :: - ;< caz=(list card) b - (do-poke %contact-action-1 !>([%self `contact`[%bio^~ ~ ~]])) - :: add oranges back - :: - ;< caz=(list card) b - (do-poke %contact-action !>([%edit add-group+~sampel-palnet^%oranges ~])) - :: profile is missing bio - :: - ;< peek=(unit (unit cage)) b - (get-peek /x/v1/self) - =/ cag (need (need peek)) - %+ ex-equal - !> cag - !> contact-1+!>(`contact`(~(del by con) %bio)) -:: +test-poke-meet-0: v0 meet a peer -:: -++ test-poke-0-meet - %- eval-mare - =/ m (mare ,~) - =* b bind:m - ^- form:m - ;< caz=(list card) b (do-init %contacts contacts-agent) - ;< =bowl b get-bowl - :: v0 %meet is no-op - :: - ;< caz=(list card) b (do-poke %contact-action !>([%meet ~[~sun]])) - (ex-cards caz ~) -:: +test-poke-heed-0: v0 heed a peer -:: -++ test-poke-0-heed - %- eval-mare - =/ m (mare ,~) - =* b bind:m - ^- form:m - ;< caz=(list card) b (do-init %contacts contacts-agent) - ;< =bowl b get-bowl - :: v0 %heed is the new %meet - :: - ;< caz=(list card) b (do-poke %contact-action !>([%heed ~[~sun]])) - %+ ex-cards caz - :~ (ex-task /contact [~sun %contacts] %watch /v1/contact) - (ex-fact ~[/news] contact-news+!>([~sun ~])) - (ex-fact ~[/v1/news] contact-response-0+!>([%peer ~sun ~])) - == -+| %poke -:: +test-poke-anon: delete the profile -:: -++ test-poke-anon - %- eval-mare - =/ m (mare ,~) - =* b bind:m - ^- form:m - ;< caz=(list card) b (do-init %contacts contacts-agent) - ;< =bowl b get-bowl - :: - =/ con-1=contact - %- malt - ^- (list (pair @tas value)) - ~[nickname+text/'Zod' bio+text/'The first of the galaxies'] - :: - =/ edit-1 con-1 - :: foreign subscriber to /contact - :: - ;< ~ b (set-src ~sun) - ;< caz=(list card) b (do-watch /v1/contact) - :: local subscriber to /news - :: - ;< ~ b (set-src our.bowl) - ;< caz=(list card) b (do-watch /v1/news) - :: - ;< ~ b (set-src our.bowl) - :: edit the profile - :: - ;< caz=(list card) b (do-poke contact-action-1+!>([%self con-1])) - :: delete the profile - :: - ;< caz=(list card) b (do-poke contact-action-1+!>([%anon ~])) - :: contact update is published on /v1/contact - :: news is published on /news, /v1/news - :: - ;< ~ b %+ ex-cards caz - :~ (ex-fact ~[/news] contact-news+!>([our.bowl ~])) - (ex-fact ~[/v1/news] contact-response-0+!>([%self ~])) - (ex-fact ~[/v1/contact] contact-update-1+!>([%full (add now.bowl (mul 2 tick)) ~])) - == - :: v0: profile is empty - :: - ;< peek=(unit (unit cage)) b - (get-peek /x/contact/(scot %p our.bowl)) - ;< ~ b - %+ ex-equal - !>((need peek)) - !>(~) - :: profile is empty - :: - ;< peek=(unit (unit cage)) b - (get-peek /x/v1/self) - =/ cag (need (need peek)) - %+ ex-equal - !>(cag) - !>(contact-1+!>(`contact`~)) -:: +test-poke-self: change the profile -:: -++ test-poke-self - %- eval-mare - =/ m (mare ,~) - =* b bind:m - ^- form:m - ;< caz=(list card) b (do-init %contacts contacts-agent) - ;< =bowl b get-bowl - :: - =| con-0=contact-0:c0 - =. nickname.con-0 'Zod' - =. bio.con-0 'The first of the galaxies' - :: - =/ con-1=contact - %- malt - ^- (list (pair @tas value)) - ~[nickname+text/'Zod' bio+text/'The first of the galaxies'] - :: - =/ upd-0=update-0:c0 - [%full (add now.bowl tick) con-0] - =/ upd-1=update - [%full (add now.bowl tick) con-1] - =/ edit-1 con-1 - :: foreign subscriber to /contact - :: - ;< ~ b (set-src ~sun) - ;< caz=(list card) b (do-watch /v1/contact) - :: local subscriber to /news - :: - ;< ~ b (set-src our.bowl) - ;< caz=(list card) b (do-watch /v1/news) - :: - ;< ~ b (set-src our.bowl) - :: - ;< caz=(list card) b (do-poke contact-action-1+!>([%self con-1])) - %+ ex-cards caz - :~ (ex-fact ~[/news] contact-news+!>([our.bowl con-0])) - (ex-fact ~[/v1/news] contact-response-0+!>([%self con-1])) - (ex-fact ~[/v1/contact] contact-update-1+!>(upd-1)) - == -:: +test-poke-page: create new contact page -:: -++ test-poke-page - %- eval-mare - =/ m (mare ,~) - =* b bind:m - ^- form:m - ;< caz=(list card) b (do-init %contacts contacts-agent) - ;< =bowl b get-bowl - :: - =/ con-1=contact - %- malt - ^- (list (pair @tas value)) - ~[nickname+text/'Sun' bio+text/'It is bright today'] - :: - =/ resp=response - [%page id+0v1 ~ con-1] - =/ mypage=^page - [p=~ q=con-1] - :: local subscriber to /news - :: - ;< ~ b (set-src our.bowl) - ;< caz=(list card) b (do-watch /v1/news) - :: - ;< ~ b (set-src our.bowl) - :: create new contact page - :: - ;< caz=(list card) b (do-poke contact-action-1+!>([%page id+0v1 con-1])) - :: news is published on /v1/news - :: - ;< ~ b %+ ex-cards caz - :~ (ex-fact ~[/v1/news] contact-response-0+!>(resp)) - == - :: peek page in the book: new contact page is found - :: - ;< peek=(unit (unit cage)) b (get-peek /x/v1/book/id/0v1) - =/ =cage (need (need peek)) - ;< ~ b - %+ ex-equal - !> [%contact-page-0 q.cage] - !> [%contact-page-0 !>(mypage)] - :: fail to create duplicate page - :: - %- ex-fail (do-poke contact-action-1+!>([%page id+0v1 con-1])) -:: +test-poke-edit: edit the contact book -:: -++ test-poke-edit - %- eval-mare - =/ m (mare ,~) - =* b bind:m - ^- form:m - ;< caz=(list card) b (do-init %contacts contacts-agent) - ;< =bowl b get-bowl - =/ groups - ^- (list value) - :~ flag/~sampel-palnet^%apples - flag/~sampel-palnet^%oranges - == - =/ con-1=contact - %- malt - ^- (list (pair @tas value)) - :~ nickname+text/'Sun' - bio+text/'It is bright today' - groups+set/(silt groups) - == - :: - =/ resp=response - [%page id+0v1 ~ con-1] - =/ mypage=^page - [p=~ q=con-1] - =/ edit-1 con-1 - :: local subscriber to /news - :: - ;< ~ b (set-src our.bowl) - ;< caz=(list card) b (do-watch /v1/news) - :: - ;< ~ b (set-src our.bowl) - :: create new contact page - :: - ;< caz=(list card) b (do-poke contact-action-1+!>([%page id+0v1 con-1])) - :: news is published on /v1/news - :: - ;< ~ b %+ ex-cards caz - :~ (ex-fact ~[/v1/news] contact-response-0+!>(resp)) - == - :: peek page in the book: new contact page is found - :: - ;< peek=(unit (unit cage)) b (get-peek /x/v1/book/id/0v1) - =/ =cage (need (need peek)) - %+ ex-equal - !> [%contact-page-0 q.cage] - !> [%contact-page-0 !>(mypage)] - :: delete favourite groups - :: -:: -++ test-poke-meet - %- eval-mare - =/ m (mare ,~) - =* b bind:m - ^- form:m - ;< caz=(list card) b (do-init %contacts contacts-agent) - ;< =bowl b get-bowl - :: - =/ con-sun=contact - %- malt - ^- (list (pair @tas value)) - ~[nickname+text/'Sun' bio+text/'It is bright today'] - :: local subscriber to /news - :: - ;< ~ b (set-src our.bowl) - ;< caz=(list card) b (do-watch /news) - :: meet ~sun - :: - ;< caz=(list card) b (do-poke contact-action-1+!>([%meet ~[~sun]])) - :: ~sun publishes his contact - :: - ;< ~ b (set-src ~sun) - ;< caz=(list card) b - (do-agent /contact [~sun %contacts] %fact contact-update-1+!>([%full now.bowl con-sun])) - ;< ~ b - %+ ex-cards caz - :~ (ex-fact ~[/news] contact-news+!>([~sun (contact:to-0:c con-sun)])) - (ex-fact ~[/v1/news] contact-response-0+!>([%peer ~sun con-sun])) - == - :: ~sun appears in peers - :: - ;< peek=(unit (unit cage)) b (get-peek /x/v1/peer/~sun) - =/ cag=cage (need (need peek)) - ;< ~ b - %+ ex-equal - !> cag - !> contact-foreign-0+!>(`foreign`[[now.bowl con-sun] %want]) - ;< ~ b (set-src ~sun) - :: meet ~sun a second time: a no-op - :: - ;< ~ b (set-src our.bowl) - ;< caz=(list card) b (do-poke %contact-action !>([%meet ~[~sun]])) - (ex-cards caz ~) -:: -++ test-poke-page-unknown - %- eval-mare - =/ m (mare ,~) - =* b bind:m - ^- form:m - ;< caz=(list card) b (do-init %contacts contacts-agent) - ;< =bowl b get-bowl - :: - =/ con-sun=contact - %- malt - ^- (list (pair @tas value)) - ~[nickname+text/'Sun' bio+text/'It is bright today'] - :: local subscriber to /news - :: - ;< ~ b (set-src our.bowl) - ;< caz=(list card) b (do-watch /news) - :: page ~sun to contact boook: he also becomes our peer - :: - ;< caz=(list card) b (do-poke contact-action-1+!>([%page ~sun ~])) - ;< ~ b - %+ ex-cards caz - :~ (ex-task /contact [~sun %contacts] %watch /v1/contact) - (ex-fact ~[/news] contact-news+!>([~sun ~])) - (ex-fact ~[/v1/news] contact-response-0+!>([%peer ~sun ~])) - (ex-fact ~[/v1/news] contact-response-0+!>([%page ~sun `page:c`[~ ~]])) - == - :: ~sun appears in peers - :: - ;< peek=(unit (unit cage)) b (get-peek /x/v1/peer/~sun) - =/ cag=cage (need (need peek)) - ;< ~ b - %+ ex-equal - !> cag - !> contact-foreign-0+!>(`foreign`[~ %want]) - :: ~sun publishes his contact - :: - ;< ~ b (set-src ~sun) - ;< caz=(list card) b - (do-agent /contact [~sun %contacts] %fact contact-update-1+!>([%full now.bowl con-sun])) - ;< ~ b - %+ ex-cards caz - :~ (ex-fact ~[/news] contact-news+!>([~sun (contact:to-0:c con-sun)])) - (ex-fact ~[/v1/news] contact-response-0+!>([%page ~sun con-sun ~])) - (ex-fact ~[/v1/news] contact-response-0+!>([%peer ~sun con-sun])) - == - :: ~sun contact page is edited - :: - ;< ~ b (set-src our.bowl) - =/ con-mod=contact - %- malt - ^- (list (pair @tas value)) - ~[nickname+text/'Bright Sun' avatar+look/'https://sun.io/sun.png'] - ;< caz=(list card) b (do-poke contact-action-1+!>([%edit ~sun con-mod])) - :: ~sun's contact book page is updated - :: - ;< peek=(unit (unit cage)) b (get-peek /x/v1/book/~sun) - =/ cag=cage (need (need peek)) - ;< ~ b - %+ ex-equal - !> cag - !> [%contact-page-0 !>(`page:c`[con-sun con-mod])] - :: and his effective contact is changed - :: - ;< peek=(unit (unit cage)) b (get-peek /x/v1/contact/~sun) - =/ cag=cage (need (need peek)) - %+ ex-equal - !> cag - !> contact-1+!>((contact-uni:c con-sun con-mod)) -:: -++ test-poke-page-wipe - %- eval-mare - =/ m (mare ,~) - =* b bind:m - ^- form:m - ;< caz=(list card) b (do-init %contacts contacts-agent) - ;< =bowl b get-bowl - :: - =/ con-sun=contact - %- malt - ^- (list (pair @tas value)) - ~[nickname+text/'Sun' bio+text/'It is bright today'] - :: local subscriber to /news - :: - ;< ~ b (set-src our.bowl) - ;< caz=(list card) b (do-watch /news) - :: meet ~sun - :: - ;< caz=(list card) b (do-poke contact-action-1+!>([%meet ~[~sun]])) - :: ~sun publishes his contact - :: - ;< ~ b (set-src ~sun) - ;< caz=(list card) b - (do-agent /contact [~sun %contacts] %fact contact-update-1+!>([%full now.bowl con-sun])) - ;< ~ b - %+ ex-cards caz - :~ (ex-fact ~[/news] contact-news+!>([~sun (contact:to-0:c con-sun)])) - (ex-fact ~[/v1/news] contact-response-0+!>([%peer ~sun con-sun])) - == - :: ~sun appears in peers - :: - ;< peek=(unit (unit cage)) b (get-peek /x/v1/peer/~sun) - =/ cag=cage (need (need peek)) - ;< ~ b - %+ ex-equal - !> cag - !> contact-foreign-0+!>(`foreign`[[now.bowl con-sun] %want]) - ;< ~ b (set-src ~sun) - :: ~sun is added to contacts - :: - ;< ~ b (set-src our.bowl) - ;< caz=(list card) b (do-poke contact-action-1+!>([%page ~sun ~])) - ;< ~ b - %+ ex-cards caz - :~ (ex-fact ~[/v1/news] contact-response-0+!>([%page ~sun con-sun ~])) - == - :: ~sun contact page is edited - :: - =/ con-mod=contact - %- malt - ^- (list (pair @tas value)) - ~[nickname+text/'Bright Sun' avatar+look/'https://sun.io/sun.png'] - ;< caz=(list card) b (do-poke contact-action-1+!>([%edit ~sun con-mod])) - ;< ~ b - %+ ex-cards caz - :~ :: (ex-fact ~[/news] contact-news+!>([~sun (contact:to-0:c (~(uni by con-sun) con-mod))])) - (ex-fact ~[/v1/news] contact-response-0+!>([%page ~sun con-sun con-mod])) - == - :: despite the edit, ~sun peer contact is unchanged - :: - ;< peek=(unit (unit cage)) b (get-peek /x/v1/peer/~sun) - =/ cag=cage (need (need peek)) - ;< ~ b - %+ ex-equal - !> cag - !> contact-foreign-0+!>(`foreign`[[now.bowl con-sun] %want]) - :: however, ~sun's contact book page is changed - :: - ;< peek=(unit (unit cage)) b (get-peek /x/v1/book/~sun) - =/ cag=cage (need (need peek)) - ;< ~ b - %+ ex-equal - !> cag - !> [%contact-page-0 !>(`page:c`[con-sun con-mod])] - :: and his effective contact is changed - :: - ;< peek=(unit (unit cage)) b (get-peek /x/v1/contact/~sun) - =/ cag=cage (need (need peek)) - ;< ~ b - %+ ex-equal - !> cag - !> contact-1+!>((contact-uni:c con-sun con-mod)) - :: ~sun contact page is deleted - :: - ;< caz=(list card) b (do-poke contact-action-1+!>([%wipe ~[~sun]])) - ;< ~ b - %+ ex-cards caz - :~ :: (ex-fact ~[/news] contact-news+!>([~sun (contact:to-0:c con-sun)])) - (ex-fact ~[/v1/news] contact-response-0+!>([%wipe ~sun])) - == - :: ~sun contact page is removed - :: - ;< peek=(unit (unit cage)) b (get-peek /x/v1/book/~sun) - =/ cag (need (need peek)) - ;< ~ b (ex-equal !>(cag) !>(contact-page-0+!>(*page:c))) - :: (ex-equal !>(2) !>(2)) - :: despite the removal, ~sun peer contact is unchanged - :: - ;< peek=(unit (unit cage)) b (get-peek /x/v1/peer/~sun) - =/ cag=cage (need (need peek)) - %+ ex-equal - !> cag - !> contact-foreign-0+!>(`foreign`[[now.bowl con-sun] %want]) -:: -++ test-poke-drop - %- eval-mare - =/ m (mare ,~) - =* b bind:m - ^- form:m - ;< caz=(list card) b (do-init %contacts contacts-agent) - ;< =bowl b get-bowl - :: - =/ con-sun=contact - %- malt - ^- (list (pair @tas value)) - ~[nickname+text/'Sun' bio+text/'It is bright today'] - :: local subscriber to /news - :: - ;< ~ b (set-src our.bowl) - ;< caz=(list card) b (do-watch /news) - :: meet ~sun - :: - ;< caz=(list card) b (do-poke contact-action-1+!>([%meet ~[~sun]])) - :: ~sun publishes his contact - :: - ;< ~ b (set-src ~sun) - ;< caz=(list card) b - (do-agent /contact [~sun %contacts] %fact contact-update-1+!>([%full now.bowl con-sun])) - ;< ~ b - %+ ex-cards caz - :~ (ex-fact ~[/news] contact-news+!>([~sun (contact:to-0:c con-sun)])) - (ex-fact ~[/v1/news] contact-response-0+!>([%peer ~sun con-sun])) - == - :: ~sun appears in peers - :: - ;< peek=(unit (unit cage)) b (get-peek /x/v1/peer/~sun) - =/ cag=cage (need (need peek)) - ;< ~ b - %+ ex-equal - !> cag - !> contact-foreign-0+!>(`foreign`[[now.bowl con-sun] %want]) - ;< ~ b (set-src ~sun) - :: ~sun is added to contacts - :: - ;< ~ b (set-src our.bowl) - ;< caz=(list card) b (do-poke contact-action-1+!>([%page ~sun ~])) - ;< ~ b - %+ ex-cards caz - :~ (ex-fact ~[/v1/news] contact-response-0+!>([%page ~sun con-sun ~])) - == - :: ~sun contact page is edited - :: - =/ con-mod=contact - %- malt - ^- (list (pair @tas value)) - ~[nickname+text/'Bright Sun' avatar+look/'https://sun.io/sun.png'] - ;< caz=(list card) b (do-poke contact-action-1+!>([%edit ~sun con-mod])) - ;< ~ b - %+ ex-cards caz - :~ :: (ex-fact ~[/news] contact-news+!>([~sun (contact:to-0:c (~(uni by con-sun) con-mod))])) - (ex-fact ~[/v1/news] contact-response-0+!>([%page ~sun con-sun con-mod])) - == - :: ~sun is dropped - :: - ;< ~ b (set-src our.bowl) - ;< caz=(list card) b (do-poke contact-action-1+!>([%drop ~[~sun]])) - ;< ~ b - %+ ex-cards caz - :~ (ex-task /contact [~sun %contacts] %leave ~) - (ex-fact ~[/news] contact-news+!>([~sun ~])) - (ex-fact ~[/v1/news] contact-response-0+!>([%peer ~sun ~])) - == - :: ~sun is not found in peers - :: - ;< peek=(unit (unit cage)) b (get-peek /x/v1/peer/~sun) - ;< ~ b - %+ ex-equal - !> peek - !> [~ ~] - :: but his contact is not modified - :: - ;< peek=(unit (unit cage)) b (get-peek /x/v1/book/~sun) - =/ cag=cage (need (need peek)) - %+ ex-equal - !> cag - !> contact-page-0+!>(`page:c`[con-sun con-mod]) -:: +test-poke-snub: test snubbing a peer -:: -:: scenario -:: -:: we heve a local subscriber to /news. we meet -:: a peer ~sun. ~sun publishes his contact. subsequently, -:: ~sun is added to the contact book. we now snub ~sun. -:: ~sun is still found in peers. -:: -++ test-poke-snub - %- eval-mare - =/ m (mare ,~) - =* b bind:m - ^- form:m - ;< caz=(list card) b (do-init %contacts contacts-agent) - ;< =bowl b get-bowl - :: - =/ con-sun=contact - %- malt - ^- (list (pair @tas value)) - ~[nickname+text/'Sun' bio+text/'It is bright today'] - :: - ;< ~ b (set-src our.bowl) - ;< caz=(list card) b (do-watch /v1/news) - :: meet ~sun - :: - ;< caz=(list card) b (do-poke contact-action-1+!>([%meet ~[~sun]])) - :: ~sun publishes his contact - :: - ;< ~ b (set-src ~sun) - ;< caz=(list card) b - (do-agent /contact [~sun %contacts] %fact contact-update-1+!>([%full now.bowl con-sun])) - ;< ~ b - %+ ex-cards caz - :~ (ex-fact ~[/news] contact-news+!>([~sun (contact:to-0:c con-sun)])) - (ex-fact ~[/v1/news] contact-response-0+!>([%peer ~sun con-sun])) - == - :: ~sun is snubbed - :: - ;< ~ b (set-src our.bowl) - ;< caz=(list card) b (do-poke contact-action-1+!>([%snub ~[~sun]])) - ;< ~ b - %+ ex-cards caz - :~ (ex-task /contact [~sun %contacts] %leave ~) - == - :: ~sun is still found in peers - :: - ;< peek=(unit (unit cage)) b (get-peek /x/v1/peer/~sun) - =/ cag=cage (need (need peek)) - %+ ex-equal - !> cag - !> contact-foreign-0+!>(`foreign`[[now.bowl con-sun] ~]) -:: -+| %peer -:: +test-pub-profile -:: -:: scenario -:: -:: ~sun subscribes to our /contact. we publish -:: our profile with current time a. we then change -:: the profile, advancing the timestamp to time b. -:: ~sun now subscribes to /contact/at/b. -:: no update is sent. -:: -++ test-pub-profile - %- eval-mare - =/ m (mare ,~) - =* b bind:m - ^- form:m - ;< caz=(list card) b (do-init %contacts contacts-agent) - ;< =bowl b get-bowl - :: - =/ con=contact - %- malt - ^- (list (pair @tas value)) - ~[nickname+text/'Dev' bio+text/'Let\'s build'] - :: edit our profile - :: - ;< caz=(list card) b (do-poke contact-action-1+!>([%self con])) - ;< ~ b - %+ ex-cards caz - :~ (ex-fact ~[/news] contact-news+!>([our.bowl (contact:to-0:c con)])) - (ex-fact ~[/v1/news] contact-response-0+!>([%self con])) - (ex-fact ~ contact-update-1+!>([%full `@da`(add now.bowl tick) con])) - == - :: ~sun subscribes to /contact, profile is published - :: - ;< ~ b (set-src ~sun) - ;< caz=(list card) b (do-watch /v1/contact) - ;< ~ b %+ ex-cards caz - :~ (ex-fact ~ contact-update-1+!>([%full `@da`(add now.bowl tick) con])) - == - :: we update our profile, which advances the timestamp. - :: update is published. - :: - =+ now=`@da`(add now.bowl (mul 2 tick)) - =. con (~(put by con) birthday+date/~2000.1.1) - ;< ~ b (set-src our.bowl) - ;< caz=(list card) b (do-poke contact-action-1+!>([%self con])) - ;< ~ b - %+ ex-cards caz - :~ (ex-fact ~[/news] contact-news+!>([our.bowl (contact:to-0:c con)])) - (ex-fact ~[/v1/news] contact-response-0+!>([%self con])) - (ex-fact ~[/v1/contact] contact-update-1+!>([%full now con])) - == - :: ~sun resubscribes to /contact/at/old-now - :: update is sent - :: - ;< ~ b (set-src ~sun) - ;< caz=(list card) b (do-watch /v1/contact/at/(scot %da now.bowl)) - ;< ~ b - %+ ex-cards caz - :~ (ex-fact ~ contact-update-1+!>([%full now con])) - == - :: ~sun subscribes to /contact/at/(add now.bowl tick). - :: no update is sent - already at latest - :: - ;< ~ b (set-src ~sun) - ;< caz=(list card) b (do-watch /v1/contact/at/(scot %da now)) - %+ ex-cards caz ~ -:: -:: +test-sub-profile -:: -:: scenario -:: -:: we subscribe to ~sun's /contact. we receive -:: her profile at time a. subsequently, another update -:: of the profile with older timestamp is received. -:: ~sun's profile is not updated. most recent update -:: at time b arrives. ~sun's profile is updated. -:: we are kicked off the subscription, and in -:: the result we subscribe to /contact/at/b -:: path. -:: -++ test-sub-profile - %- eval-mare - =/ m (mare ,~) - =* b bind:m - ^- form:m - ;< caz=(list card) b (do-init %contacts contacts-agent) - ;< =bowl b get-bowl - :: - =/ con=contact - %- malt - ^- (list (pair @tas value)) - ~[nickname+text/'Sun' bio+text/'It is sunny today'] - =/ mod=contact - %- ~(uni by con) - %- malt ^- (list (pair @tas value)) - ~[birthday+date/~2000.1.1] - ;< caz=(list card) b (do-poke contact-action-1+!>([%meet ~sun ~])) - ;< ~ b - %+ ex-cards caz - :~ (ex-task /contact [~sun %contacts] %watch /v1/contact) - (ex-fact ~[/news] contact-news+!>([~sun ~])) - (ex-fact ~[/v1/news] contact-response-0+!>([%peer ~sun ~])) - == - ;< ~ b (set-src ~sun) - ;< caz=(list card) b - (do-agent /contact [~sun %contacts] %fact contact-update-1+!>([%full now.bowl con])) - ;< caz=(list card) b - (do-agent /contact [~sun %contacts] %fact contact-update-1+!>([%full (sub now.bowl tick) mod])) - :: ~sun's profile is unchanged - :: - ;< peek=(unit (unit cage)) b (get-peek /x/v1/peer/~sun) - =/ cag=cage (need (need peek)) - ;< ~ b - %+ ex-equal - !> cag - !> contact-foreign-0+!>(`foreign`[[now.bowl con] %want]) - ;< caz=(list card) b - (do-agent /contact [~sun %contacts] %fact contact-update-1+!>([%full (add now.bowl tick) mod])) - ;< peek=(unit (unit cage)) b (get-peek /x/v1/peer/~sun) - =/ cag=cage (need (need peek)) - ;< ~ b - %+ ex-equal - !> cag - !> contact-foreign-0+!>(`foreign`[[(add now.bowl tick) mod] %want]) - ;< caz=(list card) b - (do-agent /contact [~sun %contacts] %kick ~) - %+ ex-cards caz - :~ %^ ex-task /contact - [~sun %contacts] - [%watch /v1/contact/at/(scot %da (add now.bowl tick))] - == -:: -+| %peek -:: -++ test-peek-0-all - %- eval-mare - =/ m (mare ,~) - =* b bind:m - ^- form:m - ;< caz=(list card) b (do-init %contacts contacts-agent) - ;< =bowl b get-bowl - :: - =/ con-sun=contact - %- malt - ^- (list (pair @tas value)) - ~[nickname+text/'Sun' bio+text/'It is bright today'] - =/ con-mur=contact - %- malt - ^- (list (pair @tas value)) - ~[nickname+text/'Mur' bio+text/'Murky waters'] - :: meet ~sun and ~mur - :: - ;< ~ b (set-src our.bowl) - ;< caz=(list card) b (do-poke %contact-action-1 !>([%meet ~[~sun ~mur]])) - :: ~sun publishes his contact - :: - ;< ~ b (set-src ~sun) - ;< caz=(list card) b - (do-agent /contact [~sun %contacts] %fact %contact-update-1 !>([%full now.bowl con-sun])) - :: ~mur publishes his contact - :: - ;< ~ b (set-src ~mur) - ;< caz=(list card) b - (do-agent /contact [~mur %contacts] %fact %contact-update-1 !>([%full now.bowl con-mur])) - :: peek all: two peers are found - :: - ;< peek=(unit (unit cage)) b (get-peek /x/all) - =/ cag=cage (need (need peek)) - ?> ?=(%contact-rolodex p.cag) - =/ rol !<(rolodex:c0 q.cag) - ;< ~ b - %+ ex-equal - !> (~(got by rol) ~sun) - !> [[now.bowl (contact:to-0:c con-sun)] %want] - %+ ex-equal - !> (~(got by rol) ~mur) - !> [[now.bowl (contact:to-0:c con-mur)] %want] -:: -++ test-peek-book - %- eval-mare - =/ m (mare ,~) - =* b bind:m - ^- form:m - ;< caz=(list card) b (do-init %contacts contacts-agent) - ;< =bowl b get-bowl - :: - =/ con-1=contact - %- malt - ^- (list (pair @tas value)) - ~[nickname+text/'Sun' bio+text/'It is bright today'] - =/ con-2=contact - %- malt - ^- (list (pair @tas value)) - ~[nickname+text/'Mur' bio+text/'Murky waters'] - :: - ;< caz=(list card) b (do-poke contact-action-1+!>([%page id+0v1 con-1])) - ;< caz=(list card) b (do-poke contact-action-1+!>([%page id+0v2 con-2])) - :: peek book: two contacts are found - :: - ;< peek=(unit (unit cage)) b (get-peek /x/v1/book) - =/ cag=cage (need (need peek)) - ?> ?=(%contact-book-0 p.cag) - =/ =book !<(book q.cag) - ;< ~ b - %+ ex-equal - !> mod:(~(got by book) id+0v1) - !> con-1 - %+ ex-equal - !> mod:(~(got by book) id+0v2) - !> con-2 -:: -++ test-peek-page - %- eval-mare - =/ m (mare ,~) - =* b bind:m - ^- form:m - ;< caz=(list card) b (do-init %contacts contacts-agent) - ;< =bowl b get-bowl - :: - =/ con-1=contact - %- malt - ^- (list (pair @tas value)) - ~[nickname+text/'Sun' bio+text/'It is bright today'] - =/ con-2=contact - %- malt - ^- (list (pair @tas value)) - ~[nickname+text/'Mur' bio+text/'Murky waters'] - :: - ;< caz=(list card) b (do-poke contact-action-1+!>([%page id+0v1 con-1])) - ;< caz=(list card) b (do-poke contact-action-1+!>([%page id+0v2 con-2])) - :: unknown page is not found - :: - ;< peek=(unit (unit cage)) b (get-peek /u/v1/book/id/0v3) - ;< ~ b (ex-equal q:(need (need peek)) !>(|)) - :: - :: two pages are found - :: - ;< peek=(unit (unit cage)) b (get-peek /u/v1/book/id/0v1) - ;< ~ b (ex-equal q:(need (need peek)) !>(&)) - ;< peek=(unit (unit cage)) b (get-peek /x/v1/book/id/0v1) - =/ cag=cage (need (need peek)) - ;< ~ b - %+ ex-equal - !> cag - !> contact-page-0+!>(`page:c`[~ con-1]) - :: - ;< peek=(unit (unit cage)) b (get-peek /u/v1/book/id/0v2) - ;< ~ b (ex-equal q:(need (need peek)) !>(&)) - ;< peek=(unit (unit cage)) b (get-peek /x/v1/book/id/0v2) - =/ cag=cage (need (need peek)) - :: ;< ~ b - %+ ex-equal - !> cag - !> contact-page-0+!>(`page:c`[~ con-2]) -:: -++ test-peek-all - %- eval-mare - =/ m (mare ,~) - =* b bind:m - ^- form:m - ;< caz=(list card) b (do-init %contacts contacts-agent) - ;< =bowl b get-bowl - :: - =/ con-sun=contact - %- malt - ^- (list (pair @tas value)) - ~[nickname+text/'Sun' bio+text/'It is bright today'] - =/ con-mur=contact - %- malt - ^- (list (pair @tas value)) - ~[nickname+text/'Mur' bio+text/'Murky waters'] - =/ con-mod=contact - %- malt - ^- (list (pair @tas value)) - ~[avatar+look/'https://sun.io/sun.png'] - :: meet ~sun and ~mur - :: - ;< ~ b (set-src our.bowl) - ;< caz=(list card) b (do-poke %contact-action-1 !>([%meet ~[~sun ~mur]])) - :: ~sun publishes his contact - :: - ;< ~ b (set-src ~sun) - ;< caz=(list card) b - (do-agent /contact [~sun %contacts] %fact contact-update-1+!>([%full now.bowl con-sun])) - :: ~sun is added to the contact book with user overlay - :: - ;< ~ b (set-src our.bowl) - ;< caz=(list card) b (do-poke contact-action-1+!>([%page ~sun con-mod])) - :: ~mur publishes his contact - :: - ;< ~ b (set-src ~mur) - ;< caz=(list card) b - (do-agent /contact [~mur %contacts] %fact contact-update-1+!>([%full now.bowl con-mur])) - :: peek all: two contacts are found - :: - ;< peek=(unit (unit cage)) b (get-peek /x/v1/all) - =/ cag=cage (need (need peek)) - ?> ?=(%contact-directory-0 p.cag) - =/ dir !<(directory q.cag) - ;< ~ b - %+ ex-equal - !> (~(got by dir) ~sun) - !> (contact-uni:c con-sun con-mod) - %+ ex-equal - !> (~(got by dir) ~mur) - !> con-mur -:: +test-retry: test resubscription logic -:: -:: scenario -:: -:: we %meet ~sun. however, ~sun is running incompatible version. -:: negative %watch-ack arrives. we setup the timer to retry. -:: the timer fires. we resubscribe. -:: -++ test-retry - %- eval-mare - =/ m (mare ,~) - =* b bind:m - ^- form:m - :: - ;< caz=(list card) b (do-init %contacts contacts-agent) - ;< =bowl b get-bowl - ;< caz=(list card) b (do-poke contact-action-1+!>([%meet ~[~sun]])) - ;< caz=(list card) b - %^ do-agent /contact - [~sun %contacts] - [%watch-ack (some leaf+"outdated contacts" ~)] - ;< ~ b - %+ ex-cards caz - :~ %+ ex-arvo /retry/(scot %p ~sun) - [%b %wait (add now.bowl ~m30)] - == - ;< caz=(list card) b - %+ do-arvo /retry/(scot %p ~sun) - [%behn %wake ~] - %+ ex-cards caz - :~ %^ ex-task /contact - [~sun %contacts] - [%watch /v1/contact] - == --- diff --git a/desk/tests/app/reel.hoon b/desk/tests/app/reel.hoon deleted file mode 100644 index ee7808db..00000000 --- a/desk/tests/app/reel.hoon +++ /dev/null @@ -1,120 +0,0 @@ -/- r=reel -/+ *test-agent -/= reel-agent /app/reel -|% -++ dap %reel-test -++ vic 'https://tlon.network/lure/' -++ civ ~loshut-lonreg -++ token '~bus/reel-test' -+$ reel-state - $: %4 - vic=@t - civ=ship - our-metadata=(map token:r metadata:r) - open-link-requests=(set (pair ship cord)) - open-describes=(set token:r) - stable-id=(map cord token:r) - == -++ test-reel-describe - %- eval-mare - =/ m (mare ,~) - ;< * bind:m (do-init dap reel-agent) - ;< * bind:m (jab-bowl |=(b=bowl b(our ~dev, src ~dev, now *@da))) - =/ =metadata:r [%test (my ['inviter' '~dev'] ['group' '~bus/reel-test'] ~)] - =/ describe [token metadata] - ;< caz=(list card) bind:m (do-poke %reel-describe !>(describe)) - ;< bw=bowl bind:m get-bowl - =/ nonce (scot %da now.bw) - =/ edited-md [%test (~(put by fields.metadata) 'bite-type' '2')] - :: make sure we're sending a describe request to the bait provider - ;< * bind:m - %+ ex-cards caz - =/ request [nonce edited-md] - ~[(ex-poke /describe [civ %bait] bait-describe+!>(request))] - ;< state=vase bind:m get-save - =+ !<(reel-state state) - :: ensure link metadata added to our state and has bite-type field - ;< * bind:m (ex-equal !>(our-metadata) !>((my [nonce edited-md] ~))) - :: ensure nonce is added to open-describes set - ;< * bind:m (ex-equal !>(open-describes) !>((sy [nonce] ~))) - :: ensure stable-id has an entry for the token - ;< * bind:m (ex-equal !>(stable-id) !>((my [token nonce] ~))) - :: simulate the bait provider returning the new metadata - ;< bw=bowl bind:m get-bowl - =/ real-token (shax (jam [dap eny.bw])) - ;< * bind:m (jab-bowl |=(b=bowl b(src civ))) - ;< * bind:m (do-poke %reel-confirmation !>([nonce real-token])) - ;< state=vase bind:m get-save - =+ !<(reel-state state) - ;< * bind:m (ex-equal !>(open-describes) !>(~)) - ;< * bind:m (ex-equal !>(stable-id) !>((sy [token real-token] ~))) - (ex-equal !>(our-metadata) !>((my [real-token edited-md] ~))) -:: -:: testing old way of distributing links from requester side -++ test-reel-token-link-requester - %- eval-mare - =/ m (mare ,~) - ;< * bind:m (do-init dap reel-agent) - ;< * bind:m (jab-bowl |=(b=bowl b(our ~dev, src ~dev, now *@da))) - ;< bw=bowl bind:m get-bowl - =/ request-path /token-link/(scot %p ~bus)/[dap] - :: simulate subscription from frontend for link - ;< caz=(list card) bind:m - (do-watch request-path) - =/ next (add now.bw ~h1) - =/ expire=wire /expire/(scot %p ~bus)/[dap] - ;< * bind:m - %+ ex-cards caz - =/ =cage reel-want-token-link+!>(dap) - :~ (ex-poke request-path [~bus dap] cage) - (ex-arvo expire %b %wait next) - == - ;< state=vase bind:m get-save - =+ !<(reel-state state) - =/ new-requests (sy [~bus dap] ~) - :: ensure that the request is in the open-link-requests set - ;< * bind:m (ex-equal !>(open-link-requests) !>(new-requests)) - ;< * bind:m (jab-bowl |=(b=bowl b(now next))) - ;< bw=bowl bind:m get-bowl - :: simulate link request expiring - ;< * bind:m (do-arvo expire %behn %wake ~) - ;< state=vase bind:m get-save - =+ !<(reel-state state) - :: make sure the request is removed from the open-link-requests set - ;< * bind:m (ex-equal !>(open-link-requests) !>(~)) - :: try to get the link again, but this time not expiring - ;< * bind:m (do-watch request-path) - =/ url (cat 3 vic '~bus/reel-test') - =/ response `[dap url] - ;< * bind:m (jab-bowl |=(b=bowl b(src ~bus))) - ;< caz=(list card) bind:m (do-poke %reel-give-token-link !>(response)) - %+ ex-cards caz - ~[(ex-fact ~[request-path] %json !>(s+url))] -:: -:: testing old way of distributing links from dispenser side -++ test-reel-token-link-dispenser - %- eval-mare - =/ m (mare ,~) - ;< * bind:m (do-init dap reel-agent) - ;< * bind:m (jab-bowl |=(b=bowl b(our ~bus, src ~bus))) - :: build state for link - =/ fields=(map cord cord) (my ['inviter' '~zod'] ~) - =/ init-state=vase - !> - :* %4 - vic - civ - (my [token %meta fields] ~) - ~ - ~ - (my [token token] ~) - == - ;< * bind:m (do-load reel-agent `init-state) - ;< * bind:m (jab-bowl |=(b=bowl b(src ~zod))) - :: simulate link request - ;< caz=(list card) bind:m (do-poke %reel-want-token-link !>(token)) - %+ ex-cards caz - =/ url (cat 3 vic '~bus/reel-test') - =/ =cage reel-give-token-link+!>(`[token url]) - ~[(ex-poke /token-link-want/[token] [~zod dap] cage)] --- \ No newline at end of file diff --git a/desk/tests/lib/contacts-json-1.hoon b/desk/tests/lib/contacts-json-1.hoon deleted file mode 100644 index 2c9766e3..00000000 --- a/desk/tests/lib/contacts-json-1.hoon +++ /dev/null @@ -1,252 +0,0 @@ -/- *contacts, g=groups -/+ *test -/+ c=contacts, j=contacts-json-1, mark-warmer -:: -/= c0 /mar/contact-0 -/= c1 /mar/contact -/~ mar * /mar/contact -:: -|% -:: -++ ex-equal - |= [a=vase b=vase] - (expect-eq b a) -:: -++ enjs-equal - |= [jon=json txt=@t] - %+ ex-equal - !> (en:json:html jon) - !> txt -:: -++ dejs-equal - |* [saf=$-(json *) txt=@t data=*] - %+ ex-equal - !> (saf (need (de:json:html txt))) - !> data -:: -++ test-ship - ;: weld - %+ enjs-equal - (ship:enjs:j ~sampel-palnet) - '"~sampel-palnet"' - :: - %^ dejs-equal ship:dejs:j - '"~sampel-palnet"' - ~sampel-palnet - == -++ test-cid - ;: weld - %+ enjs-equal - (cid:enjs:j 0v11abc) - '"0v11abc"' - :: - %^ dejs-equal cid:dejs:j - '"0v11abc"' - 0v11abc - == -++ test-kip - ;: weld - %+ enjs-equal - (kip:enjs:j ~sampel-palnet) - '"~sampel-palnet"' - :: - %+ enjs-equal - (kip:enjs:j id+0v11abc) - '"0v11abc"' - :: - %^ dejs-equal kip:dejs:j - '"~sampel-palnet"' - ~sampel-palnet - :: - %^ dejs-equal kip:dejs:j - '"0v11abc"' - id+0v11abc - == -++ test-value - ;: weld - :: submit null value to delete entry in contacts - :: - %^ dejs-equal value:dejs:j - 'null' - ~ - :: - %+ enjs-equal - (value:enjs:j text+'the lazy fox') - '{"type":"text","value":"the lazy fox"}' - :: - %^ dejs-equal value:dejs:j - '{"type":"text","value":"the lazy fox"}' - text+'the lazy fox' - :: - %+ enjs-equal - (value:enjs:j numb+42) - '{"type":"numb","value":42}' - :: - %^ dejs-equal value:dejs:j - '{"type":"numb","value":42}' - numb+42 - :: - %+ enjs-equal - (value:enjs:j date+~2024.9.11) - '{"type":"date","value":"~2024.9.11"}' - :: - %^ dejs-equal value:dejs:j - '{"type":"date","value":"~2024.9.11"}' - date+~2024.9.11 - :: - %+ enjs-equal - (value:enjs:j tint+0xcafe.babe) - '{"type":"tint","value":"cafe.babe"}' - :: - %^ dejs-equal value:dejs:j - '{"type":"tint","value":"cafe.babe"}' - tint+0xcafe.babe - :: - %+ enjs-equal - (value:enjs:j ship+~sampel-palnet) - '{"type":"ship","value":"~sampel-palnet"}' - :: - %^ dejs-equal value:dejs:j - '{"type":"ship","value":"~sampel-palnet"}' - ship+~sampel-palnet - :: - %+ enjs-equal - (value:enjs:j look+'https://ship.io/avatar.png') - '{"type":"look","value":"https://ship.io/avatar.png"}' - :: - %^ dejs-equal value:dejs:j - '{"type":"look","value":"https://ship.io/avatar.png"}' - look+'https://ship.io/avatar.png' - :: - %+ enjs-equal - (value:enjs:j flag+[~sampel-palnet %circle]) - '{"type":"flag","value":"~sampel-palnet/circle"}' - :: - %^ dejs-equal value:dejs:j - '{"type":"flag","value":"~sampel-palnet/circle"}' - flag+[~sampel-palnet %circle] - :: - %+ enjs-equal - %- value:enjs:j - set+(silt `(list value)`~[flag/[~sampel-palnet %circle] flag/[~sampel-pardux %square]]) - '{"type":"set","value":[{"type":"flag","value":"~sampel-palnet/circle"},{"type":"flag","value":"~sampel-pardux/square"}]}' - :: - %^ dejs-equal value:dejs:j - '{"type":"set","value":[{"type":"flag","value":"~sampel-palnet/circle"},{"type":"flag","value":"~sampel-pardux/square"}]}' - set+(silt `(list value)`~[flag/[~sampel-palnet %circle] flag/[~sampel-pardux %square]]) - == -++ test-contact - ;: weld - %+ enjs-equal - %- contact:enjs:j - %- malt - ^- (list [@tas value]) - :~ name+text/'Sampel' - surname+text/'Palnet' - == - '{"name":{"type":"text","value":"Sampel"},"surname":{"type":"text","value":"Palnet"}}' - :: - %^ dejs-equal contact:dejs:j - '{"name":{"type":"text","value":"Sampel"},"surname":{"type":"text","value":"Palnet"}}' - ^- contact:c - %- malt - ^- (list [@tas value]) - :~ name+text/'Sampel' - surname+text/'Palnet' - == - == -++ test-action - =/ con=contact:c - %- malt - ^- (list [@tas value]) - :~ name+text/'Sampel' - == - =/ mod=contact:c - %- malt - ^- (list [@tas value]) - :~ surname+text/'Palnet' - == - :: - ;: weld - %^ dejs-equal action:dejs:j - '{"anon":null}' - [%anon ~] - :: - %^ dejs-equal action:dejs:j - '{"self":{"name":{"type":"text","value":"Sampel"}}}' - [%self con] - :: - %^ dejs-equal action:dejs:j - '{"page":{"kip":"0v1","contact":{"surname":{"type":"text","value":"Palnet"}}}}' - [%page id+0v1 mod] - :: - %^ dejs-equal action:dejs:j - '{"page":{"kip":"~sampel-palnet","contact":{"surname":{"type":"text","value":"Palnet"}}}}' - [%page ~sampel-palnet mod] - :: - %^ dejs-equal action:dejs:j - '{"wipe":["0v1", "0v2", "~sampel-palnet"]}' - [%wipe id+0v1 id+0v2 ~sampel-palnet ~] - :: - %^ dejs-equal action:dejs:j - '{"meet":["~sampel-palnet", "~master-botnet"]}' - [%meet ~sampel-palnet ~master-botnet ~] - :: - %^ dejs-equal action:dejs:j - '{"drop":["~sampel-palnet", "~master-botnet"]}' - [%drop ~sampel-palnet ~master-botnet ~] - :: - %^ dejs-equal action:dejs:j - '{"snub":["~sampel-palnet", "~master-botnet"]}' - [%snub ~sampel-palnet ~master-botnet ~] - == -++ test-response - =/ con=contact:c - %- malt - ^- (list [@tas value]) - :~ name+text/'Sampel' - == - =/ mod=contact:c - %- malt - ^- (list [@tas value]) - :~ surname+text/'Palnet' - == - ;: weld - %+ enjs-equal - (response:enjs:j [%self con]) - '{"self":{"contact":{"name":{"type":"text","value":"Sampel"}}}}' - :: - %+ enjs-equal - (response:enjs:j [%page id+0v1 con mod]) - ^~ %- en:json:html %- need %- de:json:html - ''' - { - "page": { - "mod":{"surname":{"type":"text","value":"Palnet"}}, - "kip":"0v1", - "contact":{"name":{"type":"text","value":"Sampel"}} - } - } - ''' - :: - %+ enjs-equal - (response:enjs:j [%wipe id+0v1]) - '{"wipe":{"kip":"0v1"}}' - :: - %+ enjs-equal - (response:enjs:j [%wipe ~sampel-palnet]) - '{"wipe":{"kip":"~sampel-palnet"}}' - :: - %+ enjs-equal - (response:enjs:j [%peer ~sampel-palnet con]) - ^~ %- en:json:html %- need %- de:json:html - ''' - { - "peer": { - "who":"~sampel-palnet", - "contact":{"name":{"type":"text","value":"Sampel"}} - } - } - ''' - == ---