@@ -32,6 +32,12 @@ describe('Hash128', function () {
3232 new Error ( 'Invalid Hash length 17' ) ,
3333 )
3434 } )
35+
36+ it ( `throws when constructed from non-hexadecimal string` , ( ) => {
37+ expect ( ( ) => Hash128 . from ( 'Z' . repeat ( 32 ) ) ) . toThrow (
38+ new Error ( 'Invalid hash string ' + 'Z' . repeat ( 32 ) ) ,
39+ )
40+ } )
3541} )
3642describe ( 'Hash160' , function ( ) {
3743 it ( 'has a static width member' , function ( ) {
@@ -56,6 +62,12 @@ describe('Hash160', function () {
5662 Hash160 . from ( '100000000000000000000000000000000000000000' ) ,
5763 ) . toThrow ( new Error ( 'Invalid Hash length 21' ) )
5864 } )
65+
66+ it ( `throws when constructed from non-hexadecimal string` , ( ) => {
67+ expect ( ( ) => Hash160 . from ( 'Z' . repeat ( 40 ) ) ) . toThrow (
68+ new Error ( 'Invalid hash string ' + 'Z' . repeat ( 40 ) ) ,
69+ )
70+ } )
5971} )
6072
6173describe ( 'Hash192' , function ( ) {
@@ -83,6 +95,12 @@ describe('Hash192', function () {
8395 Hash192 . from ( '10000000000000000000000000000000000000000000000000' ) ,
8496 ) . toThrow ( new Error ( 'Invalid Hash length 25' ) )
8597 } )
98+
99+ it ( `throws when constructed from non-hexadecimal string` , ( ) => {
100+ expect ( ( ) => Hash192 . from ( 'Z' . repeat ( 48 ) ) ) . toThrow (
101+ new Error ( 'Invalid hash string ' + 'Z' . repeat ( 48 ) ) ,
102+ )
103+ } )
86104} )
87105
88106describe ( 'Hash256' , function ( ) {
@@ -105,6 +123,12 @@ describe('Hash256', function () {
105123 expect ( h . nibblet ( 4 ) ) . toBe ( 0x0b )
106124 expect ( h . nibblet ( 5 ) ) . toBe ( 0xd )
107125 } )
126+
127+ it ( `throws when constructed from non-hexadecimal string` , ( ) => {
128+ expect ( ( ) => Hash256 . from ( 'Z' . repeat ( 64 ) ) ) . toThrow (
129+ new Error ( 'Invalid hash string ' + 'Z' . repeat ( 64 ) ) ,
130+ )
131+ } )
108132} )
109133
110134describe ( 'Currency' , function ( ) {
0 commit comments