mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-24 07:26:51 +03:00
naive: tests: nonces for proxies
This commit is contained in:
parent
cd615524cd
commit
ae3b2ec6af
@ -585,11 +585,11 @@
|
|||||||
++ gen-rut-jar
|
++ gen-rut-jar
|
||||||
^- (jar @p event)
|
^- (jar @p event)
|
||||||
=/ filter ;: cork
|
=/ filter ;: cork
|
||||||
::(cury filter-owner %.y)
|
(cury filter-owner %.y)
|
||||||
(cury filter-proxy %own)
|
(cury filter-proxy %own)
|
||||||
:: (cury filter-nonce %.n)
|
(cury filter-nonce %.y)
|
||||||
::(cury filter-rank %star)
|
::(cury filter-rank %star)
|
||||||
(cury filter-dominion %l2)
|
::(cury filter-dominion %l2)
|
||||||
%- cury
|
%- cury
|
||||||
:- filter-tx-type
|
:- filter-tx-type
|
||||||
:* %spawn
|
:* %spawn
|
||||||
@ -835,8 +835,18 @@
|
|||||||
%+ category (weld "correct nonce? " (scow %f nonce.cur-event))
|
%+ category (weld "correct nonce? " (scow %f nonce.cur-event))
|
||||||
::
|
::
|
||||||
=/ cur-point (~(got by points.initial-state) cur-ship)
|
=/ cur-point (~(got by points.initial-state) cur-ship)
|
||||||
=/ cur-nonce nonce.owner.own:(~(got by points.initial-state) cur-ship)
|
::=/ cur-nonce nonce.owner.own:(~(got by points.initial-state) cur-ship)
|
||||||
=/ new-nonce ?: &(nonce.cur-event owner.cur-event) :: wrong nonce and/or wrong owner do not increment nonce
|
=* own own.cur-point
|
||||||
|
=/ cur-nonce
|
||||||
|
?- proxy.cur-event
|
||||||
|
%own nonce.owner.own
|
||||||
|
%spawn nonce.spawn-proxy.own
|
||||||
|
%manage nonce.management-proxy.own
|
||||||
|
%vote nonce.voting-proxy.own
|
||||||
|
%transfer nonce.transfer-proxy.own
|
||||||
|
==
|
||||||
|
:: wrong nonce and/or wrong owner do not increment nonce
|
||||||
|
=/ new-nonce ?: &(nonce.cur-event owner.cur-event)
|
||||||
+(cur-nonce)
|
+(cur-nonce)
|
||||||
cur-nonce
|
cur-nonce
|
||||||
::
|
::
|
||||||
@ -847,7 +857,14 @@
|
|||||||
!>
|
!>
|
||||||
|^ ^- ^state:naive
|
|^ ^- ^state:naive
|
||||||
?. (~(got by suc-map) cur-event)
|
?. (~(got by suc-map) cur-event)
|
||||||
(alter-state cur-point(nonce.owner.own new-nonce))
|
%- alter-state
|
||||||
|
?- proxy.cur-event
|
||||||
|
%own cur-point(nonce.owner.own new-nonce)
|
||||||
|
%spawn cur-point(nonce.spawn-proxy.own new-nonce)
|
||||||
|
%manage cur-point(nonce.management-proxy.own new-nonce)
|
||||||
|
%vote cur-point(nonce.voting-proxy.own new-nonce)
|
||||||
|
%transfer cur-point(nonce.transfer-proxy.own new-nonce)
|
||||||
|
==
|
||||||
?+ tx-type.cur-event !!
|
?+ tx-type.cur-event !!
|
||||||
%transfer-point set-xfer
|
%transfer-point set-xfer
|
||||||
%configure-keys set-keys
|
%configure-keys set-keys
|
||||||
@ -858,14 +875,32 @@
|
|||||||
%escape (set-escape which-escape-l2)
|
%escape (set-escape which-escape-l2)
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
|
:: ++ inc-nonce ^- ^state:naive
|
||||||
|
:: =* own own.cur-point
|
||||||
|
:: =^ nonce cur-point
|
||||||
|
:: ?- proxy.cur-event
|
||||||
|
:: %own
|
||||||
|
:: :- nonce.owner.own
|
||||||
|
:: cur-point(nonce.owner.own +(nonce.owner.own))
|
||||||
|
:: ++ inc-nonce ^- ^state:naive
|
||||||
|
:: =/ up-nonce
|
||||||
|
:: %= cur-point
|
||||||
|
:: ?+ proxy.cur-event !!
|
||||||
|
:: %own nonce.owner.own
|
||||||
|
:: %spawn nonce.spawn-proxy.own
|
||||||
|
:: %management nonce.management-proxy.own
|
||||||
|
:: %vote nonce.voting-proxy.own
|
||||||
|
:: %transfer nonce.transfer-proxy.own
|
||||||
|
:: == new-nonce
|
||||||
|
:: (alter-state up-nonce)
|
||||||
|
::
|
||||||
++ set-keys ^- ^state:naive
|
++ set-keys ^- ^state:naive
|
||||||
=/ new-keys
|
=/ new-keys
|
||||||
%= cur-point
|
%= cur-point
|
||||||
life.keys.net +(life.keys.net:(~(got by points.initial-state) cur-ship))
|
life.keys.net +(life.keys.net:(~(got by points.initial-state) cur-ship))
|
||||||
suite.keys.net suit
|
suite.keys.net suit
|
||||||
auth.keys.net auth
|
auth.keys.net auth
|
||||||
crypt.keys.net encr
|
crypt.keys.net encr
|
||||||
nonce.owner.own new-nonce
|
|
||||||
==
|
==
|
||||||
(alter-state new-keys)
|
(alter-state new-keys)
|
||||||
::
|
::
|
||||||
@ -873,7 +908,6 @@
|
|||||||
=/ new-xfer
|
=/ new-xfer
|
||||||
%= cur-point
|
%= cur-point
|
||||||
address.owner.own (addr %transfer-test)
|
address.owner.own (addr %transfer-test)
|
||||||
nonce.owner.own new-nonce
|
|
||||||
==
|
==
|
||||||
(alter-state new-xfer)
|
(alter-state new-xfer)
|
||||||
::
|
::
|
||||||
@ -881,7 +915,6 @@
|
|||||||
=/ new-mgmt
|
=/ new-mgmt
|
||||||
%= cur-point
|
%= cur-point
|
||||||
address.management-proxy.own (addr %proxy-test)
|
address.management-proxy.own (addr %proxy-test)
|
||||||
nonce.owner.own new-nonce
|
|
||||||
==
|
==
|
||||||
(alter-state new-mgmt)
|
(alter-state new-mgmt)
|
||||||
::
|
::
|
||||||
@ -889,7 +922,6 @@
|
|||||||
=/ new-spwn
|
=/ new-spwn
|
||||||
%= cur-point
|
%= cur-point
|
||||||
address.spawn-proxy.own (addr %proxy-test)
|
address.spawn-proxy.own (addr %proxy-test)
|
||||||
nonce.owner.own new-nonce
|
|
||||||
==
|
==
|
||||||
(alter-state new-spwn)
|
(alter-state new-spwn)
|
||||||
::
|
::
|
||||||
@ -897,7 +929,6 @@
|
|||||||
=/ new-xfer
|
=/ new-xfer
|
||||||
%= cur-point
|
%= cur-point
|
||||||
address.transfer-proxy.own (addr %proxy-test)
|
address.transfer-proxy.own (addr %proxy-test)
|
||||||
nonce.owner.own new-nonce
|
|
||||||
==
|
==
|
||||||
(alter-state new-xfer)
|
(alter-state new-xfer)
|
||||||
::
|
::
|
||||||
@ -906,7 +937,6 @@
|
|||||||
=/ new-escp
|
=/ new-escp
|
||||||
%= cur-point
|
%= cur-point
|
||||||
escape.net (some ship)
|
escape.net (some ship)
|
||||||
nonce.owner.own new-nonce
|
|
||||||
==
|
==
|
||||||
(alter-state new-escp)
|
(alter-state new-escp)
|
||||||
::
|
::
|
||||||
@ -921,22 +951,33 @@
|
|||||||
address.transfer-proxy.own (addr %spawn-test)
|
address.transfer-proxy.own (addr %spawn-test)
|
||||||
sponsor.net [has=%.y who=cur-ship]
|
sponsor.net [has=%.y who=cur-ship]
|
||||||
==
|
==
|
||||||
=/ new-point-nonce
|
::=/ new-spawn=^state:naive
|
||||||
%= cur-point
|
=/ expect-state (alter-state cur-point) :: this updates the nonce of the spawner
|
||||||
nonce.owner.own new-nonce
|
|
||||||
==
|
|
||||||
=/ new-spawn=^state:naive
|
|
||||||
%= expect-state
|
%= expect-state
|
||||||
points (~(put by points.expect-state) ship spawned)
|
points (~(put by points.expect-state) ship spawned)
|
||||||
==
|
==
|
||||||
%= new-spawn
|
:: =/ new-point-nonce
|
||||||
points (~(put by points.new-spawn) cur-ship new-point-nonce)
|
:: %= cur-point
|
||||||
==
|
:: nonce.owner.own new-nonce
|
||||||
|
:: ==
|
||||||
|
:: %= new-spawn
|
||||||
|
:: points (~(put by points.new-spawn) cur-ship new-point-nonce)
|
||||||
|
:: ==
|
||||||
::
|
::
|
||||||
++ alter-state
|
++ alter-state
|
||||||
|= new-point=point:naive ^- ^state:naive
|
:: this updates the expect-state with the new point, and takes
|
||||||
|
:: care of incrementing the nonce as well.
|
||||||
|
|= alt-point=point:naive ^- ^state:naive
|
||||||
|
=/ updated-point=point:naive
|
||||||
|
?- proxy.cur-event
|
||||||
|
%own alt-point(nonce.owner.own new-nonce)
|
||||||
|
%spawn alt-point(nonce.spawn-proxy.own new-nonce)
|
||||||
|
%manage alt-point(nonce.management-proxy.own new-nonce)
|
||||||
|
%vote alt-point(nonce.voting-proxy.own new-nonce)
|
||||||
|
%transfer alt-point(nonce.transfer-proxy.own new-nonce)
|
||||||
|
==
|
||||||
%= expect-state
|
%= expect-state
|
||||||
points (~(put by points.expect-state) cur-ship new-point)
|
points (~(put by points.expect-state) cur-ship updated-point)
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
-- :: end of expected state
|
-- :: end of expected state
|
||||||
|
Loading…
Reference in New Issue
Block a user