v29.4-roots.4 · Commit 28: [PATCH 28/37] fix(wallet): secure asynchronous sweep cancellation
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..0c8095f97605744103294ce4e4aae923774372b5
Download original patch · Release notes
Diff rows 1–31 of 31. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.
ci/test/test_wallet_privacy_contract.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Static contracts for transient sweep-key handling and cancellation."""
|
| 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 |
+
|
| 30 |
+
if __name__ == "__main__":
|
| 31 |
+
unittest.main()
|