FhenixProtocol / fhenix.js

The JavaScript SDK for Fhenix
https://fhenixjs.fhenix.zone/
Other
2 stars 1 forks source link

Fix `bytesToNumber()` #1

Closed assafmo closed 8 months ago

assafmo commented 8 months ago

This fixes bytesToNumber() to always return the result as an unsigned integer.

Example: byteArray holds the value 2^32 - 3, which is 11111111111111111111111111111101 in binary. The old implementation uses the number type, which is a signed integer, to calculate intermediate values. And because the most significant bit (MSB) is turned on, it interprets this as a negative number and returns -3.

github-actions[bot] commented 8 months ago

Coverage report

St.:grey_question:
Category Percentage Covered / Total
🟒 Statements
86.42% (-0.08% πŸ”»)
140/162
🟒 Branches 80% 36/45
🟒 Functions 93.33% 28/30
🟒 Lines 88.37% 114/129
Show files with reduced coverage πŸ”»
|
St.:grey_question:
| File | Statements | Branches | Functions | Lines | | :----------------------------------------------------------------------------------------------------------------------------------------------------: | :------- | :------------------------------------------------------------ | :------- | :-------- | :---- | | 🟒 | utils.ts |
96.77% (-0.1% πŸ”»)
| 50% | 100% | 100% |

Test suite run success

18 tests passing in 4 suites.

Report generated by πŸ§ͺjest coverage report action from 58992f4b6145bd1341eee08c9391f2434d105db5