diff --git a/packages/lisk-transactions/src/utils/validation/validation.ts b/packages/lisk-transactions/src/utils/validation/validation.ts index baf39fbe7..d3cbfa003 100644 --- a/packages/lisk-transactions/src/utils/validation/validation.ts +++ b/packages/lisk-transactions/src/utils/validation/validation.ts @@ -68,7 +68,7 @@ export const validateKeysgroup = (keysgroup: ReadonlyArray) => { const MIN_ADDRESS_LENGTH = 2; const MAX_ADDRESS_LENGTH = 22; const BASE_TEN = 10; -export const validateAddress = (address: string) => { +export const validateAddress = (address: string): boolean => { if ( address.length < MIN_ADDRESS_LENGTH || address.length > MAX_ADDRESS_LENGTH @@ -100,7 +100,9 @@ export const validateAddress = (address: string) => { } if (addressString !== addressNumber.toString(BASE_TEN)) { - throw new Error('Address number does not have natural representation.'); + throw new Error( + "Address string format does not match it's number representation.", + ); } return true; diff --git a/packages/lisk-transactions/test/utils/validation/validation.ts b/packages/lisk-transactions/test/utils/validation/validation.ts index a5c14a2ad..f27db13d0 100644 --- a/packages/lisk-transactions/test/utils/validation/validation.ts +++ b/packages/lisk-transactions/test/utils/validation/validation.ts @@ -183,7 +183,7 @@ describe('validation', () => { '922fbfdd596fa78269bbcadc67ec2a1cc15fc929a19c462169568d7a3df1a1aa', '922fbfdd596fa78269bbcadc67ec2a1cc15fc929a19c462169568d7a3df1a1aa', ]; - it('should throw', () => { + it('should throw an error', () => { return expect( checkPublicKeysForDuplicates.bind(null, publicKeys), ).to.throw( @@ -210,60 +210,55 @@ describe('validation', () => { describe('Given an address that is too short', () => { const address = 'L'; - const error = - 'Address length does not match requirements. Expected between 2 and 22 characters.'; - - it('should throw', () => { - return expect(validateAddress.bind(null, address)).to.throw(error); + it('should throw an error', () => { + return expect(validateAddress.bind(null, address)).to.throw( + 'Address length does not match requirements. Expected between 2 and 22 characters.', + ); }); }); describe('Given an address that is too long', () => { const address = '12345678901234567890123L'; - const error = - 'Address length does not match requirements. Expected between 2 and 22 characters.'; - - it('should throw', () => { - return expect(validateAddress.bind(null, address)).to.throw(error); + it('should throw an error', () => { + return expect(validateAddress.bind(null, address)).to.throw( + 'Address length does not match requirements. Expected between 2 and 22 characters.', + ); }); }); describe('Given an address without L at the end', () => { const address = '1234567890'; - const error = - 'Address format does not match requirements. Expected "L" at the end.'; - - it('should throw', () => { - return expect(validateAddress.bind(null, address)).to.throw(error); + it('should throw an error', () => { + return expect(validateAddress.bind(null, address)).to.throw( + 'Address format does not match requirements. Expected "L" at the end.', + ); }); }); describe('Given an address that includes `.`', () => { const address = '14.15133512790761431L'; - const error = - 'Address format does not match requirements. Address includes invalid character: `.`.'; - - it('should throw', () => { - return expect(validateAddress.bind(null, address)).to.throw(error); + it('should throw an error', () => { + return expect(validateAddress.bind(null, address)).to.throw( + 'Address format does not match requirements. Address includes invalid character: `.`.', + ); }); }); describe('Given an address that is out of range', () => { const address = '18446744073709551616L'; - const error = - 'Address format does not match requirements. Address out of maximum range.'; - - it('should throw', () => { - return expect(validateAddress.bind(null, address)).to.throw(error); + it('should throw an error', () => { + return expect(validateAddress.bind(null, address)).to.throw( + 'Address format does not match requirements. Address out of maximum range.', + ); }); }); describe('Given an address that has leading zeros', () => { const address = '00015133512790761431L'; - const error = 'Address number does not have natural representation.'; - - it('should throw', () => { - return expect(validateAddress.bind(null, address)).to.throw(error); + it('should throw an error', () => { + return expect(validateAddress.bind(null, address)).to.throw( + "Address string format does not match it's number representation.", + ); }); }); });