test: cover ContractCallLocal fee calculation for out-of-range gas values - #26947
Open
ruslanvelkov-beep wants to merge 1 commit into
Open
Conversation
…lues Signed-off-by: Ruslan Velkov <ruslan.velkov@limechain.tech>
ruslanvelkov-beep
requested review from
a team and
tinker-michaelj
as code owners
August 24, 2026 14:03
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #26947 +/- ##
=========================================
Coverage 70.50% 70.50%
Complexity 11690 11690
=========================================
Files 2586 2586
Lines 108469 108469
Branches 12142 12141 -1
=========================================
+ Hits 76474 76475 +1
+ Misses 28015 28013 -2
- Partials 3980 3981 +1 see 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
✅ All tests passed ✅🏷️ Commit: 6815c65 Learn more about TestLens at testlens.app/docs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds unit-test coverage for
ContractCallLocalFeeCalculatorfee calculation at theboundary gas values, pinning down that the query-fee arithmetic is sign- and
overflow-safe for a client-supplied
gas.accumulateNodePaymentforwards the query'sgasinto the shared extra-fee accumulation(
FeeResult.addServiceExtraFeeTinycents), which clamps the billable count withMath.max(0, used - included)and accumulates it with the saturatingclampedMultiply/clampedAddhelpers. The existing tests only exercisedgas = 0and a small positivevalue, leaving the sign/overflow edges uncovered.
Tests added (no production code changed)
ContractServiceFeeCalculatorsTest:testContractCallLocalWithNegativeGasChargesBaseFeeOnly— a negativegasclamps theextra count to zero, so only the base fee is charged (no negative extra fee).
testContractCallLocalWithMaxGasSaturatesInsteadOfWrapping— aLong.MAX_VALUEgassaturates via
clampedMultiply/clampedAdd(fee overcharges) rather than wrapping into anegative or undercharged value.
Both assert exact totals against the test fee schedule, so a future change that reintroduced
raw (wrapping) arithmetic or dropped the negative-clamp would fail these tests.
Related issue(s)
N/A