local n = 1 local function test(res, ermsg) if not res then error(ermsg) else print("ok",n) n = n + 1 end end local lmdb=require'lmdb' local env=lmdb.open("data") test(env,"no env") local txn = env:txn_begin(true) test(txn, "no txn") local db = txn:open() test(db, "no db") db["foo"]="bar" db["the"]="of the" test(db["foo"] == "bar","no eq 1") test(txn:commit()) local txn2 = env:txn_begin() test(txn2,"no txn2") local db2 = txn2:open() test(db2, "no db2") test(db2["the"] == "of the", "no eq 2") test(txn2:commit()) local ok,v = pcall(function() return db2["foo"] end) test(not ok,"shouldn't be able to access db from closed txn") print("ok, got msg",v) print() print("everything good!!!")