Skip to content

sub - #97

Merged
thedavidmeister merged 2 commits into
mainfrom
2025-08-11-max-sub-1
Aug 11, 2025
Merged

sub#97
thedavidmeister merged 2 commits into
mainfrom
2025-08-11-max-sub-1

Conversation

@thedavidmeister

@thedavidmeisterthedavidmeister commented Aug 11, 2025

Copy link
Copy Markdown
Contributor

Motivation

Solution

Checks

By submitting this for review, I'm confirming I've done the following:

  • made this PR as small as possible
  • unit-tested any new functionality
  • linked any relevant issues or PRs
  • included screenshots (if this involves a front-end change)

Summary by CodeRabbit

  • Tests

    • Added an edge-case subtraction test covering extreme values to strengthen reliability.
    • Centralized assertion logic via a helper to improve consistency and maintainability.
    • Expanded coverage for subtraction scenarios.
  • Chores

    • Updated gas usage snapshot with minor metric shifts and a new entry.
    • No changes to user-facing behavior.

@coderabbitai

coderabbitaiBot commented Aug 11, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds an internal test helper and a new external pure test (testSubOneFromMax) for LibDecimalFloatImplementation subtraction edge-case, and updates the gas snapshot with a new entry and minor metric shifts. No production code or public API changes.

Changes

Cohort / File(s)Summary
Gas snapshot update
./.gas-snapshot
Updated gas metrics for existing subtraction tests; added new entry testSubOneFromMax with gas 5460 and small μ shifts for other subtraction tests.
Tests: LibDecimalFloatImplementation subtraction
test/src/lib/implementation/LibDecimalFloatImplementation.sub.t.sol
Added internal helper checkSub to centralize assertions and added external pure test testSubOneFromMax() to verify subtracting 1 from max int224 coefficient at max int32 exponent yields normalized coefficient/exponent.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 2025-08-11-max-sub-1

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2f4c606 and 7f643e2.

📒 Files selected for processing (2)
  • .gas-snapshot (1 hunks)
  • test/src/lib/implementation/LibDecimalFloatImplementation.sub.t.sol (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: rainix (ubuntu-latest, rainix-rs-static)
  • GitHub Check: rainix (ubuntu-latest, test-wasm-build)
  • GitHub Check: rainix (ubuntu-latest, rainix-sol-static)
  • GitHub Check: rainix (ubuntu-latest, rainix-rs-test)
  • GitHub Check: rainix (ubuntu-latest, rainix-sol-test)
  • GitHub Check: rainix (macos-latest, rainix-rs-test)
  • GitHub Check: git-clean
🔇 Additional comments (2)
.gas-snapshot (1)

198-200: Gas snapshot updates look consistent with new test coverage

New entry for testSubOneFromMax and minor μ shifts for adjacent tests are expected. No action needed.

test/src/lib/implementation/LibDecimalFloatImplementation.sub.t.sol (1)

64-66: Solid edge-case coverage: subtracting 1 from max exponent/value path

Expectation aligns with normalization (shift exponent by 8, scale coefficient by 1e8). LGTM.

…t.sol
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
test/src/lib/implementation/LibDecimalFloatImplementation.sub.t.sol (2)

60-61: Assertion messages added — thanks

This addresses the earlier nit about adding messages to assertEq for quicker diagnosis.


64-66: Clarify the “8-digit” normalization to avoid magic numbers

Add a short comment explaining why normalization is 8 digits here. Optionally, factor 1e8 and 8 into local constants to keep the test resilient if the normalization granularity changes.

- function testSubOneFromMax() external pure {- checkSub(type(int224).max, type(int32).max, 1, 0, int256(type(int224).max) * 1e8, type(int32).max - 8);- }+ function testSubOneFromMax() external pure {+ // Sub normalization shifts exponent by 8 and scales coefficient by 1e8 for this boundary case.+ // This documents the expected normalization granularity to avoid confusion over the magic number "8".+ checkSub(type(int224).max, type(int32).max, 1, 0, int256(type(int224).max) * 1e8, type(int32).max - 8);+ }

Optionally define local constants at the top of the test contract and use them here:

// Optional: make normalization explicit in testsint256constant NORMALIZATION_DIGITS =8;
int256constant NORMALIZATION_SCALE =1e8;

Then:

- checkSub(type(int224).max, type(int32).max, 1, 0, int256(type(int224).max) * 1e8, type(int32).max - 8);+ checkSub(+ type(int224).max,+ type(int32).max,+ 1,+ 0,+ int256(type(int224).max) * NORMALIZATION_SCALE,+ type(int32).max - NORMALIZATION_DIGITS+ );
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7f643e2 and 110f42c.

📒 Files selected for processing (1)
  • test/src/lib/implementation/LibDecimalFloatImplementation.sub.t.sol (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: rainix (ubuntu-latest, test-wasm-build)
  • GitHub Check: rainix (ubuntu-latest, rainix-rs-static)
  • GitHub Check: rainix (ubuntu-latest, rainix-sol-static)
  • GitHub Check: rainix (ubuntu-latest, rainix-sol-test)
  • GitHub Check: rainix (macos-latest, rainix-rs-test)
  • GitHub Check: rainix (ubuntu-latest, rainix-rs-test)
  • GitHub Check: git-clean

@thedavidmeister
thedavidmeister merged commit 1f50603 into mainAug 11, 2025
8 checks passed
This was referenced Aug 11, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@thedavidmeister