Skip to content

[tests] Make rpcauth.py testable and add unit tests#13056

Merged
laanwj merged 1 commit into
bitcoin:masterfrom
nixbox:rpcauth
Apr 25, 2018
Merged

[tests] Make rpcauth.py testable and add unit tests#13056
laanwj merged 1 commit into
bitcoin:masterfrom
nixbox:rpcauth

Conversation

@nixbox

@nixbox nixbox commented Apr 23, 2018

Copy link
Copy Markdown
Contributor

refs #12995

@fanquake fanquake added the Tests label Apr 23, 2018
@laanwj

laanwj commented Apr 23, 2018

Copy link
Copy Markdown
Member

Some lint issues:

./test/util/rpcauth-test.py:19:1: E402 module level import not at top of file
./test/util/rpcauth-test.py:20:1: E402 module level import not at top of file
./test/util/rpcauth-test.py:21:1: E402 module level import not at top of file
./test/util/rpcauth-test.py:22:1: E402 module level import not at top of file
^---- failure generated from contrib/devtools/lint-python.sh

Also the test fails to launch:

/usr/bin/python3.4 ../test/util/rpcauth-test.py
/usr/bin/python3.4: can't open file '../test/util/rpcauth-test.py': [Errno 2] No such file or directory

@nixbox

nixbox commented Apr 24, 2018

Copy link
Copy Markdown
Contributor Author

Fixed the lint issues.

Fixed the "No such file or directory" problem as well.

@laanwj

laanwj commented Apr 24, 2018

Copy link
Copy Markdown
Member

utACK ebff14786b7addd4bcc6e74691394a77019f2bf6

@jnewbery jnewbery left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A few nits inline after testing.

Comment thread Makefile.am Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: seems like somewhat random placement. Why not alphabetically sorted like the rest?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread share/rpcauth/rpcauth.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: prefer _ for unused loop variables.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread share/rpcauth/rpcauth.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: prefer docstrings for function-level comments.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread share/rpcauth/rpcauth.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No need to use parens here. Just:

password, password_hmac = generate_password(salt)

(you could also change the return statement in generate_password() to return password, password_hmac, but under the covers Python will construct a tuple to return anyway, so it's equivalent.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread share/rpcauth/rpcauth.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: prefer string formatters ({} or % - we can't use f-strings yet).

If you must concatenate strings, please surround the + with spaces so the code isn't so difficult to parse.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread test/util/rpcauth-test.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is unnecessary - this is for python2 compatibility. We now no longer support python2 across the project.

@nixbox nixbox Apr 24, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated

Comment thread test/util/rpcauth-test.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: prefer with open() as: for opening files.

@nixbox

nixbox commented Apr 24, 2018

Copy link
Copy Markdown
Contributor Author

Mistakenly did a force push. Addressed all of your nits.

Thanks for the feedback!

@jnewbery jnewbery left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

couple more nits inline

Comment thread share/rpcauth/rpcauth.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Docstrings should be the first statement inside the function (https://www.python.org/dev/peps/pep-0257/#what-is-a-docstring)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread test/util/rpcauth-test.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: use os.path.join() for maximum portability (instead of concat'ing path strings)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, should probably say config_path

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread test/config.ini.in Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could do a rebase, since this is already in master?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@jnewbery

Copy link
Copy Markdown
Contributor

Tested ACK 6674a75.

Travis failure was unrelated failure in mining_prioritisetransaction.py. I've restarted the job.

@nixbox

nixbox commented Apr 25, 2018

Copy link
Copy Markdown
Contributor Author

All green, ready to go?

@laanwj
laanwj merged commit 6674a75 into bitcoin:master Apr 25, 2018
laanwj added a commit that referenced this pull request Apr 25, 2018
6674a75 [tests] Make rpcauth.py testable and add unit tests (Qasim Javed)

Pull request description:

  refs #12995

Tree-SHA512: 609a85a75dafe46723f050db1e96098f6859519afd5e1b141a332f34ab715144d32fdd8f10d245d6dc0765e77f82158fe7b8aa2e4317f0e893de491d2e0acf1f
laanwj added a commit to laanwj/bitcoin that referenced this pull request Apr 25, 2018
Add rpcauth-test (introduced bitcoin#13056) to AC_CONFIG_LINKS, like the other
directly called python scripts, to fix out-of-tree `make check`.
maflcko pushed a commit that referenced this pull request Apr 25, 2018
…-tree make check

3e53004 test: add rpcauth-test to AC_CONFIG_LINKS to fix out-of-tree make check (Wladimir J. van der Laan)

Pull request description:

  Add rpcauth-test (introduced #13056) to AC_CONFIG_LINKS, like the other directly called python scripts, to fix out-of-tree `make check`.
  (forgot to test this before merging, unfortunately)

Tree-SHA512: 60306ac83ee81e0f27d5b4f0420c3bd4edfa3fd5daaa067ff0c235eb55da9f6c559203c2625fed97783b2d11d9f1bed7a359b4d9204ab4af75fd1fd24b9882a8
stamhe pushed a commit to stamhe/bitcoin that referenced this pull request Jun 27, 2018
Add rpcauth-test (introduced bitcoin#13056) to AC_CONFIG_LINKS, like the other
directly called python scripts, to fix out-of-tree `make check`.
SmarterHomes pushed a commit to SmarterHomes/chaincoin that referenced this pull request Sep 6, 2018
Add rpcauth-test (introduced bitcoin#13056) to AC_CONFIG_LINKS, like the other
directly called python scripts, to fix out-of-tree `make check`.
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 22, 2020
6674a75 [tests] Make rpcauth.py testable and add unit tests (Qasim Javed)

Pull request description:

  refs bitcoin#12995

Tree-SHA512: 609a85a75dafe46723f050db1e96098f6859519afd5e1b141a332f34ab715144d32fdd8f10d245d6dc0765e77f82158fe7b8aa2e4317f0e893de491d2e0acf1f
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 22, 2020
… out-of-tree make check

3e53004 test: add rpcauth-test to AC_CONFIG_LINKS to fix out-of-tree make check (Wladimir J. van der Laan)

Pull request description:

  Add rpcauth-test (introduced bitcoin#13056) to AC_CONFIG_LINKS, like the other directly called python scripts, to fix out-of-tree `make check`.
  (forgot to test this before merging, unfortunately)

Tree-SHA512: 60306ac83ee81e0f27d5b4f0420c3bd4edfa3fd5daaa067ff0c235eb55da9f6c559203c2625fed97783b2d11d9f1bed7a359b4d9204ab4af75fd1fd24b9882a8
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants