tdb2: unify tdb1_traverse into tdb_traverse
[ccan] / ccan / tdb2 / test / run-tdb1-traverse-in-transaction.c
index 0395bff7ce66deeb30ebf465bf42869dee14f361..c4fd89dfe4b79b44996063d5dfb6b7d7ec794fcc 100644 (file)
@@ -36,15 +36,20 @@ int main(int argc, char *argv[])
 {
        struct tdb_context *tdb;
        TDB_DATA key, data;
+       union tdb_attribute hsize;
+
+       hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
+       hsize.base.next = &tap_log_attr;
+       hsize.tdb1_hashsize.hsize = 1024;
 
        plan_tests(13);
        agent = prepare_external_agent1();
        if (!agent)
                err(1, "preparing agent");
 
-       tdb = tdb1_open("run-traverse-in-transaction.tdb",
-                       1024, TDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR,
-                       0600, &tap_log_attr);
+       tdb = tdb_open("run-traverse-in-transaction.tdb1",
+                      TDB_VERSION1, O_CREAT|O_TRUNC|O_RDWR,
+                      0600, &hsize);
        ok1(tdb);
 
        key.dsize = strlen("hi");
@@ -52,19 +57,19 @@ int main(int argc, char *argv[])
        data.dptr = (void *)"world";
        data.dsize = strlen("world");
 
-       ok1(tdb1_store(tdb, key, data, TDB_INSERT) == 0);
+       ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS);
 
        ok1(external_agent_operation1(agent, OPEN, tdb->name) == SUCCESS);
 
        ok1(tdb1_transaction_start(tdb) == 0);
        ok1(external_agent_operation1(agent, TRANSACTION_START, tdb->name)
            == WOULD_HAVE_BLOCKED);
-       tdb1_traverse(tdb, traverse, NULL);
+       tdb_traverse(tdb, traverse, NULL);
 
        /* That should *not* release the transaction lock! */
        ok1(external_agent_operation1(agent, TRANSACTION_START, tdb->name)
            == WOULD_HAVE_BLOCKED);
-       tdb1_traverse_read(tdb, traverse, NULL);
+       tdb_traverse(tdb, traverse, NULL);
 
        /* That should *not* release the transaction lock! */
        ok1(external_agent_operation1(agent, TRANSACTION_START, tdb->name)
@@ -74,7 +79,7 @@ int main(int argc, char *argv[])
        ok1(external_agent_operation1(agent, TRANSACTION_START, tdb->name)
            == SUCCESS);
 
-       tdb1_close(tdb);
+       tdb_close(tdb);
 
        return exit_status();
 }