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] Cleanup TestNewNodeDelegateCmd #3421

Merged
merged 15 commits into from
Jun 25, 2022

Conversation

LuckyPigeon
Copy link
Contributor

@LuckyPigeon LuckyPigeon commented May 30, 2022

Description

Cleanup TestNewNodeDelegateCmd with following adjustment.

  • Remove redundant mock test
  • Replace AnyTimes with specific Times
  • Move specific client and variable to correspond t.Run

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

  • TestNewNodeDelegateCmd

Test Configuration:

  • Firmware version: Ubuntu 21.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

@codecov
Copy link

codecov bot commented May 30, 2022

Codecov Report

Merging #3421 (c61ae2d) into master (e3afa71) will decrease coverage by 0.01%.
The diff coverage is 50.00%.

@@            Coverage Diff             @@
##           master    #3421      +/-   ##
==========================================
- Coverage   75.28%   75.27%   -0.02%     
==========================================
  Files         241      241              
  Lines       22258    22261       +3     
==========================================
- Hits        16758    16757       -1     
- Misses       4597     4602       +5     
+ Partials      903      902       -1     
Impacted Files Coverage Δ
ioctl/newcmd/node/nodedelegate.go 71.71% <50.00%> (-0.78%) ⬇️
db/trie/mptrie/branchnode.go 97.22% <0.00%> (-1.39%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e3afa71...c61ae2d. Read the comment docs.

@LuckyPigeon LuckyPigeon marked this pull request as ready for review May 30, 2022 08:44
@LuckyPigeon LuckyPigeon requested a review from a team as a code owner May 30, 2022 08:44
ioctl/newcmd/node/nodedelegate_test.go Outdated Show resolved Hide resolved
ioctl/newcmd/node/nodedelegate_test.go Outdated Show resolved Hide resolved
ioctl/newcmd/node/nodedelegate_test.go Outdated Show resolved Hide resolved
@huof6829
Copy link
Contributor

huof6829 commented Jun 2, 2022

nodedelegate.go#L99 bc.GetProbationList(client, epochNum) should add epochStartHeight. see

probationListRes, err := bc.GetProbationList(_epochNum, epochStartHeight)

@huof6829
Copy link
Contributor

huof6829 commented Jun 2, 2022

nodedelegate.go#L99 var err error can be delete

@LuckyPigeon
Copy link
Contributor Author

I have added epochStartHeight at #3411 once, but @Liuhaai tells me to revert, and I'm not sure we need to add it or not.
If it's a necessary, I'll add it both here and #3411.

@LuckyPigeon
Copy link
Contributor Author

LuckyPigeon commented Jun 10, 2022

var err error in nodedelegate.go #L102 had been used at

if err != nil {
cmd.Println(err)
}
return nil

@huof6829 huof6829 closed this Jun 13, 2022
@huof6829 huof6829 reopened this Jun 13, 2022
@huof6829
Copy link
Contributor

huof6829 commented Jun 13, 2022

I have added epochStartHeight at #3411 once, but @Liuhaai tells me to revert, and I'm not sure we need to add it or not. If it's a necessary, I'll add it both here and #3411.

I'v modified #3411. After #3411 merged, you can use getProbationList() for line 206~215

@@ -244,8 +247,6 @@ func NewNodeDelegateCmd(client ioctl.Client) *cobra.Command {
flagEpochNumUsage)
cmd.Flags().BoolVarP(&nextEpoch, "next-epoch", "n", false,
Copy link
Contributor

Choose a reason for hiding this comment

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

@CoderZhi next-epoch is a new flag here and not exist in ioctl/cmd/node/nodedelegate.go. I'm not sure if it can be used like this. In cmd nextEpoch is distinguished by

if epochData.Height >= config.ReadConfig.Nsv2height {
return delegatesV2(probationList, response, &message)
}

I think we should create new pr to change to the original logic.

@huof6829
Copy link
Contributor

var err error in nodedelegate.go #L102 had been used at

if err != nil {
cmd.Println(err)
}
return nil

fixed

@Liuhaai
Copy link
Member

Liuhaai commented Jun 14, 2022

map could be replaced with if... else

@CoderZhi CoderZhi merged commit bd7662c into iotexproject:master Jun 25, 2022
pocockn added a commit to pocockn/iotex-core that referenced this pull request Jul 4, 2022
* upstream/master: (24 commits)
  account type with zero init nonce (iotexproject#3387)
  [api] Separate Server and Server Handler (iotexproject#3485)
  [ioctl] Build hdwallet derive command line into new ioctl (iotexproject#3418)
  [ioctl] Build hdwallet create command line into new ioctl (iotexproject#3470)
  [makefile] add go mod tidy (iotexproject#3471)
  [api] update chain metrics (iotexproject#3484)
  remove config.EVMNetworkID() (iotexproject#3460)
  [filedao] remove checkMasterChainDBFile() (iotexproject#3463)
  [api] add crashlog (iotexproject#3456)
  [api] Move generateBlockMeta to grpcserver.go (iotexproject#3303)
  [ioctl] Build action hash command line into new ioctl (iotexproject#3425)
  [ioctl] Build hdwallet export command line into new ioctl (iotexproject#3423)
  [ioctl] Refactor nodereward command in new ioctl (iotexproject#3416)
  [ioctl] Cleanup TestNewNodeDelegateCmd (iotexproject#3421)
  [blockchain] Remove BoltDBDaoOption (iotexproject#3465)
  remove InMemDaoOption (iotexproject#3464)
  [action] add evm london test (iotexproject#3402)
  [ioctl] create main for ioctl/newcmd (iotexproject#3296)
  [ioctl] Build block bucket command line into new ioctl (iotexproject#3386)
  [ioctl] Build hdwallet import command line into new ioctl (iotexproject#3419)
  ...
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.

4 participants