mirror of
https://github.com/urbit/shrub.git
synced 2024-12-25 04:52:06 +03:00
naive: minimum l1/deposit/l2 tests
This commit is contained in:
parent
c8f8d8b36d
commit
0c79d73f68
@ -40,6 +40,12 @@
|
||||
::
|
||||
:: TODO: if sig fails to verify, skip instead of crashing
|
||||
::
|
||||
:: TODO: is it possible to spawn directly to the deposit address? if
|
||||
:: so, should we find its parent's owner to control it?
|
||||
::
|
||||
:: TODO: should we add any protection in the L1 contracts that you
|
||||
:: don't deposit from a contract?
|
||||
::
|
||||
/+ ethereum
|
||||
:: Constants
|
||||
::
|
||||
@ -123,17 +129,6 @@
|
||||
:: ECDSA verifier
|
||||
::
|
||||
+$ verifier $-([dat=@ v=@ r=@ s=@] =address)
|
||||
:: stdlib verifier, for testing
|
||||
::
|
||||
:: TODO: does this uniquely produce the pubkey?
|
||||
::
|
||||
++ dumver
|
||||
^- verifier
|
||||
|= [dat=@ v=@ r=@ s=@]
|
||||
=, secp256k1:secp:crypto
|
||||
%- address-from-pub:key:ethereum
|
||||
%- serialize-point
|
||||
(ecdsa-raw-recover dat v r s)
|
||||
--
|
||||
::
|
||||
|%
|
||||
|
@ -1,5 +1,7 @@
|
||||
/+ *test, naive, ethereum
|
||||
|%
|
||||
++ address @ux
|
||||
++ n |=([=^state:naive =^input:naive] (naive dumver +<))
|
||||
++ dumver
|
||||
^- ^verifier:naive
|
||||
|= [dat=@ v=@ r=@ s=@]
|
||||
@ -7,6 +9,43 @@
|
||||
%- address-from-pub:key:ethereum
|
||||
%- serialize-point
|
||||
(ecdsa-raw-recover dat v r s)
|
||||
::
|
||||
++ key address-from-prv:key:ethereum
|
||||
++ log
|
||||
|= [event=@t data=@t topics=(lest @)]
|
||||
^- ^input:naive
|
||||
[%log ~ *@ux data (hash-log-name:naive event) topics]
|
||||
::
|
||||
::
|
||||
++ owner-changed
|
||||
|= [=ship =address]
|
||||
(log 'OwnerChanged(uint32,address)' *@t ship address ~)
|
||||
::
|
||||
++ init-bud
|
||||
|= =^state:naive
|
||||
(n state (owner-changed ~bud 0x123))
|
||||
::
|
||||
++ init-l2-marbud
|
||||
|= =^state:naive
|
||||
=^ f1 state (init-bud state)
|
||||
=^ f2 state (n state (owner-changed ~marbud (key ~marbud)))
|
||||
=^ f3 state (n state (owner-changed ~marbud deposit-address:naive))
|
||||
[:(welp f1 f2 f3) state]
|
||||
::
|
||||
++ sign-tx
|
||||
|= [pk=@ tx=@]
|
||||
=+ (ecdsa-raw-sign:secp256k1:secp:crypto tx pk)
|
||||
(cat 3 (can 3 1^v 32^r 32^s ~) tx)
|
||||
::
|
||||
++ transfer-point
|
||||
|= [=ship =address reset=?]
|
||||
%+ sign-tx ship
|
||||
%: can 3
|
||||
1^(can 0 7^%0 1^reset ~)
|
||||
4^ship
|
||||
20^address
|
||||
~
|
||||
==
|
||||
--
|
||||
::
|
||||
|%
|
||||
@ -20,4 +59,23 @@
|
||||
:* %log ~ *@ux *@t
|
||||
(hash-log-name:naive 'OwnerChanged(uint32,address)') (@ux ~bud) 0x123 ~
|
||||
==
|
||||
::
|
||||
++ test-deposit
|
||||
%+ expect-eq
|
||||
!> %l2
|
||||
::
|
||||
!>
|
||||
=| =^state:naive
|
||||
=^ f state (init-l2-marbud state)
|
||||
dominion:(~(got by points.state) ~marbud)
|
||||
::
|
||||
++ test-batch
|
||||
%+ expect-eq
|
||||
!> 0x234
|
||||
::
|
||||
!>
|
||||
=| =^state:naive
|
||||
=^ f state (init-l2-marbud state)
|
||||
=^ f state (n state %bat (transfer-point ~marbud 0x234 |))
|
||||
owner.own:(~(got by points.state) ~marbud)
|
||||
--
|
||||
|
Loading…
Reference in New Issue
Block a user