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

test: Split rpc_signmessage test for disabled wallet #22641

Merged
merged 1 commit into from
Aug 23, 2021
Merged

test: Split rpc_signmessage test for disabled wallet #22641

merged 1 commit into from
Aug 23, 2021

Conversation

Shubhankar-Gambhir
Copy link
Contributor

@Shubhankar-Gambhir Shubhankar-Gambhir commented Aug 5, 2021

This PR enables a part of the non-wallet functional test (rpc_signmessage.py) to be run even with the Bitcoin Core wallet disabled, it is inspired by #20078.

Divided tests in rpc_signmessage.py into 2 files wallet_signmessagewithaddress.py and rpc_signmessagewithprivkey.py, latter one can run even when wallet is disabled that provides extra test which was not performed earlier.

  • we need bitcoincore wallet to run rpc_signmessage.py, but it is olny required for signing messages with address and not for signing messages wih private key, so latter one can be in a seperate test which can run without wallet
  • verifying message doesn't require wallet, so it can be used in both tests without any problem
  • 2 tests are named as wallet_signmessagewithaddress.py and rpc_signmessagewithprivkey.py to provide clarity of what they are testing.

@DrahtBot DrahtBot added the Tests label Aug 5, 2021
@maflcko maflcko changed the title Test : Added test for disabled wallet Test: Added test for disabled wallet Aug 6, 2021
Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

test/functional/test_runner.py Outdated Show resolved Hide resolved
Copy link
Contributor

@ShubhamPalriwala ShubhamPalriwala left a comment

Choose a reason for hiding this comment

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

tAck 1701949

Decoupling the signing of messages with a private key and with an address opens up the doors for further individual testing in the future.

Tested on Ubuntu 21.04


self.log.info('test parameter validity and error codes')
# signmessage(withprivkey) have two required parameters
for num_params in [0, 1, 3, 4, 5]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason for running the loop here on L32 and L36 from 0 to 5?

Copy link
Contributor

Choose a reason for hiding this comment

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

It skips 2 (signmessagewithprivkey has two required parameters). I think the intention here is to ensure the RPC returns an error if called with the wrong number of parameters.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright! Makes sense then

def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 1
self.extra_args = [["-addresstype=legacy"]]
Copy link
Member

@laanwj laanwj Aug 10, 2021

Choose a reason for hiding this comment

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

I don't think this argument makes any difference without wallet?
Edit: yes, it works fine without this line

Copy link
Contributor

@vasild vasild left a comment

Choose a reason for hiding this comment

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

Approach ACK

I verified that this is just moving bits of a test to a separate new test (as intended).

Tested:

When compiled with --enable-wallet:

rpc_signmessagewithprivkey.py    | ✓ Passed  | 1 s
wallet_signmessagewithaddress.py | ✓ Passed  | 1 s

When compiled with --disable-wallet:

rpc_signmessagewithprivkey.py    | ✓ Passed  | 1 s
wallet_signmessagewithaddress.py | ○ Skipped | 0 s

wallet_signmessagewithaddress.py fails as expected if skip_if_no_wallet() is removed from it and the wallet is not enabled.

Just a few minor suggestions:

  • The first line in the commit message usually starts with a lowercase letter and has no space before the ::
$ git log --oneline --grep='^test:' origin/master |wc -l
     829

$ git log --oneline --grep='^Test:' origin/master |wc -l
       3

$ git log --oneline --grep='^Test :' origin/master |wc -l
       0
  • In the OP: s/rpc_signmessagewithaddress.py/wallet_signmessagewithaddress.py/

  • The commit message is a bit scarce. In general, it is good if it contains a summary of the changes and more importantly, why are they being done. It would be best if one can make sense of it by just reading the commit message, if github.com is not available.

assert self.nodes[0].verifymessage(address, signature, message)

self.log.info('test parameter validity and error codes')
# signmessage(withprivkey) have two required parameters
Copy link
Contributor

Choose a reason for hiding this comment

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

s/signmessage(withprivkey) have/signmessagewithprivkey has/ because this test is now executing just one RPC - signmessagewithprivkey.

@@ -45,18 +36,16 @@ def run_test(self):
# signmessage(withprivkey) have two required parameters
Copy link
Contributor

Choose a reason for hiding this comment

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

s/signmessage(withprivkey) have/signmessage has/ because this test is now executing just one RPC - signmessage.

Comment on lines 40 to 43
# verifymessage has three required parameters
for num_params in [0, 1, 2, 4, 5]:
param_list = ["dummy"]*num_params
assert_raises_rpc_error(-1, "verifymessage", self.nodes[0].verifymessage, *param_list)
Copy link
Contributor

Choose a reason for hiding this comment

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

This and lines 46,47,48 below exercise verifymessage which does not require a wallet, I think they can be removed from this file (wallet_signmessagewithaddress.py) since they are also present in rpc_signmessagewithprivkey.py.

Divided tests in rpc_signmessage.py into 2 files wallet_signmessagewithaddress.py and
rpc_signmessagewithprivkey.py, latter one can run even when wallet is disabled.
@Shubhankar-Gambhir Shubhankar-Gambhir changed the title Test: Added test for disabled wallet test: added test for disabled wallet Aug 12, 2021
Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

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

Concept ACK

@maflcko maflcko changed the title test: added test for disabled wallet test: Split rpc_signmessage test for disabled wallet Aug 15, 2021
Copy link
Contributor

@vasild vasild left a comment

Choose a reason for hiding this comment

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

ACK a3b559c

In the OP: s/rpc_signmessagewithaddress.py/wallet_signmessagewithaddress.py/

Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

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

Code-review ACK a3b559c

(review was quite painless thanks to --color-moved=dimmed-zebra)
No big deal, but if you for any reason need to retouch, I'd suggest to also adapt the commit subject to the PR title -- "added test for disabled wallet" is very generic and doesn't say much.

@maflcko maflcko merged commit 489beb3 into bitcoin:master Aug 23, 2021
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 23, 2021
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 23, 2022
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.

7 participants