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

Separate _verify_single_precompiled_checksum() #1304

Merged
merged 3 commits into from
Oct 31, 2019

Conversation

pirapira
Copy link
Contributor

@pirapira pirapira commented Oct 22, 2019

This commit separates a function that checks one entry of
contracts.json. This eases the implementation of #1257.

What this PR does

This is a pure refactoring that separates away a subroutine.

Before this PR, ContractSourceManager didn't have a function that checks a single entry of contracrts.json. There was only verify_precompiled_checksums() that checks all entries of contracts.json. This PR separates _verify_single_precompiled_checksum() that checks a single entry of contracts.json.

Why I'm making this PR

After this PR, I want to expose a feature to check a single contracts.json entry. That will be useful for checking whether or not SecretRegistry's sources have changed.

What's tricky about this PR (if any)

I had to take a moment to name the arguments of the new function.


Any reviewer can check these:

  • In Python, use keyword arguments
  • Squash unnecessary commits
  • Comment commits
  • Follow naming conventions
    • python_variable

And before "merge" all checkboxes have to be checked. If you find redundant points, remove them.

@codecov
Copy link

codecov bot commented Oct 23, 2019

Codecov Report

Merging #1304 into master will increase coverage by 0.17%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1304      +/-   ##
==========================================
+ Coverage   81.77%   81.94%   +0.17%     
==========================================
  Files          21       21              
  Lines        1465     1468       +3     
  Branches      193      193              
==========================================
+ Hits         1198     1203       +5     
+ Misses        228      226       -2     
  Partials       39       39
Impacted Files Coverage Δ
raiden_contracts/utils/versions.py 100% <ø> (ø) ⬆️
raiden_contracts/contract_source_manager.py 94.18% <100%> (+2.61%) ⬆️

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 940f375...01fe451. Read the comment docs.

@pirapira pirapira removed the request for review from err508 October 24, 2019 09:51
@pirapira pirapira requested a review from konradkonrad October 29, 2019 09:23

def test_verify_single_precompiled_cyhecksum_on_nonexistent_contract_name() -> None:
with pytest.raises(ContractSourceManagerVerificationError, match="No checksum for"):
verify_single_precompiled_checksum_on_nonexistetnt_contract_name()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
verify_single_precompiled_checksum_on_nonexistetnt_contract_name()
verify_single_precompiled_checksum_on_nonexistent_contract_name()

)


def verify_single_precompiled_checksum_on_nonexistetnt_contract_name() -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

It appears, this functions exists only for testing behavior. So it seems a little odd to have it inside contract_source_manager.py -- can't you move it to, e.g. https://github.com/raiden-network/raiden-contracts/blob/master/raiden_contracts/tests/utils/contracts.py ?

Copy link
Contributor Author

@pirapira pirapira Oct 30, 2019

Choose a reason for hiding this comment

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

I'm trying to avoid using _xyz from other modules. @hackaugusto what do you suggest?

Copy link
Contributor

@konradkonrad konradkonrad left a comment

Choose a reason for hiding this comment

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

you get my approval, but please change the typos and reconsider the placement of the nonexistent test function!

This commit separates a function that checks one entry of
contracts.json.  This eases the implementation of raiden-network#1257.
@pirapira pirapira merged commit 7e730f6 into raiden-network:master Oct 31, 2019
@pirapira pirapira deleted the individual-verify branch October 31, 2019 11:40
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.

2 participants