Skip to content

Conversation

@YukiTsuchida
Copy link
Contributor

@YukiTsuchida YukiTsuchida commented Oct 28, 2025

  • Add unit tests for Solidity code
  • Raise coverage report threshold to 100%
  • Exclude non-essential files from coverage measurement
  • Minor: fix a solhint warning in script/DeployAll.s.sol

@github-actions
Copy link

github-actions bot commented Oct 28, 2025

LCOV of commit 51a84ae during Coverage Report #18

Summary coverage rate:
  lines......: 100.0% (77 of 77 lines)
  functions..: 100.0% (22 of 22 functions)
  branches...: no data found

Files changed coverage rate: n/a

Full coverage report

import {IIBCModuleInitializer} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/26-router/IIBCModule.sol";
import {ILightClient} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/02-client/ILightClient.sol";

contract DeployAll is Script, Config {
Copy link
Contributor Author

@YukiTsuchida YukiTsuchida Oct 28, 2025

Choose a reason for hiding this comment

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

I split the function because solhint complained about function-max-lines (I wonder why it didn't complain before? I don't know why).

@YukiTsuchida YukiTsuchida self-assigned this Oct 28, 2025
Comment on lines +32 to +36
'test/*' \
'script/*' \
'src/proto/**' \
'src/core/PacketHandler.sol' \
'src/core/ContractRegistry.sol' \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exclude because coverage measurement is not required

Copy link
Member

@mattsu6666 mattsu6666 left a comment

Choose a reason for hiding this comment

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

I've left comments!

mod.onChanCloseConfirm(m);
}

function test_onChanCloseConfirm_Succeeds_WhenCallerHasRole() public {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Could you explain the naming convention for test cases? I don't know how snake-case and camel-case are being used. Typically, the following conventions are used.
https://getfoundry.sh/guides/best-practices/writing-tests#organizing-and-naming-tests

Copy link
Contributor Author

@YukiTsuchida YukiTsuchida Oct 29, 2025

Choose a reason for hiding this comment

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

Sticking to Foundry’s vibe: test_<Function>_<Description>.
Underscores only split segments; inside a segment we use UpperCamel, e.g. ReturnsSelfAndVersionWhenCallerHasRole.
Revert cases are tagged with RevertIf/When/On_….

fix: 51a84ae

return _module;
}

function extHandlePacket(Packet calldata p) external returns (bytes memory ack) {
Copy link
Member

@mattsu6666 mattsu6666 Oct 29, 2025

Choose a reason for hiding this comment

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

Nit: When using Test Harness, the following naming convention is recommended.
e.g. exposed_myInternalMethod
https://getfoundry.sh/guides/best-practices/writing-tests#internal-functions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix: 13d6bfc

Packet memory packet = _mkPacketWithCall(txId, callInfo);

// assert event emitted
vm.expectEmit(true, true, true, true);
Copy link
Member

Choose a reason for hiding this comment

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

Since all arguments are always set to true, it’s simpler and better to just write vm.expectEmit(address(harness)). In addition, testing the emitter address is important.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix: a6fd5fe

bytes memory callInfo = hex"c0ffee";
Packet memory packet = _mkPacketWithCall(txId, callInfo);

// assert event emitted
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Obvious comment is not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix: f7da2e0

);
}

function test_handlePacket_RevertInModule_ReturnsFAILED_AndEmitsEvent() public {
Copy link
Member

Choose a reason for hiding this comment

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

It’s a bit tricky, but this test case doesn’t revert, so the test name should be changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix: 51a84ae

Copy link
Member

@mattsu6666 mattsu6666 left a comment

Choose a reason for hiding this comment

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

LGTM!!

@YukiTsuchida YukiTsuchida merged commit bc168cf into main Oct 29, 2025
5 checks passed
@YukiTsuchida YukiTsuchida deleted the impl-unit-tests branch January 16, 2026 08:29
Sign up for free to 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.

3 participants