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.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32675.
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.
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.
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)
walletpassphrasechange
as well?
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
0 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)
1 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")
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”)
0 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)
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…
0 # 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.
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…
0 assert_raises_rpc_error(-14, "wallet passphrase entered was incorrect", self.nodes[0].walletpassphrasechange, passphrase_with_nulls.partition("\0")[0], "abc")
cr ACK 7cfbb8575e1ffbad5c48e2c461b45dd6ac63d064
In the description: “This PR adds test coverage for the walletpassphrase
RPC…” should include also "walletpassphrasechange
".