iotex-core icon indicating copy to clipboard operation
iotex-core copied to clipboard

[ioctl] build did gethash command line into new ioctl

Open LuckyPigeon opened this issue 2 years ago • 4 comments

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.

Type of change

Please delete options that are not relevant.

  • [x] 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

  • [x] make test
  • [x] TestNewDidGetHashCmd

Test Configuration:

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

Checklist:

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

LuckyPigeon avatar Sep 16 '22 02:09 LuckyPigeon

@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?

LuckyPigeon avatar Sep 16 '22 02:09 LuckyPigeon

@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.

huof6829 avatar Sep 16 '22 02:09 huof6829

@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.

LuckyPigeon avatar Sep 16 '22 08:09 LuckyPigeon

@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.

huof6829 avatar Sep 23 '22 04:09 huof6829

Codecov Report

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

:exclamation: 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%) :arrow_up:
ioctl/newcmd/node/nodedelegate.go 70.19% <0.00%> (-0.95%) :arrow_down:
ioctl/newcmd/node/nodeprobationlist.go 90.90% <0.00%> (-4.33%) :arrow_down:
action/protocol/execution/evm/evm.go 44.57% <26.66%> (-0.86%) :arrow_down:
db/trie/mptrie/hashnode.go 36.36% <41.17%> (-54.55%) :arrow_down:
db/trie/mptrie/merklepatriciatrie.go 78.73% <46.80%> (-12.70%) :arrow_down:
db/trie/mptrie/leafiterator.go 62.06% <50.00%> (ø)
action/protocol/execution/evm/evmstatedbadapter.go 65.87% <64.28%> (-0.04%) :arrow_down:
db/trie/mptrie/extensionnode.go 91.91% <94.28%> (-1.07%) :arrow_down:
... and 16 more

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

codecov[bot] avatar Sep 23 '22 13:09 codecov[bot]

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

huof6829 avatar Sep 23 '22 14:09 huof6829

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

sonarqubecloud[bot] avatar Sep 30 '22 11:09 sonarqubecloud[bot]