@@ -12,7 +12,11 @@ import { padU32 } from '../util/pad';
1212
1313describe ( 'decoder/Decoder' , ( ) => {
1414 const stringToBytes = function ( str : string ) {
15- return str . match ( / .{ 1 , 2 } / g) . map ( code => parseInt ( code , 16 ) ) ;
15+ const matches = str . match ( / .{ 1 , 2 } / g) ;
16+ if ( ! matches ) {
17+ throw new Error ( 'stringToBytes: mo matches' ) ;
18+ }
19+ return matches . map ( code => parseInt ( code , 16 ) ) ;
1620 } ;
1721
1822 const address1 =
@@ -118,9 +122,9 @@ describe('decoder/Decoder', () => {
118122
119123 describe ( 'decodeParam' , ( ) => {
120124 it ( 'throws an error on non ParamType param' , ( ) => {
121- expect ( ( ) => Decoder . decodeParam ( { } as ParamType , undefined , undefined ) ) . toThrow (
122- / P a r a m T y p e /
123- ) ;
125+ expect ( ( ) =>
126+ Decoder . decodeParam ( { } as ParamType , undefined , undefined )
127+ ) . toThrow ( / P a r a m T y p e / ) ;
124128 } ) ;
125129
126130 it ( 'throws an error on invalid param type' , ( ) => {
@@ -172,8 +176,11 @@ describe('decoder/Decoder', () => {
172176
173177 it ( 'decodes fixedBytes' , ( ) => {
174178 expect (
175- Decoder . decodeParam ( new ParamType ( 'fixedBytes' , null , 2 ) , [ bytes1 ] , 0 )
176- . token
179+ Decoder . decodeParam (
180+ new ParamType ( 'fixedBytes' , undefined , 2 ) ,
181+ [ bytes1 ] ,
182+ 0
183+ ) . token
177184 ) . toEqual ( tokenFixedBytes1 ) ;
178185 } ) ;
179186
@@ -209,10 +216,14 @@ describe('decoder/Decoder', () => {
209216
210217 it ( 'decodes string (indexed)' , ( ) => {
211218 expect (
212- Decoder . decodeParam ( new ParamType ( 'string' , null , 0 , true ) , [ bytes1 ] , 0 )
219+ Decoder . decodeParam (
220+ new ParamType ( 'string' , undefined , 0 , true ) ,
221+ [ bytes1 ] ,
222+ 0
223+ )
213224 ) . toEqual (
214225 Decoder . decodeParam (
215- new ParamType ( 'fixedBytes' , null , 32 , true ) ,
226+ new ParamType ( 'fixedBytes' , undefined , 32 , true ) ,
216227 [ bytes1 ] ,
217228 0
218229 )
@@ -222,7 +233,7 @@ describe('decoder/Decoder', () => {
222233
223234 describe ( 'decode' , ( ) => {
224235 it ( 'throws an error on invalid params' , ( ) => {
225- expect ( ( ) => Decoder . decode ( null , '123' ) ) . toThrow ( / a r r a y / ) ;
236+ expect ( ( ) => Decoder . decode ( undefined , '123' ) ) . toThrow ( / a r r a y / ) ;
226237 } ) ;
227238
228239 describe ( 'address' , ( ) => {
@@ -300,7 +311,10 @@ describe('decoder/Decoder', () => {
300311 describe ( 'fixedBytes' , ( ) => {
301312 it ( 'decodes fixedBytes' , ( ) => {
302313 expect (
303- Decoder . decode ( [ new ParamType ( 'fixedBytes' , null , 2 ) ] , `${ bytes1 } ` )
314+ Decoder . decode (
315+ [ new ParamType ( 'fixedBytes' , undefined , 2 ) ] ,
316+ `${ bytes1 } `
317+ )
304318 ) . toEqual ( [ tokenFixedBytes1 ] ) ;
305319 } ) ;
306320 } ) ;
0 commit comments