unit_tests: add ringdb unit tests

This commit is contained in:
moneromooo-monero 2018-04-09 18:42:22 +01:00
parent 90a16b119f
commit 6a61f520e2
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
4 changed files with 181 additions and 5 deletions

View file

@ -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)