Cursors get closed after transaction that open them
Some checks failed
Main LMDBAL workfow / Test LMDBAL with qt5 (push) Failing after 1m4s
Main LMDBAL workfow / Test LMDBAL with qt6 (push) Successful in 1m24s
Main LMDBAL workfow / Release documentation (push) Has been skipped

This commit is contained in:
Blue 2024-12-24 14:59:58 +02:00
parent 68ea7df6a9
commit e88efb458f
Signed by: blue
GPG key ID: 9B203B252A63EE38
12 changed files with 225 additions and 56 deletions

View file

@ -402,7 +402,7 @@ TEST_F(CacheCursorTest, CursorRAIIBehaviour) {
TEST_F(CacheCursorTest, CornerCases) {
transaction.terminate();
EXPECT_THROW(cursor.current(), LMDBAL::Unknown);
EXPECT_THROW(cursor.current(), LMDBAL::CursorNotReady);
cursor.close();
LMDBAL::Cursor<uint64_t, std::string> emptyCursor = emptyCache->createCursor();

View file

@ -380,7 +380,7 @@ TEST_F(StorageCursorTest, CursorRAIIBehaviour) {
TEST_F(StorageCursorTest, CornerCases) {
EXPECT_EQ(getTableCursorsSize(), 1);
transaction.terminate();
EXPECT_THROW(cursor.current(), LMDBAL::Unknown);
EXPECT_THROW(cursor.current(), LMDBAL::CursorNotReady);
cursor.close();
LMDBAL::Cursor<uint64_t, std::string> emptyCursor = emptyTable->createCursor();
@ -414,4 +414,18 @@ TEST_F(StorageCursorTest, CornerCases) {
EXPECT_EQ(element.first, reference->first);
EXPECT_EQ(element.second, reference->second);
EXPECT_THROW(cursor.prev(), LMDBAL::NotFound);
cursor.close();
}
TEST_F(StorageCursorTest, TerminatedTransaction) {
LMDBAL::Cursor<uint64_t, std::string> emptyCursor = table->createCursor();
{
LMDBAL::Transaction txn = db->beginReadOnlyTransaction();
cursor.open(txn);
EXPECT_NO_THROW(cursor.first());
}
EXPECT_FALSE(cursor.opened());
}