Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Incorrect MIN_SINT32 constant in lisk validator (#8976)
Browse files Browse the repository at this point in the history
Update constant
  • Loading branch information
Incede authored Sep 14, 2023
1 parent 4f88fb8 commit e3a31ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions elements/lisk-validator/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
*
*/

export const MAX_SINT32 = 2147483647; // (2 ** (32 - 1)) + 1 * -1
export const MIN_SINT32 = MAX_SINT32 * -1; // ((2 ** (32 - 1)) - 1) * -1
export const MAX_SINT32 = 2147483647; // (2 ** (32 - 1)) - 1
export const MIN_SINT32 = MAX_SINT32 * -1 - 1; // (2 ** (32 - 1)) * -1
export const MAX_UINT32 = 4294967295; // (2 ** 32) - 1
export const MAX_UINT64 = BigInt('18446744073709551615'); // BigInt((2 ** 64) - 1) - 1
export const MAX_SINT64 = BigInt('9223372036854775807'); // BigInt(2 ** (64 - 1) - 1) -1
export const MIN_SINT64 = MAX_SINT64 * BigInt(-1) - BigInt(1); // (BigInt(2 ** (64 - 1) - 1) -1) * BigInt(-1)
export const MAX_UINT64 = BigInt('18446744073709551615'); // BigInt((2 ** 64) - 1) - BigInt(1)
export const MAX_SINT64 = BigInt('9223372036854775807'); // BigInt(2 ** (64 - 1) - 1) - BigInt(1)
export const MIN_SINT64 = MAX_SINT64 * BigInt(-1) - BigInt(1); // BigInt(2 ** (64 - 1)) * BigInt(-1)
4 changes: 2 additions & 2 deletions elements/lisk-validator/test/validation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ describe('validation', () => {
return expect(isSInt32(2147483648)).toBeFalse();
});

it('should return false when a number "-2147483648" which is just below the limit of sint32', () => {
return expect(isSInt32(-2147483648)).toBeFalse();
it('should return false when a number "-2147483649" which is just below the limit of sint32', () => {
return expect(isSInt32(-2147483649)).toBeFalse();
});

it('should return true when a valid number was provided', () => {
Expand Down

0 comments on commit e3a31ab

Please sign in to comment.