Browse Source

Verify cache restoration and channel cleanup for encrypted attachments

stream-multiview
evgeny 6 days ago
parent
commit
8a46a53a21
  1. 14
      tests/test_encrypted_attachment.c
  2. 1
      tools/chatgui/src/inputbar.cpp

14
tests/test_encrypted_attachment.c

@ -261,11 +261,23 @@ static void tick(void* arg) {
inject(t, A, B, ROUTER_FLAG_ENCRYPTED | ROUTER_FLAG_SIGNED, 0);
if (!readable(t, B) || value(b, "SELECT count(*) FROM attachment_key_requests") != 1 ||
value(a, "SELECT count(*) FROM attachment_key_requests") != 2) { failure(t, "duplicate grant changed persisted access"); return; }
sqlite3_stmt* cached = NULL;
if (sqlite3_prepare_v2(b->topo_sqlite_db, "SELECT plain_path FROM attachment_keys", -1, &cached, NULL) ||
sqlite3_step(cached) != SQLITE_ROW || remove((const char*)sqlite3_column_text(cached, 0))) {
sqlite3_finalize(cached); failure(t, "cache eviction fixture"); return;
}
sqlite3_finalize(cached); download(t, B);
t->phase++;
}
break;
case 9:
if (++t->hold >= 20) { t->phase++; uasync_stop(t->ua); return; }
if (readable(t, B) && ++t->hold >= 20) {
if (value(a, "SELECT count(*) FROM attachment_key_requests") != 2) { failure(t, "cache restore requested another consent"); return; }
chat_core_delete_channel(c, CHANNEL);
if (value(c, "SELECT count(*) FROM attachment_keys") || value(c, "SELECT count(*) FROM attachment_key_requests") ||
value(c, "SELECT count(*) FROM attachment_key_outbox")) { failure(t, "deleted channel retained grants/requests"); return; }
t->phase++; uasync_stop(t->ua); return;
}
break;
}
if (t->failed) return;

1
tools/chatgui/src/inputbar.cpp

@ -471,6 +471,7 @@ void InputBar::setRecordingContext(const QString& mediaDirBase, const QString& c
if (m_channelIdForRecord != channelId || m_mediaDirBase != mediaDirBase) {
clearReply();
++m_attachmentContext;
m_encryptBtn->setChecked(false);
clearPendingAttachment();
if (m_dropHint) m_dropHint->hide();
}

Loading…
Cancel
Save