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

Incorrect MIN_SINT32 constant in lisk validator #8976

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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