-
Notifications
You must be signed in to change notification settings - Fork 2
Impl unit tests #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Impl unit tests #16
Conversation
LCOV of commit
|
| 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 { |
There was a problem hiding this comment.
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).
| 'test/*' \ | ||
| 'script/*' \ | ||
| 'src/proto/**' \ | ||
| 'src/core/PacketHandler.sol' \ | ||
| 'src/core/ContractRegistry.sol' \ |
There was a problem hiding this comment.
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
mattsu6666
left a comment
There was a problem hiding this 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!
test/CrossModule.t.sol
Outdated
| mod.onChanCloseConfirm(m); | ||
| } | ||
|
|
||
| function test_onChanCloseConfirm_Succeeds_WhenCallerHasRole() public { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
test/TxAtomicSimple.t.sol
Outdated
| return _module; | ||
| } | ||
|
|
||
| function extHandlePacket(Packet calldata p) external returns (bytes memory ack) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix: 13d6bfc
test/TxAtomicSimple.t.sol
Outdated
| Packet memory packet = _mkPacketWithCall(txId, callInfo); | ||
|
|
||
| // assert event emitted | ||
| vm.expectEmit(true, true, true, true); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix: a6fd5fe
test/TxAtomicSimple.t.sol
Outdated
| bytes memory callInfo = hex"c0ffee"; | ||
| Packet memory packet = _mkPacketWithCall(txId, callInfo); | ||
|
|
||
| // assert event emitted |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix: f7da2e0
test/TxAtomicSimple.t.sol
Outdated
| ); | ||
| } | ||
|
|
||
| function test_handlePacket_RevertInModule_ReturnsFAILED_AndEmitsEvent() public { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix: 51a84ae
mattsu6666
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!!
script/DeployAll.s.sol