Skip to content

Commit 69ea12c

Browse files
author
Braydon Fuller
committed
tests: test dbwrapper options compression and maxopenfiles
1 parent 1b36e2c commit 69ea12c

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/test/dbwrapper_tests.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,49 @@ BOOST_AUTO_TEST_CASE(dbwrapper)
4747
}
4848
}
4949

50+
BOOST_AUTO_TEST_CASE(dbwrapper_compression)
51+
{
52+
// Perform tests both with compression and without
53+
for (int i = 0; i < 2; i++) {
54+
bool compression = (bool)i;
55+
path ph = temp_directory_path() / unique_path();
56+
CDBWrapper dbw(ph, (1 << 20), true, false, false, compression);
57+
char key = 'k';
58+
uint256 in = GetRandHash();
59+
uint256 res;
60+
61+
BOOST_CHECK(dbw.Write(key, in));
62+
BOOST_CHECK(dbw.Read(key, res));
63+
BOOST_CHECK_EQUAL(res.ToString(), in.ToString());
64+
}
65+
}
66+
67+
BOOST_AUTO_TEST_CASE(dbwrapper_maxopenfiles_64)
68+
{
69+
path ph = temp_directory_path() / unique_path();
70+
CDBWrapper dbw(ph, (1 << 20), true, false, false, false, 64);
71+
char key = 'k';
72+
uint256 in = GetRandHash();
73+
uint256 res;
74+
75+
BOOST_CHECK(dbw.Write(key, in));
76+
BOOST_CHECK(dbw.Read(key, res));
77+
BOOST_CHECK_EQUAL(res.ToString(), in.ToString());
78+
}
79+
80+
BOOST_AUTO_TEST_CASE(dbwrapper_maxopenfiles_1000)
81+
{
82+
path ph = temp_directory_path() / unique_path();
83+
CDBWrapper dbw(ph, (1 << 20), true, false, false, false, 1000);
84+
char key = 'k';
85+
uint256 in = GetRandHash();
86+
uint256 res;
87+
88+
BOOST_CHECK(dbw.Write(key, in));
89+
BOOST_CHECK(dbw.Read(key, res));
90+
BOOST_CHECK_EQUAL(res.ToString(), in.ToString());
91+
}
92+
5093
// Test batch operations
5194
BOOST_AUTO_TEST_CASE(dbwrapper_batch)
5295
{

0 commit comments

Comments
 (0)