Skip to content
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

[SC-437] Fixing coverage by adding unit tests #18

Merged
merged 14 commits into from
Jun 12, 2024

Conversation

hexonaut
Copy link
Contributor

@hexonaut hexonaut commented Jun 5, 2024

Adding unit tests to the receiver contracts for more robust testing and it fixes coverage issues.

Please note I also updated the import to relative to fix an issue with having this as a library. It wouldn't resolve the types properly otherwise.

Also, fixing a bug with subsequent message relays on all testing frameworks.

Copy link
Contributor

@barrutko barrutko left a comment

Choose a reason for hiding this comment

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

Two small suggestions, other that that looks good.

test/mocks/TargetContractMock.sol Outdated Show resolved Hide resolved
test/mocks/TargetContractMock.sol Outdated Show resolved Hide resolved
test/mocks/TargetContractMock.sol Outdated Show resolved Hide resolved
test/mocks/TargetContractMock.sol Outdated Show resolved Hide resolved
function test_handleReceiveMessage_success() public {
assertEq(target.data(), 0);
vm.prank(destinationMessenger);
receiver.handleReceiveMessage(
Copy link
Contributor

Choose a reason for hiding this comment

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

May as well assert return value here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

@@ -105,6 +105,16 @@ abstract contract IntegrationBaseTest is Test {
assertEq(moSource.length(), 2);
assertEq(moSource.messages(0), 3);
assertEq(moSource.messages(1), 4);

// One more message to destination
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we want another to source as well to make sure that both relays handle correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ya good point, added

Comment on lines 84 to 85
assertEq(result, true);
assertEq(target.count(), 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Align

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link

Coverage after merging SC-437-fix-coverage into SC-452-refactor-forwards-receivers will be

100.00%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src/forwarders
   AMBForwarder.sol100%100%100%100%
   ArbitrumForwarder.sol100%100%100%100%
   CCTPForwarder.sol100%100%100%100%
   OptimismForwarder.sol100%100%100%100%
src/receivers
   AMBReceiver.sol100%100%100%100%
   ArbitrumReceiver.sol100%100%100%100%
   CCTPReceiver.sol100%100%100%100%
   OptimismReceiver.sol100%100%100%100%

Copy link
Contributor

@barrutko barrutko left a comment

Choose a reason for hiding this comment

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

LGTM

@hexonaut hexonaut merged commit 1b6d35f into SC-452-refactor-forwards-receivers Jun 12, 2024
3 checks passed
@hexonaut hexonaut deleted the SC-437-fix-coverage branch June 12, 2024 16:16
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.

3 participants