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

Move Verify to SealedEnvelope #3197

Merged

Conversation

RobertKwiatkowski
Copy link
Contributor

Verify function is now SealedEnvelope method

@RobertKwiatkowski RobertKwiatkowski requested a review from a team as a code owner March 15, 2022 12:58
@CLAassistant
Copy link

CLAassistant commented Mar 15, 2022

CLA assistant check
All committers have signed the CLA.

@RobertKwiatkowski
Copy link
Contributor Author

I believe that the Verify() function test from action_test.go should also be moved to the sealedenvelope_test.go However there was no standalone test just for the Verify function thus I would like to receive some information/tips from your side.

Verify function is now SealedEnvelope method
@codecov
Copy link

codecov bot commented Mar 15, 2022

Codecov Report

Merging #3197 (1381f58) into master (bde7db5) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #3197   +/-   ##
=======================================
  Coverage   74.99%   74.99%           
=======================================
  Files         227      227           
  Lines       21196    21196           
=======================================
  Hits        15895    15895           
  Misses       4463     4463           
  Partials      838      838           
Impacted Files Coverage Δ
action/action.go 85.71% <ø> (-3.58%) ⬇️
action/protocol/generic_validator.go 88.23% <100.00%> (ø)
action/sealedenvelope.go 93.27% <100.00%> (+0.89%) ⬆️

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 bde7db5...1381f58. Read the comment docs.

@Liuhaai
Copy link
Member

Liuhaai commented Mar 15, 2022

thx for contribution. It'd be better if you can write unit test for Verify()

@dustinxie dustinxie merged commit 887ebab into iotexproject:master Mar 16, 2022
@@ -179,3 +183,27 @@ func wrapStakingActionIntoExecution(ab AbstractAction, toAddr []byte, pb proto.M
data: data,
}, nil
}

// Verify verifies the action using sender's public key
func (sealed *SealedEnvelope) Verify() error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

it is hard to say whether it is appropriate to have this function as a function of struct sealedenvelope for the following reasons:

  1. It uses so many public functions of itself, which is not recommended in our codebase
  2. The original Verify function is more like a util function, which groups some checks together. It is only used in action/protocol/generic_validator.go. The usage of this function in several test files are misuse. We can split it into several checks:
    a. check public key
    b. check gas limit
    c. check signature
    check a and b could be moved into action/protocol/generic_validator.go

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.

5 participants