This PR adds test coverage for the walletpassphrase/walletpassphrasechange RPC when the passphrase is incorrect due to a null character.
For reference: #27068 introduced the usage of SecureString to allow null characters.
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--006a51241073e994b41acfe9ec718e94-->
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32675.
<!--021abf342d371248e50ceaed478a90ca-->
See the guideline for information on the review process.
| Type | Reviewers |
|---|---|
| ACK | maflcko, w0xlt, BrandonOdiwuor, theStack, pablomartin4btc, achow101 |
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
<!--174a7506f384e20aa4161008e828411d-->
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
<!--5faf32d7da4f0f540f40219e4f7537a3-->
94 | @@ -95,6 +95,7 @@ def run_test(self): 95 | self.nodes[0].walletpassphrasechange(passphrase2, passphrase_with_nulls) 96 | # walletpassphrasechange should not stop at null characters 97 | assert_raises_rpc_error(-14, "wallet passphrase entered was incorrect", self.nodes[0].walletpassphrase, passphrase_with_nulls.partition("\0")[0], 10) 98 | + assert_raises_rpc_error(-14, "wallet passphrase entered is incorrect. It contains a null character (ie - a zero byte)", self.nodes[0].walletpassphrase, passphrase_with_nulls + "\0", 10)
might as well add coverage for walletpassphrasechange as well?
Yes, going to add it.
Done
3b90060a2df2b65369117f3ee8afe26be631867d..7cfbb8575e1ffbad5c48e2c461b45dd6ac63d064 address #32675 (review)
lgtm ACK 7cfbb8575e1ffbad5c48e2c461b45dd6ac63d064
Code Review ACK 7cfbb8575e1ffbad5c48e2c461b45dd6ac63d064
94 | @@ -95,6 +95,9 @@ def run_test(self): 95 | self.nodes[0].walletpassphrasechange(passphrase2, passphrase_with_nulls) 96 | # walletpassphrasechange should not stop at null characters 97 | assert_raises_rpc_error(-14, "wallet passphrase entered was incorrect", self.nodes[0].walletpassphrase, passphrase_with_nulls.partition("\0")[0], 10) 98 | + assert_raises_rpc_error(-14, "The wallet passphrase entered was incorrect", self.nodes[0].walletpassphrasechange, passphrase_with_nulls.partition("\0")[0], "abc") 99 | + assert_raises_rpc_error(-14, "wallet passphrase entered is incorrect. It contains a null character (ie - a zero byte)", self.nodes[0].walletpassphrase, passphrase_with_nulls + "\0", 10) 100 | + assert_raises_rpc_error(-14, "The old wallet passphrase entered is incorrect. It contains a null character (ie - a zero byte)", self.nodes[0].walletpassphrasechange, passphrase_with_nulls + "\0", "abc")
nit: as there is already a null character inside the string, could just append a regular character at the end to cause a mismatch with this error message
assert_raises_rpc_error(-14, "wallet passphrase entered is incorrect. It contains a null character (ie - a zero byte)", self.nodes[0].walletpassphrase, passphrase_with_nulls + "x", 10)
assert_raises_rpc_error(-14, "The old wallet passphrase entered is incorrect. It contains a null character (ie - a zero byte)", self.nodes[0].walletpassphrasechange, passphrase_with_nulls + "x", "abc")
Yes, make sense, thanks. I will just keep as-is to not invalidate the reviews.
ACK 7cfbb8575e1ffbad5c48e2c461b45dd6ac63d064
94 | @@ -95,6 +95,9 @@ def run_test(self): 95 | self.nodes[0].walletpassphrasechange(passphrase2, passphrase_with_nulls) 96 | # walletpassphrasechange should not stop at null characters 97 | assert_raises_rpc_error(-14, "wallet passphrase entered was incorrect", self.nodes[0].walletpassphrase, passphrase_with_nulls.partition("\0")[0], 10) 98 | + assert_raises_rpc_error(-14, "The wallet passphrase entered was incorrect", self.nodes[0].walletpassphrasechange, passphrase_with_nulls.partition("\0")[0], "abc") 99 | + assert_raises_rpc_error(-14, "wallet passphrase entered is incorrect. It contains a null character (ie - a zero byte)", self.nodes[0].walletpassphrase, passphrase_with_nulls + "\0", 10)
nit: again if you have to retouch... otherwise when you search for that "similar" description in the code you get both places ("The wallet" and "The Old wallet")
assert_raises_rpc_error(-14, "The wallet passphrase entered is incorrect. It contains a null character (ie - a zero byte)", self.nodes[0].walletpassphrase, passphrase_with_nulls + "\0", 10)
I will leave as-is for now to not invalidate the reivews. Thanks.
94 | @@ -95,6 +95,9 @@ def run_test(self):
95 | self.nodes[0].walletpassphrasechange(passphrase2, passphrase_with_nulls)
96 | # walletpassphrasechange should not stop at null characters
nit: if you have to retouch maybe... even if it's not entirely part of the scope of the change...
# walletpassphrasechange should not stop at null characters as prior to v25.0
And a test could be added in wallet_backcompatibility.py if it makes sense.
Same. And maybe out of scope, will see.
94 | @@ -95,6 +95,9 @@ def run_test(self): 95 | self.nodes[0].walletpassphrasechange(passphrase2, passphrase_with_nulls) 96 | # walletpassphrasechange should not stop at null characters 97 | assert_raises_rpc_error(-14, "wallet passphrase entered was incorrect", self.nodes[0].walletpassphrase, passphrase_with_nulls.partition("\0")[0], 10) 98 | + assert_raises_rpc_error(-14, "The wallet passphrase entered was incorrect", self.nodes[0].walletpassphrasechange, passphrase_with_nulls.partition("\0")[0], "abc")
nit: just if you retouch... to be consistent with other places where that error description is being compared...
assert_raises_rpc_error(-14, "wallet passphrase entered was incorrect", self.nodes[0].walletpassphrasechange, passphrase_with_nulls.partition("\0")[0], "abc")
Same
cr ACK 7cfbb8575e1ffbad5c48e2c461b45dd6ac63d064
In the description: "This PR adds test coverage for the walletpassphrase RPC..." should include also "walletpassphrasechange".
ACK 7cfbb8575e1ffbad5c48e2c461b45dd6ac63d064