Skip to content

added some unit tests#1611

Draft
0xDEnYO wants to merge 1 commit intomainfrom
improve-unit-test-coverage
Draft

added some unit tests#1611
0xDEnYO wants to merge 1 commit intomainfrom
improve-unit-test-coverage

Conversation

@0xDEnYO
Copy link
Contributor

@0xDEnYO 0xDEnYO commented Feb 2, 2026

Which Jira task belongs to this PR?

Why did I implement it this way?

Checklist before requesting a review

Checklist for reviewer (DO NOT DEPLOY and contracts BEFORE CHECKING THIS!!!)

  • I have checked that any arbitrary calls to external contracts are validated and or restricted
  • I have checked that any privileged calls (i.e. storage modifications) are validated and or restricted
  • I have ensured that any new contracts have had AT A MINIMUM 1 preliminary audit conducted on by <company/auditor>

@lifi-action-bot lifi-action-bot marked this pull request as draft February 2, 2026 07:41
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 2, 2026

Walkthrough

Introduces new Solidity test suites and test cases for multiple contracts and libraries: PeripheryRegistryFacet (access control validation), ExcessivelySafeCall (utility functions with data capping), LibBytes (byte manipulation), LibUtil (revert message handling and address checks), and OFTComposeMsgCodec (encoding/decoding). Also extends existing LibUtil tests with additional coverage.

Changes

Cohort / File(s) Summary
Facet Tests
test/solidity/Facets/PeripheryRegistryFacet.t.sol
New test contract validating access control for periphery contract registration, ensuring non-owners cannot register and verifying event emission and storage.
Library Test Suites
test/solidity/Helpers/ExcessivelySafeCall.t.sol, test/solidity/Libraries/LibBytes.t.sol, test/solidity/Libraries/OFTComposeMsgCodec.t.sol
New comprehensive test harnesses and test contracts covering safe call execution with data capping, byte slicing and address conversion, and OFT message codec encoding/decoding with round-trip validation.
LibUtil Tests
test/solidity/Libraries/LibUtil.t.sol
Extended existing test file with three new test functions covering silent revert handling, revert string decoding, and zero address validation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

AuditNotRequired

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description contains only the template structure with empty sections and unchecked boxes; the author has not filled in any meaningful content about Jira task, implementation rationale, or why tests were added. Fill in the Jira task reference, explain the implementation rationale, and provide context for the unit tests added. Check off completed checklist items.
Title check ❓ Inconclusive Title is vague and generic, using "some unit tests" without specifying which tests, components, or what aspect of the codebase is being tested. Replace with a specific title like "Add unit tests for PeripheryRegistryFacet, ExcessivelySafeCall, LibBytes, LibUtil, and OFTComposeMsgCodec" or similar.
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch improve-unit-test-coverage

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@lifi-action-bot
Copy link
Collaborator

Test Coverage Report

Line Coverage: 87.91% (3013 / 3427 lines)
Function Coverage: 92.58% ( 487 / 526 functions)
Branch Coverage: 65.67% ( 484 / 737 branches)
Test coverage (87.91%) is above min threshold (83%). Check passed.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@test/solidity/Libraries/LibBytes.t.sol`:
- Around line 1-3: Remove the blank line between the SPDX license identifier and
the pragma declaration in the test/solidity/Libraries/LibBytes.t.sol header so
the SPDX line is immediately followed by the pragma solidity ^0.8.17; statement;
simply delete the empty line after the SPDX comment to comply with the coding
guideline.

In `@test/solidity/Libraries/OFTComposeMsgCodec.t.sol`:
- Around line 1-3: Remove the blank line separating the SPDX license comment and
the pragma statement so the file starts with the SPDX comment immediately
followed by the pragma directive; locate the top of
test/solidity/Libraries/OFTComposeMsgCodec.t.sol where the lines "//
SPDX-License-Identifier: LGPL-3.0-only" and "pragma solidity ^0.8.17;" are and
put them adjacent with no empty line between.
🧹 Nitpick comments (3)
test/solidity/Helpers/ExcessivelySafeCall.t.sol (1)

4-6: Use consistent import remapping.

Line 5 uses the lifi/ remapping while line 6 uses src/ directly. For consistency, prefer the lifi/ remapping throughout.

Suggested fix
 import { Test } from "forge-std/Test.sol";
 import { ExcessivelySafeCall } from "lifi/Helpers/ExcessivelySafeCall.sol";
-import { InvalidCallData } from "src/Errors/GenericErrors.sol";
+import { InvalidCallData } from "lifi/Errors/GenericErrors.sol";

As per coding guidelines: Use remappings defined in remappings.txt for imports: lifi/src/.

test/solidity/Facets/PeripheryRegistryFacet.t.sol (1)

39-52: LGTM!

The success test properly verifies both event emission and storage update. The structure follows the setup → execute → assert pattern with proper use of vm.expectEmit.

Optional: Consider adding test for non-existent registry lookup.

For more comprehensive coverage, you could add a test verifying the behavior when calling getPeripheryContract with a name that hasn't been registered.

🧪 Optional test for non-existent periphery lookup
function test_getPeripheryContract_ReturnsZeroForUnregistered() public {
    assertEq(registry.getPeripheryContract("NonExistent"), address(0));
}
test/solidity/Libraries/OFTComposeMsgCodec.t.sol (1)

66-74: Prefer camelCase for local variables (msg_encodedMsg).

♻️ Proposed refactor
-        bytes memory msg_ = harness.encode(nonce, srcEid, amountLD, compose);
+        bytes memory encodedMsg = harness.encode(nonce, srcEid, amountLD, compose);
 
-        assertEq(harness.nonce(msg_), nonce);
-        assertEq(harness.srcEid(msg_), srcEid);
-        assertEq(harness.amountLD(msg_), amountLD);
-        assertEq(harness.composeFrom(msg_), composeFrom);
+        assertEq(harness.nonce(encodedMsg), nonce);
+        assertEq(harness.srcEid(encodedMsg), srcEid);
+        assertEq(harness.amountLD(encodedMsg), amountLD);
+        assertEq(harness.composeFrom(encodedMsg), composeFrom);
         assertEq(
-            keccak256(harness.composeMsg(msg_)),
+            keccak256(harness.composeMsg(encodedMsg)),
             keccak256(composePayload)
         );

As per coding guidelines: Functions and variables use camelCase; constants and immutables are CONSTANT_CASE.

Comment on lines +1 to +3
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.17;

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove the blank line between SPDX and pragma.

SPDX must be immediately followed by the pragma.

🧩 Proposed fix
-// SPDX-License-Identifier: LGPL-3.0-only
-
-pragma solidity ^0.8.17;
+// SPDX-License-Identifier: LGPL-3.0-only
+pragma solidity ^0.8.17;
As per coding guidelines, own files must use the SPDX line immediately followed by the pragma with no blank line in between.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.17;
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.17;
🤖 Prompt for AI Agents
In `@test/solidity/Libraries/LibBytes.t.sol` around lines 1 - 3, Remove the blank
line between the SPDX license identifier and the pragma declaration in the
test/solidity/Libraries/LibBytes.t.sol header so the SPDX line is immediately
followed by the pragma solidity ^0.8.17; statement; simply delete the empty line
after the SPDX comment to comply with the coding guideline.

Comment on lines +1 to +3
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.17;

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove the blank line between SPDX and pragma.

This file violates the SPDX/pragma adjacency rule.

🛠️ Proposed fix
-// SPDX-License-Identifier: LGPL-3.0-only
-
-pragma solidity ^0.8.17;
+// SPDX-License-Identifier: LGPL-3.0-only
+pragma solidity ^0.8.17;

As per coding guidelines: Own files must use // SPDX-License-Identifier: LGPL-3.0-only immediately followed by the pragma statement with no blank line in between.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.17;
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.17;
🤖 Prompt for AI Agents
In `@test/solidity/Libraries/OFTComposeMsgCodec.t.sol` around lines 1 - 3, Remove
the blank line separating the SPDX license comment and the pragma statement so
the file starts with the SPDX comment immediately followed by the pragma
directive; locate the top of test/solidity/Libraries/OFTComposeMsgCodec.t.sol
where the lines "// SPDX-License-Identifier: LGPL-3.0-only" and "pragma solidity
^0.8.17;" are and put them adjacent with no empty line between.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants