Skip to content
Permalink
Browse files

Fix ringb wallet closing and add unit tests

  • Loading branch information...
miltonf committed Feb 9, 2019
1 parent 9549488 commit e96ea759f34fb80b92cba307576414b6b9e3cd16
Showing with 18 additions and 6 deletions.
  1. +14 −4 src/wallet/ringdb.cpp
  2. +1 −0 src/wallet/ringdb.h
  3. +2 −1 tests/unit_tests/CMakeLists.txt
  4. +1 −1 tests/unit_tests/ringdb.cpp
@@ -190,7 +190,8 @@ namespace tools
{

ringdb::ringdb(std::string filename, const std::string &genesis):
filename(filename)
filename(filename),
env(NULL)
{
MDB_txn *txn;
bool tx_active = false;
@@ -227,9 +228,18 @@ ringdb::ringdb(std::string filename, const std::string &genesis):

ringdb::~ringdb()
{
mdb_dbi_close(env, dbi_rings);
mdb_dbi_close(env, dbi_blackballs);
mdb_env_close(env);
close();
}

void ringdb::close()
{
if (env)
{
mdb_dbi_close(env, dbi_rings);
mdb_dbi_close(env, dbi_blackballs);
mdb_env_close(env);
env = NULL;
}
}

bool ringdb::add_rings(const crypto::chacha_key &chacha_key, const cryptonote::transaction_prefix &tx)
@@ -41,6 +41,7 @@ namespace tools
{
public:
ringdb(std::string filename, const std::string &genesis);
void close();
~ringdb();

bool add_rings(const crypto::chacha_key &chacha_key, const cryptonote::transaction_prefix &tx);
@@ -68,7 +68,8 @@ set(unit_tests_sources
varint.cpp
ringct.cpp
output_selection.cpp
vercmp.cpp)
vercmp.cpp
ringdb.cpp)

set(unit_tests_headers
unit_tests_utils.h)
@@ -164,4 +164,4 @@ TEST(blackball, clear)
ASSERT_TRUE(ringdb.blackball(OUTPUT_1));
ASSERT_TRUE(ringdb.clear_blackballs());
ASSERT_FALSE(ringdb.blackballed(OUTPUT_1));
}
}

0 comments on commit e96ea75

Please sign in to comment.
You can’t perform that action at this time.