From dd90d7884f03941d5052a22fa69b1cf56644f09e Mon Sep 17 00:00:00 2001 From: katelyn martin Date: Wed, 20 Mar 2024 13:14:22 -0400 Subject: [PATCH] =?UTF-8?q?tests(app):=20=F0=9F=8E=A4=20add=20`app=5Ftrack?= =?UTF-8?q?s=5Fvalidator=5Fuptimes`=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/tests/app_tracks_validator_uptimes.rs | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 crates/core/app/tests/app_tracks_validator_uptimes.rs diff --git a/crates/core/app/tests/app_tracks_validator_uptimes.rs b/crates/core/app/tests/app_tracks_validator_uptimes.rs new file mode 100644 index 0000000000..86db55ab36 --- /dev/null +++ b/crates/core/app/tests/app_tracks_validator_uptimes.rs @@ -0,0 +1,55 @@ +mod common; + +use { + self::common::BuilderExt, cnidarium::TempStorage, penumbra_app::server::consensus::Consensus, + penumbra_genesis::AppState, penumbra_keys::test_keys, penumbra_mock_client::MockClient, + penumbra_mock_consensus::TestNode, tap::Tap, tracing::info, +}; + +/// The length of the [`penumbra_sct`] epoch. +/// +/// This test relies on many epochs turning over, so we will work with a shorter epoch duration. +const EPOCH_DURATION: u64 = 8; + +#[tokio::test] +// ci: ignore this test and allow some specific warnings, until this test is written. +#[ignore = "not written yet"] +#[allow(unused_variables, unused_mut, unreachable_code)] // `todo!` fools some lints. +async fn app_tracks_validator_uptimes() -> anyhow::Result<()> { + // Install a test logger, acquire some temporary storage, and start the test node. + let guard = common::set_tracing_subscriber(); + let storage = TempStorage::new().await?; + + // Configure an AppState with slightly shorter epochs than usual. + let app_state = AppState::Content(penumbra_genesis::Content { + sct_content: penumbra_sct::genesis::Content { + sct_params: penumbra_sct::params::SctParameters { + epoch_duration: EPOCH_DURATION, + }, + }, + ..Default::default() + }); + + // Start the test node. + let mut node = { + let consensus = Consensus::new(storage.as_ref().clone()); + TestNode::builder() + .single_validator() + .with_penumbra_auto_app_state(app_state)? + .init_chain(consensus) + .await + }?; + + // Sync the mock client, using the test wallet's spend key, to the latest snapshot. + let mut client = MockClient::new(test_keys::SPEND_KEY.clone()) + .with_sync_to_storage(&storage) + .await? + .tap(|c| info!(client.notes = %c.notes.len(), "mock client synced to test storage")); + + todo!("write test assertions"); + + Ok(()) + .tap(|_| drop(node)) + .tap(|_| drop(storage)) + .tap(|_| drop(guard)) +}