@@ -47,6 +47,26 @@ describe('MosaicNonce', () => {
47
47
deepEqual ( nonce . toDTO ( ) , 0 ) ;
48
48
} ) ;
49
49
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
+
50
70
describe ( 'toHex()' , ( ) => {
51
71
it ( 'should return string value of nonce' , ( ) => {
52
72
const nonce = new MosaicNonce ( new Uint8Array ( [ 0x0 , 0x0 , 0x0 , 0x0 ] ) ) ;
0 commit comments