// Forumer review probe (lib/forumer_core at cde75b1): is the per-persona hourly limit enforceable by receivers? // A receiver (ForumerBackend::checkPost) counts the author's stored posts of that kind with ts in [ts-1h, ts], and drops // the post if the count is already at the limit. This probe replays that exact check against the real PostStore. #include "forumer_core/flood.h" #include "forumer_core/identity.h" #include "forumer_core/post.h" #include "forumer_core/post_store.h" #include #include #include #include using namespace forumer; namespace fs = std::filesystem; static int64_t nowMs() { return std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); } static int run(const char* label, bool descending, int n) { auto acct = identity::Account::create("mallory"); auto persona = acct.persona(0); fs::path f = fs::temp_directory_path() / (std::string("forumer-q-flood-") + (descending ? "desc" : "asc") + ".sqlite3"); fs::remove(f); auto store = PostStore::open(f); const int64_t now = nowMs(); std::vector posts; for (int i = 0; i < n; i++) { post::Draft d; d.kind = post::Kind::Reply; d.root = std::string(32, 'a'); d.parent = std::string(32, 'a'); d.body = "spam " + std::to_string(i); d.timestampMs = now - 3600 * 1000LL + (int64_t)i * (3600 * 1000LL / n); // spread over the last hour post::Error e; auto p = post::sign(d, persona, identity::Disclosure::Persona, "", 16, &e); // the real 16-bit work posts.push_back(*p); } if (descending) std::reverse(posts.begin(), posts.end()); int accepted = 0; for (auto& p : posts) { const int64_t ts = p.content.timestampMs; size_t in = store->countByAuthor(p.publicKey, p.content.kind, ts - flood::kWindowMs, ts); if (!flood::withinLimit(p.content.kind, in)) continue; // "persona is over its hourly limit" if (store->insert(p, now) == PostStore::Insert::Added) accepted++; } std::cout << label << ": " << accepted << " of " << n << " replies by ONE persona accepted (limit is " << flood::maxPerWindow(post::Kind::Reply) << " per hour)\n"; return accepted; } int main() { run("ascending timestamps (honest order)", false, 300); run("descending timestamps (newest first)", true, 300); return 0; }