Skip to content

Commit

Permalink
Fix zebrad state write tests
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 committed Nov 27, 2023
1 parent e5576c4 commit 98a0f60
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
16 changes: 15 additions & 1 deletion zebra-state/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,12 +458,26 @@ pub(crate) fn database_format_version_at_path(

// Hide this destructive method from the public API, except in tests.
#[allow(unused_imports)]
pub(crate) use hidden::write_database_format_version_to_disk;
pub(crate) use hidden::{
write_database_format_version_to_disk, write_state_database_format_version_to_disk,
};

pub(crate) mod hidden {

use super::*;

/// Writes `changed_version` to the on-disk state database after the format is changed.
/// (Or a new database is created.)
///
/// See `write_database_format_version_to_disk()` for details.
pub fn write_state_database_format_version_to_disk(
config: &Config,
changed_version: &Version,
network: Network,
) -> Result<(), BoxError> {
write_database_format_version_to_disk(config, STATE_DATABASE_KIND, changed_version, network)
}

/// Writes `changed_version` to the on-disk database after the format is changed.
/// (Or a new database is created.)
///
Expand Down
8 changes: 6 additions & 2 deletions zebra-state/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,14 @@ pub use service::{
};

#[cfg(not(any(test, feature = "proptest-impl")))]
pub(crate) use config::hidden::write_database_format_version_to_disk;
pub(crate) use config::hidden::{
write_database_format_version_to_disk, write_state_database_format_version_to_disk,
};

#[cfg(any(test, feature = "proptest-impl"))]
pub use config::hidden::write_database_format_version_to_disk;
pub use config::hidden::{
write_database_format_version_to_disk, write_state_database_format_version_to_disk,
};

#[cfg(any(test, feature = "proptest-impl"))]
pub use constants::latest_version_for_adding_subtrees;
Expand Down
8 changes: 6 additions & 2 deletions zebrad/tests/acceptance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2625,8 +2625,12 @@ async fn state_format_test(
.zebrad_config(test_name, false, Some(dir.path()), network)
.expect("already checked config")?;

zebra_state::write_database_format_version_to_disk(fake_version, &config.state, network)
.expect("can't write fake database version to disk");
zebra_state::write_state_database_format_version_to_disk(
&config.state,
fake_version,
network,
)
.expect("can't write fake database version to disk");

// Give zebra_state enough time to actually write the database version to disk.
tokio::time::sleep(Duration::from_secs(1)).await;
Expand Down

0 comments on commit 98a0f60

Please sign in to comment.