@@ -10,8 +10,11 @@ import { BytesReader } from '../src/bytesReader';
1010import  { 
1111  bufferCV , 
1212  BufferCV , 
13+   clarityByteToType , 
1314  ClarityType , 
15+   clarityTypeToByte , 
1416  ClarityValue , 
17+   ClarityWireType , 
1518  contractPrincipalCV , 
1619  contractPrincipalCVFromStandard , 
1720  deserializeCV , 
@@ -708,4 +711,71 @@ describe('Clarity Types', () => {
708711      intTest ;  // avoid the "value is never read warning" 
709712    } ) ; 
710713  } ) ; 
714+ 
715+   describe ( 'Clarity type wire format' ,  ( )  =>  { 
716+     test ( clarityTypeToByte . name ,  ( )  =>  { 
717+       expect ( clarityTypeToByte ( ClarityType . Int ) ) . toEqual ( 0x00 ) ; 
718+       expect ( clarityTypeToByte ( ClarityType . Int ) ) . toEqual ( ClarityWireType . int ) ; 
719+ 
720+       expect ( clarityTypeToByte ( ClarityType . UInt ) ) . toEqual ( 0x01 ) ; 
721+       expect ( clarityTypeToByte ( ClarityType . UInt ) ) . toEqual ( ClarityWireType . uint ) ; 
722+ 
723+       expect ( clarityTypeToByte ( ClarityType . Buffer ) ) . toEqual ( 0x02 ) ; 
724+       expect ( clarityTypeToByte ( ClarityType . Buffer ) ) . toEqual ( ClarityWireType . buffer ) ; 
725+ 
726+       expect ( clarityTypeToByte ( ClarityType . BoolTrue ) ) . toEqual ( 0x03 ) ; 
727+       expect ( clarityTypeToByte ( ClarityType . BoolTrue ) ) . toEqual ( ClarityWireType . true ) ; 
728+ 
729+       expect ( clarityTypeToByte ( ClarityType . BoolFalse ) ) . toEqual ( 0x04 ) ; 
730+       expect ( clarityTypeToByte ( ClarityType . BoolFalse ) ) . toEqual ( ClarityWireType . false ) ; 
731+ 
732+       expect ( clarityTypeToByte ( ClarityType . PrincipalStandard ) ) . toEqual ( 0x05 ) ; 
733+       expect ( clarityTypeToByte ( ClarityType . PrincipalStandard ) ) . toEqual ( ClarityWireType . address ) ; 
734+ 
735+       expect ( clarityTypeToByte ( ClarityType . PrincipalContract ) ) . toEqual ( 0x06 ) ; 
736+       expect ( clarityTypeToByte ( ClarityType . PrincipalContract ) ) . toEqual ( ClarityWireType . contract ) ; 
737+ 
738+       expect ( clarityTypeToByte ( ClarityType . ResponseOk ) ) . toEqual ( 0x07 ) ; 
739+       expect ( clarityTypeToByte ( ClarityType . ResponseOk ) ) . toEqual ( ClarityWireType . ok ) ; 
740+ 
741+       expect ( clarityTypeToByte ( ClarityType . ResponseErr ) ) . toEqual ( 0x08 ) ; 
742+       expect ( clarityTypeToByte ( ClarityType . ResponseErr ) ) . toEqual ( ClarityWireType . err ) ; 
743+ 
744+       expect ( clarityTypeToByte ( ClarityType . OptionalNone ) ) . toEqual ( 0x09 ) ; 
745+       expect ( clarityTypeToByte ( ClarityType . OptionalNone ) ) . toEqual ( ClarityWireType . none ) ; 
746+ 
747+       expect ( clarityTypeToByte ( ClarityType . OptionalSome ) ) . toEqual ( 0x0a ) ; 
748+       expect ( clarityTypeToByte ( ClarityType . OptionalSome ) ) . toEqual ( ClarityWireType . some ) ; 
749+ 
750+       expect ( clarityTypeToByte ( ClarityType . List ) ) . toEqual ( 0x0b ) ; 
751+       expect ( clarityTypeToByte ( ClarityType . List ) ) . toEqual ( ClarityWireType . list ) ; 
752+ 
753+       expect ( clarityTypeToByte ( ClarityType . Tuple ) ) . toEqual ( 0x0c ) ; 
754+       expect ( clarityTypeToByte ( ClarityType . Tuple ) ) . toEqual ( ClarityWireType . tuple ) ; 
755+ 
756+       expect ( clarityTypeToByte ( ClarityType . StringASCII ) ) . toEqual ( 0x0d ) ; 
757+       expect ( clarityTypeToByte ( ClarityType . StringASCII ) ) . toEqual ( ClarityWireType . ascii ) ; 
758+ 
759+       expect ( clarityTypeToByte ( ClarityType . StringUTF8 ) ) . toEqual ( 0x0e ) ; 
760+       expect ( clarityTypeToByte ( ClarityType . StringUTF8 ) ) . toEqual ( ClarityWireType . utf8 ) ; 
761+     } ) ; 
762+ 
763+     test ( clarityByteToType . name ,  ( )  =>  { 
764+       expect ( clarityByteToType ( 0x00 ) ) . toEqual ( ClarityType . Int ) ; 
765+       expect ( clarityByteToType ( 0x01 ) ) . toEqual ( ClarityType . UInt ) ; 
766+       expect ( clarityByteToType ( 0x02 ) ) . toEqual ( ClarityType . Buffer ) ; 
767+       expect ( clarityByteToType ( 0x03 ) ) . toEqual ( ClarityType . BoolTrue ) ; 
768+       expect ( clarityByteToType ( 0x04 ) ) . toEqual ( ClarityType . BoolFalse ) ; 
769+       expect ( clarityByteToType ( 0x05 ) ) . toEqual ( ClarityType . PrincipalStandard ) ; 
770+       expect ( clarityByteToType ( 0x06 ) ) . toEqual ( ClarityType . PrincipalContract ) ; 
771+       expect ( clarityByteToType ( 0x07 ) ) . toEqual ( ClarityType . ResponseOk ) ; 
772+       expect ( clarityByteToType ( 0x08 ) ) . toEqual ( ClarityType . ResponseErr ) ; 
773+       expect ( clarityByteToType ( 0x09 ) ) . toEqual ( ClarityType . OptionalNone ) ; 
774+       expect ( clarityByteToType ( 0x0a ) ) . toEqual ( ClarityType . OptionalSome ) ; 
775+       expect ( clarityByteToType ( 0x0b ) ) . toEqual ( ClarityType . List ) ; 
776+       expect ( clarityByteToType ( 0x0c ) ) . toEqual ( ClarityType . Tuple ) ; 
777+       expect ( clarityByteToType ( 0x0d ) ) . toEqual ( ClarityType . StringASCII ) ; 
778+       expect ( clarityByteToType ( 0x0e ) ) . toEqual ( ClarityType . StringUTF8 ) ; 
779+     } ) ; 
780+   } ) ; 
711781} ) ; 
0 commit comments