fix(store): drop payments on /wipe; document non-forensic
All checks were successful
ci / test (pull_request) Successful in 3m1s
All checks were successful
ci / test (pull_request) Successful in 3m1s
/wipe now deletes payments as well as chat, checkpoints WAL, and enables sqlite secure_delete (flash still not crypto-shred).
This commit is contained in:
parent
bfd28fce6b
commit
45c105de8a
5 changed files with 70 additions and 12 deletions
|
|
@ -1,10 +1,13 @@
|
|||
//! M5: wipe messages (keep identity + friends); wipe-all is a new person.
|
||||
|
||||
use onionwire::Store;
|
||||
use onionwire::tui::{
|
||||
QuitDecision, QuitPrompt, WipeDecision, WipeKind, WipePrompt, parse_slash, quit_screen_text,
|
||||
wipe_screen_text,
|
||||
parse_slash, quit_screen_text, wipe_screen_text, QuitDecision, QuitPrompt, WipeDecision,
|
||||
WipeKind, WipePrompt,
|
||||
};
|
||||
use onionwire::{PaymentWrite, Store};
|
||||
|
||||
// Official mainnet standard from Monero docs (same fixture as tests/pay.rs).
|
||||
const MAINNET_STD: &str = "4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgYeYTRj5UzqtReoS44qo9mtmXCqY45DJ852K5Jv2684Rge";
|
||||
|
||||
fn pk(tag: u8) -> [u8; 32] {
|
||||
let mut k = [0u8; 32];
|
||||
|
|
@ -50,6 +53,53 @@ fn wipe_clears_messages_keeps_self_and_friends() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn wipe_clears_payments_keeps_self_and_friends() {
|
||||
let dir = tempfile::tempdir().expect("tempdir");
|
||||
let store = Store::open_at_with_passphrase(dir.path(), "onionwire-test").expect("open");
|
||||
let me = store.self_identity().unwrap();
|
||||
store
|
||||
.upsert_friend(&pk(1), "a.onion", Some("alice"))
|
||||
.unwrap();
|
||||
store
|
||||
.append_message(&pk(1), "out", b"secret-log-line-xyz")
|
||||
.unwrap();
|
||||
store
|
||||
.insert_payment(
|
||||
&pk(1),
|
||||
PaymentWrite {
|
||||
dir: "out",
|
||||
kind: "receipt",
|
||||
amount_atomic: "1000000000000",
|
||||
address: MAINNET_STD,
|
||||
memo: "counterparty-memo-xyz",
|
||||
txid: Some("aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899"),
|
||||
verified: true,
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(store.list_messages(&pk(1)).unwrap().len(), 1);
|
||||
assert_eq!(store.list_payments(&pk(1)).unwrap().len(), 1);
|
||||
|
||||
store.wipe_messages().expect("wipe");
|
||||
|
||||
assert!(store.list_messages(&pk(1)).unwrap().is_empty());
|
||||
assert!(
|
||||
store.list_payments(&pk(1)).unwrap().is_empty(),
|
||||
"wipe must drop payments, not only chat"
|
||||
);
|
||||
assert_eq!(store.friend_count().unwrap(), 1);
|
||||
let f = store.get_friend(&pk(1)).unwrap().expect("friend");
|
||||
assert_eq!(f.petname.as_deref(), Some("alice"));
|
||||
let me2 = store.self_identity().unwrap();
|
||||
assert_eq!(me.identity_pk, me2.identity_pk);
|
||||
drop(store);
|
||||
assert!(
|
||||
!db_contains(dir.path(), b"counterparty-memo-xyz"),
|
||||
"wipe must not leave payment memo in the db file"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn wipe_all_removes_dir_so_next_open_is_new_identity() {
|
||||
let dir = tempfile::tempdir().expect("tempdir");
|
||||
|
|
@ -108,8 +158,9 @@ fn wipe_all_requires_typing_wipeall() {
|
|||
#[test]
|
||||
fn wipe_prompt_text_matches_spec() {
|
||||
let m = wipe_screen_text(WipeKind::Messages);
|
||||
assert!(m.contains("Wipe message log?"));
|
||||
assert!(m.contains("Wipe chat and payments history?"));
|
||||
assert!(m.contains("Identity key and friends stay."));
|
||||
assert!(m.contains("Not a forensic erase."));
|
||||
assert!(m.contains("Type WIPE to confirm"));
|
||||
assert!(m.contains("Esc to cancel"));
|
||||
let a = wipe_screen_text(WipeKind::All);
|
||||
|
|
|
|||
Loading…
Reference in a new issue