shrub/pkg/arvo/tests/sys/zuse/ethereum/rlp.hoon
Jared Tobin b3901ab42f Add 'pkg/arvo/' from commit 'c20e2a185f131ff3f5d3961829bd7a3fe0f227f8'
git-subtree-dir: pkg/arvo
git-subtree-mainline: 9c8f40bf6c
git-subtree-split: c20e2a185f
2019-06-28 12:48:05 +08:00

54 lines
1.1 KiB
Plaintext

/+ *test
|%
::NOTE tests lightly modified from the examples here:
:: https://github.com/ethereum/wiki/wiki/RLP
::
++ test-encoding-string
%+ expect-eq
!> %- encode:rlp:ethereum
b+3^0xaa.bbcc
!> 0x83aa.bbcc
::
++ test-encoding-list
%+ expect-eq
!> %- encode:rlp:ethereum
l+~[b+3^0xaa.bbcc b+3^0xdd.eeff]
!> 0xc8.83aa.bbcc.83dd.eeff
::
++ test-encoding-empty-list
%+ expect-eq
!> %- encode:rlp:ethereum
l+~
!> 0xc0
::
++ test-encoding-zero-byte
%+ expect-eq
!> %- encode:rlp:ethereum
b+1^0x0
!> 0x0
::
++ test-encoding-empty-zero
%+ expect-eq
!> %- encode:rlp:ethereum
b+0^0x0
!> 0x80
::
++ test-encoding-15
%+ expect-eq
!> %- encode:rlp:ethereum
b+1^15
!> 0xf
::
++ test-encoding-1024
%+ expect-eq
!> %- encode:rlp:ethereum
b+2^1.024
!> 0x82.0400
::
++ test-encoding-set-of-three
%+ expect-eq
!> %- encode:rlp:ethereum
l+[l+~ l+[l+~ ~] l+[l+~ l+[l+~ ~] ~] ~]
!> 0xc7c0.c1c0.c3c0.c1c0
--