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

Fix encoding user input in failed transaction message #1376

Merged

Conversation

m4ksio
Copy link
Contributor

@m4ksio m4ksio commented Sep 29, 2021

No description provided.

@m4ksio m4ksio changed the title Fix encoidng user input in failed transaction message Fix encodinguser input in failed transaction message Sep 29, 2021
@m4ksio m4ksio changed the title Fix encodinguser input in failed transaction message Fix encoding user input in failed transaction message Sep 29, 2021
Base automatically changed from m4ksio/accounts-refactor to master September 29, 2021 00:35
Copy link
Contributor

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

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

The test is a tad elaborate, I'm impressed you went through the trouble! Thanks!

@@ -262,7 +263,8 @@ func (e *AccountKeyHandler) AddEncodedAccountKey(address runtime.Address, encode

publicKey, err = flow.DecodeRuntimeAccountPublicKey(encodedPublicKey, 0)
if err != nil {
err = errors.NewValueErrorf(string(encodedPublicKey), "invalid encoded public key value: %w", err)
hexEncodedPublicKey := hex.EncodeToString(encodedPublicKey)
err = errors.NewValueErrorf(hexEncodedPublicKey, "invalid encoded public key value: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: In so far as we're using a NewValueErrorf already, could we just interpolate with "%x"?

@codecov-commenter
Copy link

codecov-commenter commented Sep 29, 2021

Codecov Report

Merging #1376 (01b62a8) into master (7925ced) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

❗ Current head 01b62a8 differs from pull request most recent head 6390f7f. Consider uploading reports for the commit 6390f7f to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1376      +/-   ##
==========================================
- Coverage   55.39%   55.37%   -0.03%     
==========================================
  Files         510      510              
  Lines       31857    31858       +1     
==========================================
- Hits        17648    17640       -8     
- Misses      11834    11842       +8     
- Partials     2375     2376       +1     
Flag Coverage Δ
unittests 55.37% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
fvm/handler/accountKey.go 6.49% <100.00%> (+5.18%) ⬆️
...sus/approvals/assignment_collector_statemachine.go 42.30% <0.00%> (-9.62%) ⬇️
...ngine/common/synchronization/finalized_snapshot.go 68.75% <0.00%> (-4.17%) ⬇️
network/p2p/dns/resolver.go 97.53% <0.00%> (-2.47%) ⬇️
admin/command_runner.go 78.51% <0.00%> (-1.49%) ⬇️

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 7925ced...6390f7f. Read the comment docs.

Copy link
Member

@AlexHentschel AlexHentschel 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 to me. Though, I don't think I have enough background to reliably find subtle edge cases.

Style suggestion:

would be great to document in the godoc of method

func (e *AccountKeyHandler) AddEncodedAccountKey(address runtime.Address, encodedPublicKey []byte) (err error) {

what specific error types it returns under which conditions (at least AccountNotFoundError and ValueError)

require.NoError(t, err)

err = akh.AddEncodedAccountKey(runtime.Address(address), encodedPublicKey)
require.Error(t, err)
Copy link
Member

Choose a reason for hiding this comment

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

lets check the specific error type here, you are expecting to return

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done and done

@m4ksio
Copy link
Contributor Author

m4ksio commented Sep 29, 2021

bors merge

@bors
Copy link
Contributor

bors bot commented Sep 29, 2021

@bors bors bot merged commit 9b3bb0d into master Sep 29, 2021
@bors bors bot deleted the m4ksio/fix-encoidng-user-input-in-failed-transaction-message branch September 29, 2021 22:48
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.

None yet

6 participants