Skip to content

Commit

Permalink
execution: add ExecutionEngine tests (#2095)
Browse files Browse the repository at this point in the history
  • Loading branch information
JacekGlen authored Jun 17, 2024
1 parent 8407996 commit c398249
Show file tree
Hide file tree
Showing 11 changed files with 824 additions and 77 deletions.
1 change: 1 addition & 0 deletions silkworm/capi/silkworm_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ namespace snapshot_test = snapshots::test_util;
struct CApiTest : public db::test_util::TestDatabaseContext {
TemporaryDirectory tmp_dir;
SilkwormSettings settings{.log_verbosity = SilkwormLogLevel::SILKWORM_LOG_NONE};
mdbx::env_managed& db{get_mdbx_env()};
};

//! Utility to copy `src` C-string to `dst` fixed-size char array
Expand Down
8 changes: 7 additions & 1 deletion silkworm/db/test_util/test_database_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ namespace {

} // namespace

TestDatabaseContext::TestDatabaseContext() : db{initialize_test_database()} {}
TestDatabaseContext::TestDatabaseContext() : db_{initialize_test_database()} {}

silkworm::ChainConfig TestDatabaseContext::get_chain_config() {
db::ROTxnManaged txn{db_};
auto chain_config = db::read_chain_config(txn);
return chain_config ? *chain_config : silkworm::ChainConfig{};
}

} // namespace silkworm::db::test_util
12 changes: 9 additions & 3 deletions silkworm/db/test_util/test_database_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,18 @@ class TestDatabaseContext {
TestDatabaseContext();

~TestDatabaseContext() {
auto db_path = db.get_path();
db.close();
auto db_path = db_.get_path();
db_.close();
std::filesystem::remove_all(db_path);
}

mdbx::env_managed db;
mdbx::env_managed& get_mdbx_env() { return db_; }
db::EnvConfig get_env_config() { return env_config_; }
silkworm::ChainConfig get_chain_config();

private:
mdbx::env_managed db_;
db::EnvConfig env_config_;
};

} // namespace silkworm::db::test_util
Loading

0 comments on commit c398249

Please sign in to comment.