@@ -97,5 +97,64 @@ describe('Account', () => {
9797 expect ( publicAccount . verifySignature ( '0xAA' , signed ) )
9898 . to . be . true ;
9999 } ) ;
100+
101+ it ( 'hexa without 0x previx' , ( ) => {
102+ const account = Account . createFromPrivateKey (
103+ 'AB860ED1FE7C91C02F79C02225DAC708D7BD13369877C1F59E678CC587658C47' ,
104+ NetworkType . MIJIN_TEST ,
105+ ) ;
106+ const publicAccount = account . publicAccount ;
107+ const signed = account . signData ( '66128B29E8197352A2FEB51B50CF5D02F1D05B20D44B3F7953B98ACD2BCA15D4' ) ;
108+ expect ( publicAccount . verifySignature ( '66128B29E8197352A2FEB51B50CF5D02F1D05B20D44B3F7953B98ACD2BCA15D4' , signed ) )
109+ . to . be . true ;
110+ } ) ;
111+
112+ it ( 'hexa without 0x previx should be the same as with 0x' , ( ) => {
113+ const account = Account . createFromPrivateKey (
114+ 'AB860ED1FE7C91C02F79C02225DAC708D7BD13369877C1F59E678CC587658C47' ,
115+ NetworkType . MIJIN_TEST ,
116+ ) ;
117+ const publicAccount = account . publicAccount ;
118+ const signed = account . signData ( 'AA' ) ;
119+ const signedWith0x = account . signData ( '0xAA' ) ;
120+ expect ( publicAccount . verifySignature ( 'AA' , signed ) )
121+ . to . be . true ;
122+ expect ( publicAccount . verifySignature ( '0xAA' , signedWith0x ) )
123+ . to . be . true ;
124+ } ) ;
125+
126+ it ( 'hexa without 0x previx should be the same as with 0x' , ( ) => {
127+ const account = Account . createFromPrivateKey (
128+ 'AB860ED1FE7C91C02F79C02225DAC708D7BD13369877C1F59E678CC587658C47' ,
129+ NetworkType . MIJIN_TEST ,
130+ ) ;
131+ const publicAccount = account . publicAccount ;
132+ const signed = account . signData ( 'ff60983e0c5d21d2fb83c67598d560f3cf0e28ae667b5616aaa58a059666cd8cf826b026243c92cf' ) ;
133+ const signedWith0x =
134+ account . signData ( '0xff60983e0c5d21d2fb83c67598d560f3cf0e28ae667b5616aaa58a059666cd8cf826b026243c92cf' ) ;
135+ expect (
136+ publicAccount
137+ . verifySignature ( 'ff60983e0c5d21d2fb83c67598d560f3cf0e28ae667b5616aaa58a059666cd8cf826b026243c92cf' , signed ) )
138+ . to . be . true ;
139+ expect ( publicAccount
140+ . verifySignature ( '0xff60983e0c5d21d2fb83c67598d560f3cf0e28ae667b5616aaa58a059666cd8cf826b026243c92cf' , signedWith0x ) )
141+ . to . be . true ;
142+ } ) ;
143+
144+ it ( 'sign empty' , ( ) => {
145+ const account = Account . createFromPrivateKey (
146+ 'AB860ED1FE7C91C02F79C02225DAC708D7BD13369877C1F59E678CC587658C47' ,
147+ NetworkType . MIJIN_TEST ,
148+ ) ;
149+ const publicAccount = account . publicAccount ;
150+ const signed = account . signData ( '' ) ;
151+ const signedWith0x = account . signData ( '0x' ) ;
152+ expect (
153+ publicAccount . verifySignature ( '' , signed ) )
154+ . to . be . true ;
155+ expect ( publicAccount
156+ . verifySignature ( '0x' , signedWith0x ) )
157+ . to . be . true ;
158+ } ) ;
100159 } ) ;
101160} ) ;
0 commit comments