v31.1-roots.1 · Commit 6: [PATCH 06/17] feat(wallet): preserve Roots signing and spend controls on v31
ci/test/test_wallet_privacy_contract.py
Before: /dev/null · After: ci/test/test_wallet_privacy_contract.py
File metadata
new file mode 100644 index 0000000000000000000000000000000000000000..54403e205c8a68272c1b3ae013443fd3e92fa809
Download original patch · Release notes
Diff rows 1–61 of 61. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.
ci/test/test_wallet_privacy_contract.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Static contracts for wallet privacy behavior and documentation."""
|
|
3
|
+
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
import unittest
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
ROOT = Path(__file__).resolve().parents[2]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class WalletPrivacyContractTest(unittest.TestCase):
|
|
12
|
+
def test_wif_paths_do_not_copy_secrets_to_std_string(self):
|
|
13
|
+
sweep_dialog = (ROOT / "src/qt/sweepdialog.cpp").read_text(encoding="utf-8")
|
|
14
|
+
wallet_interface = (ROOT / "src/wallet/interfaces.cpp").read_text(encoding="utf-8")
|
|
15
|
+
self.assertNotIn("m_private_key->text().toStdString()", sweep_dialog)
|
|
16
|
+
self.assertNotIn("std::string{private_key.begin(), private_key.end()}", wallet_interface)
|
|
17
|
+
self.assertIn("memory_cleanse(encoded.data(), encoded.size())", sweep_dialog)
|
|
18
|
+
self.assertIn("DecodeSecret(private_key)", wallet_interface)
|
|
19
|
+
key_io = (ROOT / "src/key_io.cpp").read_text(encoding="utf-8")
|
|
20
|
+
self.assertIn("DecodeSecretImpl<SecureString, secure_allocator<unsigned char>>", key_io)
|
|
21
|
+
|
|
22
|
+
def test_broadcast_has_a_final_authorization_gate(self):
|
|
23
|
+
spend = (ROOT / "src/wallet/spend.cpp").read_text(encoding="utf-8")
|
|
24
|
+
begin = spend.index("authorization.BeginBroadcast()")
|
|
25
|
+
broadcast = spend.index("broadcast(final_tx, error)")
|
|
26
|
+
self.assertLess(begin, broadcast)
|
|
27
|
+
self.assertIn("authorization.IsCancelled()", spend)
|
|
28
|
+
|
|
29
|
+
def test_coin_control_documentation_matches_its_row_filter(self):
|
|
30
|
+
documentation = (ROOT / "doc/wallet-privacy.md").read_text(encoding="utf-8")
|
|
31
|
+
wallet_interface = (ROOT / "src/wallet/interfaces.cpp").read_text(encoding="utf-8")
|
|
32
|
+
wallet_spend = (ROOT / "src/wallet/spend.cpp").read_text(encoding="utf-8")
|
|
33
|
+
coin_control = (ROOT / "src/wallet/coincontrol.h").read_text(encoding="utf-8")
|
|
34
|
+
|
|
35
|
+
self.assertIn("starts with the wallet's normal available-output list", documentation)
|
|
36
|
+
self.assertIn("Locked\n outputs remain visible", documentation)
|
|
37
|
+
self.assertIn("Unsafe and immature outputs are not added merely to show a status", documentation)
|
|
38
|
+
self.assertIn("not an\n inventory of unavailable outputs", documentation)
|
|
39
|
+
self.assertNotIn("Locked, unsafe,\n immature, or unavailable inputs are reported", documentation)
|
|
40
|
+
|
|
41
|
+
list_coins = wallet_spend[wallet_spend.index("ListCoins(const CWallet& wallet)"):]
|
|
42
|
+
self.assertIn("coins_params.skip_locked = false;", list_coins)
|
|
43
|
+
self.assertNotIn("coins_params.include_immature_coinbase = true;", list_coins)
|
|
44
|
+
self.assertIn("bool m_include_unsafe_inputs = false;", coin_control)
|
|
45
|
+
self.assertIn("for (const auto& entry : ListCoins(*m_wallet))", wallet_interface)
|
|
46
|
+
|
|
47
|
+
def test_candidate_documents_release_state_and_verification(self):
|
|
48
|
+
catalog = (ROOT / "doc/roots-features.md").read_text(encoding="utf-8")
|
|
49
|
+
guide = (ROOT / "doc/wallet-privacy.md").read_text(encoding="utf-8")
|
|
50
|
+
for document in (catalog, guide):
|
|
51
|
+
self.assertIn("candidate", document)
|
|
52
|
+
self.assertIn("v31", guide)
|
|
53
|
+
self.assertNotIn("deferred to the wallet theme", guide)
|
|
54
|
+
self.assertIn("bitcoin-cli help sweepprivkeys", guide)
|
|
55
|
+
self.assertIn("bitcoin-cli --version", guide)
|
|
56
|
+
self.assertIn("settxfee", guide)
|
|
57
|
+
self.assertIn("does not restore a Berkeley DB build option", guide)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
if __name__ == "__main__":
|
|
61
|
+
unittest.main()
|