nostrdb

an unfairly fast embedded nostr database backed by lmdb
git clone git://jb55.com/nostrdb
Log | Files | Refs | Submodules | README | LICENSE

commit 0e702e97b9b62ebf90833a72e44dd924f948fc4a
parent 2bdde7631a4559a6d2df3add1e09832bf3fc020e
Author: William Casarin <jb55@jb55.com>
Date:   Tue, 12 Mar 2024 19:53:37 +0000

test: add test for created_at query plan

Diffstat:
Mtest.c | 29+++++++++++++++++++++++++++++
1 file changed, 29 insertions(+), 0 deletions(-)

diff --git a/test.c b/test.c @@ -160,6 +160,33 @@ static void test_encode_decode_invoice() test_invoice_encoding(desc); } +// Test the created_at query plan via a contact-list query +static void test_timeline_query() +{ + struct ndb *ndb; + struct ndb_filter filter; + struct ndb_config config; + struct ndb_txn txn; + struct ndb_query_result results[10]; + int count; + ndb_default_config(&config); + + assert(ndb_init(&ndb, test_dir, &config)); + + ndb_filter_init(&filter); + ndb_filter_start_field(&filter, NDB_FILTER_AUTHORS); +#include "testdata/author-filter.c" + ndb_filter_end_field(&filter); + ndb_filter_end(&filter); + + ndb_begin_query(ndb, &txn); + assert(ndb_query(&txn, &filter, 1, results, + sizeof(results)/sizeof(results[0]), &count)); + ndb_end_query(&txn); + + assert(count == 10); +} + // Test fetched_at profile records. These are saved when new profiles are // processed, or the last time we've fetched the profile. static void test_fetched_at() @@ -1418,6 +1445,8 @@ int main(int argc, const char *argv[]) { // note fetching test_fetch_last_noteid(); + test_timeline_query(); + // fulltext test_fulltext();