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

x/auth: in-process test refactor #6573

Merged
merged 71 commits into from
Jul 14, 2020

Conversation

jgimeno
Copy link
Contributor

@jgimeno jgimeno commented Jul 1, 2020

Description

ref: #6423


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 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.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@codecov
Copy link

codecov bot commented Jul 1, 2020

Codecov Report

Merging #6573 into master will increase coverage by 0.54%.
The diff coverage is 59.37%.

@@            Coverage Diff             @@
##           master    #6573      +/-   ##
==========================================
+ Coverage   58.65%   59.19%   +0.54%     
==========================================
  Files         512      512              
  Lines       31280    31295      +15     
==========================================
+ Hits        18346    18525     +179     
+ Misses      11546    11363     -183     
- Partials     1388     1407      +19     

@alessio alessio changed the title Auth module inprocess test refactor. x/auth: in-process test refactor Jul 2, 2020
@aaronc aaronc mentioned this pull request Jul 2, 2020
19 tasks
client/test_helpers.go Outdated Show resolved Hide resolved
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

Giving a preliminary ACK here, but I just want to note that I don't think CallCliCmd is necessary at all. See my comment.

Nevertheless, great work @jgimeno 🎉

@jgimeno
Copy link
Contributor Author

jgimeno commented Jul 14, 2020

Check now @alexanderbez , I kept the function unexported in every test, I did not dare to repeat by every function the logic that builds the context, do the mockIO etc. Because of DRY, but I can do it if still we agree that is verbose.

return callCliCmd(clientCtx, cli.GetDecodeCommand, args)
}

func callCliCmd(clientCtx client.Context, theCmd func() *cobra.Command, extraArgs []string) ([]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it is worth have an auxiliary function for this.

  1. Rename it: ExecTestCLICmd
  2. Why does it take a command function, and not just a *cobra.Command literal?
  3. Move this to the testutils pkg.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check now, I have put it back to the testutil but now there is lots of problems of import cycle, so I put it into testutil/cli. If we want to change that and make it work into testutil I will open an issue because everytime I get new problems with this PR when merging master.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks great! I approve! Just left one minor remark.

)

// ExecTestCLICmd builds the client context, mocks the output and executes the command.
func ExecTestCLICmd(clientCtx client.Context, cmd *cobra.Command, extraArgs []string) ([]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's return out here instead of []byte. Otherwise, ACK 🎉

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!

@alexanderbez alexanderbez added the A:automerge Automatically merge PR once all prerequisites pass. label Jul 14, 2020
@mergify mergify bot merged commit 351192a into master Jul 14, 2020
@mergify mergify bot deleted the jonathan/auth-module-inprocess-integration-test branch July 14, 2020 18:37
@alexanderbez alexanderbez mentioned this pull request Jul 17, 2020
9 tasks
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
* remove unused functions

* create helper func to send tx

* refactor to use test help to send tx by client

* Commit before getting backend.

* Temporal commit

* temp commit

* remove the creation of txbuilder from cli

* fix imports

* update changelog

* Remove unused function.

* Add flag home into tx sign command.

* migrade TestCLIValidateSignatures to use new test suite

* migrate test one

* Add changes to make sign batch.

* make test pass

* refactor common logic

* First part of cli sign.

* Add test for sign batch.

* refactor a little and improve the test

* migrate broadcast command

* fix linter

* Remove printf for debug in bank module.

* Fix unused err var.

* fix linter

* fix test

* fix tests client

* Fix linter.

* Temp commit signature.

* encode tx

* migrate tests

* Fix imports.

* Remove changelog

* fix tests

* Fix tests.

* Update x/bank/client/testutil/cli_helpers.go

* Remove alias.

* Remove wait for N block func.

* export callCmd function into its own file.

* fix imports

* bring back to inner functions

* apply mock io

* the helpers use mockio

* fix bug

* Add Helpers.

* return to put the function in testutil package

* return BufferWriter in ExecTestCLICmd

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C:CLI C:x/auth Type: Code Hygiene General cleanup and restructuring of code to provide clarity, flexibility, and modularity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants