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

[ioctl] build did gethash command line into new ioctl #3639

Merged
merged 25 commits into from
Sep 30, 2022

Conversation

LuckyPigeon
Copy link
Contributor

@LuckyPigeon LuckyPigeon commented Sep 16, 2022

Description

Refactor didgethash command in new ioctl, with the following note.

  • Use client interface to construct the Cobra command.
  • Output package is deprecated, replace it with errors package.
  • Replace fmt.Println with cmd.Println
  • Refactor unit test to cover the modification.

Fixes #3291

Type of change

Please delete options that are not relevant.

  • Code refactor or improvement

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • make test
  • TestNewDidGetHashCmd

Test Configuration:

  • Firmware version: Windows 10 (WSL Version: Ubuntu 18.04)
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@LuckyPigeon LuckyPigeon marked this pull request as ready for review September 16, 2022 02:21
@LuckyPigeon LuckyPigeon requested a review from a team as a code owner September 16, 2022 02:21
@LuckyPigeon
Copy link
Contributor Author

@huof6829
I'm encounter a problem with writting unittest, my code keep failing with the error message "did does not exist", is there any way to solve this without duplicate the test code inside didregister command?

@huof6829
Copy link
Contributor

@huof6829 I'm encounter a problem with writting unittest, my code keep failing with the error message "did does not exist", is there any way to solve this without duplicate the test code inside didregister command?

which test function? I will try.

@LuckyPigeon
Copy link
Contributor Author

@huof6829
The test function is inside didgethash_test.go, named TestNewDidGetHashCmd.
My first thought is using NewDidRegisterCmd to register a new did, but it seems doesn't work well.

@huof6829
Copy link
Contributor

@huof6829 The test function is inside didgethash_test.go, named TestNewDidGetHashCmd. My first thought is using NewDidRegisterCmd to register a new did, but it seems doesn't work well.

OK. I will try out.

@codecov
Copy link

codecov bot commented Sep 23, 2022

Codecov Report

Merging #3639 (67847d0) into master (e9732a1) will decrease coverage by 0.28%.
The diff coverage is 80.46%.

❗ Current head 67847d0 differs from pull request most recent head 3375e36. Consider uploading reports for the commit 3375e36 to get more accurate results

@@            Coverage Diff             @@
##           master    #3639      +/-   ##
==========================================
- Coverage   74.95%   74.67%   -0.29%     
==========================================
  Files         269      265       -4     
  Lines       23819    23719     -100     
==========================================
- Hits        17854    17711     -143     
- Misses       5039     5082      +43     
  Partials      926      926              
Impacted Files Coverage Δ
db/trie/mptrie/node.go 100.00% <ø> (ø)
ioctl/newcmd/action/action.go 79.62% <ø> (+0.09%) ⬆️
ioctl/newcmd/node/nodedelegate.go 70.19% <0.00%> (-0.95%) ⬇️
ioctl/newcmd/node/nodeprobationlist.go 90.90% <0.00%> (-4.33%) ⬇️
action/protocol/execution/evm/evm.go 44.57% <26.66%> (-0.86%) ⬇️
db/trie/mptrie/hashnode.go 36.36% <41.17%> (-54.55%) ⬇️
db/trie/mptrie/merklepatriciatrie.go 78.73% <46.80%> (-12.70%) ⬇️
db/trie/mptrie/leafiterator.go 62.06% <50.00%> (ø)
action/protocol/execution/evm/evmstatedbadapter.go 65.87% <64.28%> (-0.04%) ⬇️
db/trie/mptrie/extensionnode.go 91.91% <94.28%> (-1.07%) ⬇️
... and 16 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@huof6829
Copy link
Contributor

@LuckyPigeon the length of data should be inter-multiple of 32 bytes. Otherwise abi.Unpack runs error

ioctl/newcmd/did/didgethash.go Outdated Show resolved Hide resolved
ioctl/newcmd/did/didgethash.go Outdated Show resolved Hide resolved
ioctl/newcmd/did/didregister.go Outdated Show resolved Hide resolved
ioctl/newcmd/did/didgethash_test.go Outdated Show resolved Hide resolved
ioctl/newcmd/did/didgethash_test.go Outdated Show resolved Hide resolved
ioctl/newcmd/did/didgethash_test.go Outdated Show resolved Hide resolved
ioctl/newcmd/did/didgethash_test.go Outdated Show resolved Hide resolved
ioctl/newcmd/did/didgethash_test.go Outdated Show resolved Hide resolved
ioctl/newcmd/did/didgethash_test.go Outdated Show resolved Hide resolved
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
3.6% 3.6% Duplication

@huof6829 huof6829 merged commit ea19b74 into iotexproject:master Sep 30, 2022
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.

[ioctl] build did gethash command line into new ioctl
3 participants