@@ -47,6 +47,26 @@ describe('MosaicNonce', () => {
4747 deepEqual ( nonce . toDTO ( ) , 0 ) ;
4848 } ) ;
4949
50+ it ( 'should create nonce from hexadecimal notation throw exception' , ( ) => {
51+ expect ( ( ) => {
52+ MosaicNonce . createFromHex ( '111100000000' ) ;
53+ } ) . to . throw ( Error , 'Expected 4 bytes for Nonce and got ' + '111100000000' . length + ' instead.' ) ;
54+ } ) ;
55+
56+ it ( 'should create nonce from hexadecimal notation with uint32 input - 0 value' , ( ) => {
57+ const nonce = MosaicNonce . createFromHex ( ( 0 ) . toString ( 16 ) ) ;
58+ expect ( nonce . nonce ) . to . not . be . null ;
59+ deepEqual ( nonce . nonce , new Uint8Array ( [ 0x0 , 0x0 , 0x0 , 0x0 ] ) ) ;
60+ deepEqual ( nonce . toDTO ( ) , 0 ) ;
61+ } ) ;
62+
63+ it ( 'should create nonce from hexadecimal notation with uint32 input' , ( ) => {
64+ const nonce = MosaicNonce . createFromHex ( ( 11 ) . toString ( 16 ) ) ;
65+ expect ( nonce . nonce ) . to . not . be . null ;
66+ deepEqual ( nonce . nonce , new Uint8Array ( [ 0 , 0 , 0 , 11 ] ) ) ;
67+ deepEqual ( nonce . toDTO ( ) , 184549376 ) ;
68+ } ) ;
69+
5070 describe ( 'toHex()' , ( ) => {
5171 it ( 'should return string value of nonce' , ( ) => {
5272 const nonce = new MosaicNonce ( new Uint8Array ( [ 0x0 , 0x0 , 0x0 , 0x0 ] ) ) ;
0 commit comments