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

feat: clean up gnokey add + add coverage #1212

Merged
merged 22 commits into from
Apr 26, 2024

Conversation

zivkovicmilos
Copy link
Member

@zivkovicmilos zivkovicmilos commented Oct 9, 2023

Description

This PR initially started out as adding support for account derivation to gnokey add. However, over the discussions, it turned into a bigger cleanup of the gnokey add subcommand suite.

Changes done:

  • extracted ledger support into gnokey add ledger
  • extracted multisig support into gnokey add multisig
  • extracted bech32 public key support into gnokey add bech32
  • added coverage (unit tests) for all functionality, even though they were previously missing
  • added the --derive-path flag to the base gnokey add (original functionality of the PR)
Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

@zivkovicmilos zivkovicmilos added the 🌱 feature New update to Gno label Oct 9, 2023
@zivkovicmilos zivkovicmilos self-assigned this Oct 9, 2023
@github-actions github-actions bot added 📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related labels Oct 9, 2023
@zivkovicmilos
Copy link
Member Author

zivkovicmilos commented Oct 9, 2023

@moul

A disturbing amount of our gnokey commands are uncovered for the actual command orchestration newXCmd. We can easily have this coverage with txtar, just need to call the methods directly.

Here is an example for gnokey add, notice the uncovered lines.

We have 2 options here:

  • write unit tests that utilize newXCmd for all gnokey commands (we only test execX for now)
  • write unit tests that utilize txtar to directly call newXCmd, it would make our lives easier in terms of testing commands (we run the command as the user would run it). See the example txtar I've added for gnokey derive

cc @gfanton and @ajnavarro for opinions

@codecov
Copy link

codecov bot commented Oct 9, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 47.82%. Comparing base (6760265) to head (9a4c9f8).
Report is 25 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1212      +/-   ##
==========================================
+ Coverage   47.54%   47.82%   +0.28%     
==========================================
  Files         388      393       +5     
  Lines       61242    61633     +391     
==========================================
+ Hits        29117    29479     +362     
- Misses      29686    29687       +1     
- Partials     2439     2467      +28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ajnavarro
Copy link
Contributor

@moul

A disturbing amount of our gnokey commands are uncovered for the actual command orchestration newXCmd. We can easily have this coverage with txtar, just need to call the methods directly.

Here is an example for gnokey add, notice the uncovered lines.

We have 2 options here:

* write unit tests that utilize `newXCmd` for all `gnokey` commands (we only test `execX` for now)

* write unit tests that utilize `txtar` to directly call `newXCmd`, it would make our lives easier in terms of testing commands (we run the command as the user would run it). See [the example txtar](https://github.com/gnolang/gno/pull/1212/files#diff-0a2bc355fe44ff16072a65753292c76f3674b054bd4f51ff9fcf2b9f09d470e3) I've added for `gnokey derive`

cc @gfanton and @ajnavarro for opinions

I would say option 1

@gfanton
Copy link
Member

gfanton commented Oct 9, 2023

@moul

A disturbing amount of our gnokey commands are uncovered for the actual command orchestration newXCmd. We can easily have this coverage with txtar, just need to call the methods directly.

Here is an example for gnokey add, notice the uncovered lines.

We have 2 options here:

  • write unit tests that utilize newXCmd for all gnokey commands (we only test execX for now)
  • write unit tests that utilize txtar to directly call newXCmd, it would make our lives easier in terms of testing commands (we run the command as the user would run it). See the example txtar I've added for gnokey derive

cc @gfanton and @ajnavarro for opinions

I'm in favor of using option 2, i've recently implemented some tests for gno lint with both standard tests (using what was already in place) and testscripts
I know there is big room for improvement in the way we actually do our standard tests in gnovm for cmd, But I think that in terms of readability and intuitiveness, testscripts have the advantage in this particular case.

@moul
Copy link
Member

moul commented Oct 9, 2023

Regarding the discussion on testing, it is related to #1215.

By the way, why not add a -derivation-path flag to gnokey add -recover instead of adding gnokey derive?

@zivkovicmilos
Copy link
Member Author

@moul

By the way, why not add a -derivation-path flag to gnokey add -recover instead of adding gnokey derive?

I wanted to make this helper super accessible as a standalone call, and didn't want to pack in the functionality on gnokey add (let alone pair it with --recover). Do you think adding it as a flag is a better approach?

@zivkovicmilos
Copy link
Member Author

zivkovicmilos commented Oct 11, 2023

@gfanton @ajnavarro

3hpp4q

Added a unit test that calls newDeriveCmd, we can discuss later how to standardize gnokey tests:
313773b

@zivkovicmilos zivkovicmilos marked this pull request as ready for review October 11, 2023 10:57
@zivkovicmilos zivkovicmilos requested review from jaekwon, moul and a team as code owners October 11, 2023 10:57
@moul
Copy link
Member

moul commented Oct 20, 2023

LGTM for the implem, but looking for @jaekwon's opinion on the API, specifically this discussion: #1212 (comment)

@github-actions github-actions bot removed the 📦 ⛰️ gno.land Issues or PRs gno.land package related label Dec 1, 2023
@zivkovicmilos zivkovicmilos changed the title feat: add gnokey derive feat: add gnokey add --derive-accounts Dec 1, 2023
@zivkovicmilos zivkovicmilos marked this pull request as draft December 21, 2023 11:18
@zivkovicmilos
Copy link
Member Author

@moul

I've marked this PR as draft, as I want to completely clean up our gnokey add logic. I've looked into adding your 'derive-path' suggestion, and realized it would be the final nail in this jumbled code mess.

Will take this up in parallel, and ping you once it's ready for viewing 🙏

@zivkovicmilos
Copy link
Member Author

Current status:

I'm reworking this PR to clean up gnokey add, in addition to adding this mini derive support.

Currently pending tests

@zivkovicmilos zivkovicmilos changed the title feat: add gnokey add --derive-accounts feat: clean up gnokey add + add coverage Apr 1, 2024
@zivkovicmilos zivkovicmilos marked this pull request as ready for review April 1, 2024 09:12
@zivkovicmilos zivkovicmilos requested a review from a team as a code owner April 1, 2024 09:12
@zivkovicmilos
Copy link
Member Author

@gfanton @ajnavarro @moul
I've updated this old PR to be a cleanup of gnokey add, while keeping your comments about the derive functionality in check

Copy link
Member

@gfanton gfanton left a comment

Choose a reason for hiding this comment

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

Looks good 👍 !

@zivkovicmilos
Copy link
Member Author

zivkovicmilos commented Apr 2, 2024

@gfanton
I've added ledger unit tests here:

a68843b

It took way more than I thought it would to finish up the mocks 🙁

Thank you @gfanton for the input and helping me add this 🙏

@gfanton
Copy link
Member

gfanton commented Apr 16, 2024

@zivkovicmilos, some tests fail when the ledger_suite tag is not specified. All tests should pass without requiring specific tags. Can you skip ledger tests if the tag is not specified?

@zivkovicmilos
Copy link
Member Author

9a4c9f8

@gfanton
Good catch 🤦‍♂️

I've extracted it out:
9a4c9f8

@zivkovicmilos zivkovicmilos merged commit fdde3d0 into gnolang:master Apr 26, 2024
72 of 76 checks passed
@zivkovicmilos zivkovicmilos deleted the feat/add-gnokey-derive branch April 26, 2024 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🌐 tendermint v2 Issues or PRs tm2 related 🌱 feature New update to Gno
Projects
Status: Done
Status: Done
Status: 🔵 Not Needed for Launch
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants