fix(api): XDPoS_getRewardByAccount to be able to parse scientific notation - #2301
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
b651aa1 to
1b2b078
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes the XDPoS_getRewardByAccount reward parsing path to handle reward values encoded in JSON using scientific notation, and adds unit tests to validate the conversion behavior.
Changes:
- Added
jsonNumberToBigIntto convertjson.Numbervalues that may be in scientific notation into*big.Int. - Updated reward extraction logic to use the new conversion helper instead of
big.Int.SetString. - Added unit tests covering integer, scientific-notation, and invalid-number inputs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| consensus/XDPoS/api.go | Adds jsonNumberToBigInt and wires it into reward parsing for masternode/protector/observer reward fields. |
| consensus/XDPoS/api_test.go | Adds unit tests for jsonNumberToBigInt and imports encoding/json. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7894a0f to
48edd5c
Compare
…ion in json file added unit tests formatting
48edd5c to
1777b00
Compare
Proposed changes
fix api XDPoS_getRewardByAccount to be able to parse scientific not
added unit tests
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which parts of the codebase does this PR touch?
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that