package Ġcom . sol ana . models Ċ Ċ import Ġcom . sol ana . core . PublicKey Ċ import Ġcom . sol ana . core . PublicKey Rule Ċ import Ġcom . sol ana . models . Buffer .* Ċ import Ġcom . sol ana . vendor . bor sh j . Bor sh Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . Assert .* Ċ Ċ class ĠDe coding Tests Ġ{ ĊĊĠĠĠ Ġfun Ġbor sh (): ĠBor sh Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbor sh Ġ= ĠBor sh () ĊĠĠĠĠĠĠĠ Ġbor sh . set Rules ( listOf ( PublicKey Rule (), ĠAccount Info Rule (), ĠM int Rule (), ĠToken Swap Info Rule ())) ĊĠĠĠĠĠĠĠ Ġreturn Ġbor sh ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest De coding PublicKey () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbor sh Ġ= Ġbor sh () ĊĠĠĠĠĠĠĠ Ġval Ġbytes Ġ= Ġbyte ArrayOf ( Ġ 3 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 , Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġkey Ġ= ĠPublicKey ( bytes ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" Ci Dw V BF g WV 9 E 5 Mv X Wo L gn E gn 2 h K 7 r J ik b vf W av z AQ z 3 ", Ġkey . to Base 5 8 ()) ĊĠĠĠĠĠĠĠ Ġval Ġserialized Ġ= Ġbor sh . serialize ( key ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( serialized . to Typed Array (), Ġbytes . to Typed Array ()) ĊĠĠĠĠĠĠĠ Ġval Ġnew Public key Ġ= Ġbor sh . deserialize ( serialized , ĠPublicKey :: class . java ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" Ci Dw V BF g WV 9 E 5 Mv X Wo L gn E gn 2 h K 7 r J ik b vf W av z AQ z 3 ", Ġnew Public key . to Base 5 8 ()) ĊĠĠĠ Ġ} ĊĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest De coding Mint () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbor sh Ġ= Ġbor sh () ĊĠĠĠĠĠĠĠ Ġval Ġraw Data Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" AQ AAAA Ya 2 dB Th x VI U 3 7 e Pi YY Sa P ft / 0 C + rx 1 si PI 5 G rb h T 0 M AB Cl 1 Og AAA AG AQ AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA ==", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" base 6 4 " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġbuffer Ġ= ĠBuffer ( bor sh , Ġraw Data , ĠM int :: class . java ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( buffer . value ) ĊĠĠĠĠĠĠĠ Ġval Ġmint Layout Ġ= Ġbuffer . value !! ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" Qq CC v sh xt q MAL 2 C VAL qi JB 7 uE e E 5 mj SP sse Q d D zs RU o ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmint Layout . mint Authority !!. to Base 5 8 () ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 0 0 0 0 0 0 0 0 0 0 0 , Ġmint Layout . supply ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 6 , Ġmint Layout . decimals ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( mint Layout . isInitialized Ġ== Ġtrue ) ĊĠĠĠĠĠĠĠ ĠassertNull ( mint Layout . freeze Authority ) ĊĊĠĠĠĠĠĠĠ Ġval Ġserialized Ġ= Ġbor sh . serialize ( mint Layout ) ĊĠĠĠĠĠĠĠ Ġval Ġdeserialized Ġ= Ġbor sh . deserialize ( serialized , ĠM int :: class . java ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . mint Authority !!. to Base 5 8 (), Ġmint Layout . mint Authority !!. to Base 5 8 ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . supply , Ġmint Layout . supply ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . decimals , Ġmint Layout . decimals ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( de serialized . isInitialized Ġ== Ġmint Layout . isInitialized Ġ== Ġtrue ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . freeze Authority , Ġmint Layout . freeze Authority ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest De coding Account Info () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbor sh Ġ= Ġbor sh () ĊĠĠĠĠĠĠĠ Ġval Ġraw Data : ĠList < String > Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" B hr Z 0 FO HF Uh T ft 4 + J hh Jo 9 + 3 / QL 6 v HW y I 8 jk atu FP Qw C qm O zh zy 1 ve 5 l 2 Aq L 0 ott C Ch JZ 1 X SI W 3 k 3 C 7 Ta BQ n 7 a CG AQ AAAAAA AQ AA AO t 6 v ND Y dev C ba Gx ga Mz mz 7 y ox a Vu 3 q 9 v Ge Cc 7 yt ze Wq AQ AAAAAAAA AAAAAA AG Q AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAA A ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" base 6 4 " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġbuffer Ġ= ĠBuffer ( bor sh , Ġraw Data , ĠAccount Info :: class . java ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( buffer . value ) ĊĠĠĠĠĠĠĠ Ġval Ġaccount Info Ġ= Ġbuffer . value !! ĊĠĠĠĠĠĠĠ ĠassertEquals (" Qq CC v sh xt q MAL 2 C VAL qi JB 7 uE e E 5 mj SP sse Q d D zs RU o ", Ġaccount Info . mint . to Base 5 8 ()) ĊĠĠĠĠĠĠĠ ĠassertEquals (" BQ W WF hz B dw 2 v KK BU X 1 7 N He Fb Co FQ Hf R AR pd zt PE 2 t DJ ", Ġaccount Info . owner . to Base 5 8 ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" Gr D Mo eq ML F je XQ 2 4 H 5 6 S 1 RL g T 4 R 7 6 js u WC d 6 Sv Xy GP Q 5 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġaccount Info . delegate ?. to Base 5 8 () ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 0 , Ġaccount Info . deleg ated Amount ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġaccount Info . is Native ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġaccount Info . isInitialized ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġaccount Info . is Frozen ) ĊĠĠĠĠĠĠĠ ĠassertNull ( account Info . rent Ex empt Reserve ) ĊĠĠĠĠĠĠĠ ĠassertNull ( account Info . close Authority ) ĊĊĠĠĠĠĠĠĠ Ġval Ġserialized Ġ= Ġbor sh . serialize ( account Info ) ĊĊĠĠĠĠĠĠĠ Ġval Ġdeserialized Ġ= Ġbor sh . deserialize ( serialized , ĠAccount Info :: class . java ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . mint . to Base 5 8 (), Ġaccount Info . mint . to Base 5 8 ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . owner . to Base 5 8 (), Ġaccount Info . owner . to Base 5 8 ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . delegate ?. to Base 5 8 (), Ġaccount Info . delegate ?. to Base 5 8 ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . state , Ġaccount Info . state ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . is Native Option , Ġaccount Info . is Native Option ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . rent Ex empt Reserve , Ġaccount Info . rent Ex empt Reserve ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . is Native Raw , Ġaccount Info . is Native Raw ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . is Native , Ġaccount Info . is Native ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . isInitialized , Ġaccount Info . isInitialized ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . deleg ated Amount , Ġaccount Info . deleg ated Amount ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . isInitialized , Ġaccount Info . isInitialized ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . is Frozen , Ġaccount Info . is Frozen ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . close Authority , Ġaccount Info . close Authority ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest De coding Account Info 2 () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbor sh Ġ= Ġbor sh () ĊĠĠĠĠĠĠĠ Ġval Ġstring Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAA AAAA AQ AA AO t 6 v ND Y dev C ba Gx ga Mz mz 7 y ox a Vu 3 q 9 v Ge Cc 7 yt ze Wq ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" base 6 4 " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġbuffer Ġ= ĠBuffer ( bor sh , Ġstring , ĠAccount Info :: class . java ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( buffer . value ) ĊĠĠĠĠĠĠĠ Ġval Ġaccount Info Ġ= Ġbuffer . value !! ĊĊĠĠĠĠĠĠĠ ĠassertNull ( account Info . delegate ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġaccount Info . deleg ated Amount ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġaccount Info . isInitialized ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġaccount Info . is Native ) ĊĠĠĠĠĠĠĠ ĠassertNull ( account Info . rent Ex empt Reserve ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" Gr D Mo eq ML F je XQ 2 4 H 5 6 S 1 RL g T 4 R 7 6 js u WC d 6 Sv Xy GP Q 5 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġaccount Info . close Authority ?. to Base 5 8 () ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġstring 2 Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA Ag AAAAAAAAAAAAAAAA AAAAAAAA AA AQ AA AO t 6 v ND Y dev C ba Gx ga Mz mz 7 y ox a Vu 3 q 9 v Ge Cc 7 yt ze Wq ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" base 6 4 " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġbuffer 2 Ġ= ĠBuffer ( bor sh , Ġstring 2 , ĠAccount Info :: class . java ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( buffer . value ) ĊĠĠĠĠĠĠĠ Ġval Ġaccount Info 2 Ġ= Ġbuffer 2 . value !! ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġaccount Info 2 . is Frozen ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest De coding Token Swap () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbor sh Ġ= Ġbor sh () ĊĠĠĠĠĠĠĠ Ġval Ġstring Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" AQ H / Bt 3 2 4 dd lo ZP Zy + FG z ut 5 r By 0 he 1 fW ze RO oz 1 h X 7 / AK n PP nm V df 8 V ef ed p PO l 3 xy 2 V / o + Y v TT + f / dj / 1 bl p 9 D 9 l I + 9 w 6 7 a Ll O 5 X 6 d S FP B 7 W kh vy P + 7 1 Ax ES Xk 7 Qw 9 ny Y EY H 7 t 0 U am k Bl Pr ll Rf jn Q 9 h + sx / GQ Ho BS 4 Ab WP pi 2 + m 5 d Bu ym mu Z ey di I 9 1 a VN // 6 k R 8 bk 4 cz K nv SX u 1 WX NW 4 hw abi Ff + q 4 GE + 2 h / Y 0 YY w DX ax D nc G us 7 V Z ig 8 AAAA AAB 1 UBY 8 w cry pv zu co 4 dv 7 UU UR t 8 t 9 MO pn q 7 Yn ff B 1 O ov k Z AAAAAAAA AB An AAAA AAA AB Q AAAAAAAA AQ Jw AAAAAAAAAAAAAAAA AAAAAAAA AAAA AU AAAAAAAA AG Q AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAA A ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" base 6 4 " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġtoken Swap Info Bor sh Ġ= ĠBuffer ( bor sh , Ġstring , ĠToken Swap Info :: class . java ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( token Swap Info Bor sh . value ) ĊĠĠĠĠĠĠĠ Ġval Ġtoken Swap Info Ġ= Ġtoken Swap Info Bor sh . value !! ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġtoken Swap Info . version ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" Token ke g Q fe Z yi Nw AJ b Nb G KP FX CW u B vf 9 Ss 6 2 3 VQ 5 DA ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtoken Swap Info . token Program Id . to Base 5 8 () ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 7 G 9 3 K AM R 8 b L q 5 T vg LH mp ACL X CY w D cdt X VB Ks N 5 Fx 4 1 i N ", Ġtoken Swap Info . mint A . to Base 5 8 ()) ĊĠĠĠĠĠĠĠ ĠassertEquals (" So 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 ", Ġtoken Swap Info . mint B . to Base 5 8 ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġtoken Swap Info . curve Type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( token Swap Info . isInitialized , Ġtrue ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ", Ġtoken Swap Info . pay er . to Base 5 8 ()) ĊĊĠĠĠĠĠĠĠ Ġval Ġserialized Ġ= Ġbor sh . serialize ( token Swap Info ) ĊĠĠĠĠĠĠĠ Ġval Ġdeserialized Ġ= Ġbor sh . deserialize ( serialized , ĠToken Swap Info :: class . java ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . version , Ġtoken Swap Info . version ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdeserialized . token Program Id . to Base 5 8 (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtoken Swap Info . token Program Id . to Base 5 8 () ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . mint A . to Base 5 8 (), Ġtoken Swap Info . mint A . to Base 5 8 ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . mint B . to Base 5 8 (), Ġtoken Swap Info . mint B . to Base 5 8 ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . curve Type , Ġtoken Swap Info . curve Type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . isInitialized , Ġtoken Swap Info . isInitialized ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( de serialized . pay er . to Base 5 8 (), Ġtoken Swap Info . pay er . to Base 5 8 ()) ĊĠĠĠ Ġ} Ċ }