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

Check for error returned in channel msg_tests #5492

Merged

Conversation

expertdicer
Copy link
Contributor

Description

closes: #4304

Commit Message / Changelog Entry

type: commit message

see the guidelines for commit messages. (view raw markdown for examples)


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against the correct branch (see CONTRIBUTING.md).
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/).
  • Added relevant godoc comments.
  • Provide a commit message to be used for the changelog entry in the PR description for review.
  • Re-reviewed Files changed in the Github PR explorer.
  • Review Codecov Report in the comment section below once CI passes.

@expertdicer
Copy link
Contributor Author

@DimitrisJim Can you take a brief look, is this okay so that I can continue for others Msgs ?

@DimitrisJim
Copy link
Contributor

@expertdicer thanks!

I've pushed a change for the first validate test func as a small template. We can drop the expPass if we use expError and just assert on the final err message generated.

@expertdicer expertdicer marked this pull request as ready for review December 25, 2023 04:37
@expertdicer
Copy link
Contributor Author

expertdicer commented Dec 30, 2023

Or should we implement the error check like in:

suite.Require().ErrorIs(err, tc.expErr)

@DimitrisJim
Copy link
Contributor

Or should we implement the error check like in:

We should also see what others think on this. In my view, we should be checking the error message that is going to be presented even if this does lead to more verbose set-ups (wrapping the error and formatting in values).

Can leave it as is for now we'll soon get some other opinions. At some point I'll open a bigger issue to ideally get all tests checking for the same thing.

Copy link
Member

@AdityaSripal AdityaSripal left a comment

Choose a reason for hiding this comment

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

i personally prefer error code checking as we wouldn't have to change tests if the error string gets rewritten. However, i think this PR can be merged as-is and we standardize on best practices internally.

Thanks @expertdicer !!

Copy link
Contributor

@chatton chatton left a comment

Choose a reason for hiding this comment

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

I think it does add value to check the error message when the same error type is returned in multiple cases, but my only concern is the additional maintenance overhead (debugging and refactoring tests as error messages change).

I think I am actually happy just checking for the error type in most cases.

In the case of state machine breaking error messages changing it's definitely worth while, but for validate basic error messages maybe not so much.

modules/core/04-channel/types/msgs_test.go Outdated Show resolved Hide resolved
@DimitrisJim
Copy link
Contributor

I think it does add value to check the error message when the same error type is returned in multiple cases

yea, that was what my thinking was. I do recal seeing these in ValidateBasic tests but could be mistaken. Either way, it def makes more sense to only do in those cases. 👍

Copy link
Contributor

@crodriguezvega crodriguezvega left a comment

Choose a reason for hiding this comment

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

Amazing! Thank you for adding all the errors in the tests!

@crodriguezvega crodriguezvega merged commit f51d062 into cosmos:main Jan 5, 2024
61 checks passed
@crodriguezvega crodriguezvega deleted the nguyen/update-channel-msg-tests branch January 5, 2024 12:58
mergify bot pushed a commit that referenced this pull request Jan 5, 2024
* update test for MsgChannelOpenInit

* update test for MsgChannelOpenTry

* Use error as expError.

* update TestMsgChannelOpenAckValidateBasic

* update TestMsgChannelOpenConfirmValidateBasic

* update TestMsgChannelCloseInitValidateBasic and TestMsgChannelCloseConfirmValidateBasic

* update TestMsgRecvPacketValidateBasic

* update TestMsgTimeoutValidateBasic

* update TestMsgTimeoutOnCloseValidateBasic, TestMsgAcknowledgementValidateBasic, TestMsgChannelUpgradeInitValidateBasic, TestMsgChannelUpgradeTryValidateBasic

* update TestMsgChannelUpgradeAckValidateBasic, TestMsgChannelUpgradeConfirmValidateBasic

* update TestMsgChannelUpgradeOpenValidateBasic and TestMsgChannelUpgradeTimeoutValidateBasic

* update TestMsgChannelUpgradeCancelValidateBasic

* review comment

* reorder test cases

* remove unnecessary expPass variables

---------

Co-authored-by: DimitrisJim <d.f.hilliard@gmail.com>
Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
(cherry picked from commit f51d062)

# Conflicts:
#	modules/core/04-channel/types/msgs_test.go
crodriguezvega pushed a commit that referenced this pull request Jan 5, 2024
* Check for error returned in channel msg_tests (#5492)

* update test for MsgChannelOpenInit

* update test for MsgChannelOpenTry

* Use error as expError.

* update TestMsgChannelOpenAckValidateBasic

* update TestMsgChannelOpenConfirmValidateBasic

* update TestMsgChannelCloseInitValidateBasic and TestMsgChannelCloseConfirmValidateBasic

* update TestMsgRecvPacketValidateBasic

* update TestMsgTimeoutValidateBasic

* update TestMsgTimeoutOnCloseValidateBasic, TestMsgAcknowledgementValidateBasic, TestMsgChannelUpgradeInitValidateBasic, TestMsgChannelUpgradeTryValidateBasic

* update TestMsgChannelUpgradeAckValidateBasic, TestMsgChannelUpgradeConfirmValidateBasic

* update TestMsgChannelUpgradeOpenValidateBasic and TestMsgChannelUpgradeTimeoutValidateBasic

* update TestMsgChannelUpgradeCancelValidateBasic

* review comment

* reorder test cases

* remove unnecessary expPass variables

---------

Co-authored-by: DimitrisJim <d.f.hilliard@gmail.com>
Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
(cherry picked from commit f51d062)

# Conflicts:
#	modules/core/04-channel/types/msgs_test.go

* merge artifacts

---------

Co-authored-by: Lặc <67097720+expertdicer@users.noreply.github.com>
Co-authored-by: Charly <charly@interchain.berlin>
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.

Check for error returned in channel msg_tests
5 participants