Skip to content

Commit

Permalink
tests(app): 🎤 add app_tracks_validator_uptimes test
Browse files Browse the repository at this point in the history
  • Loading branch information
cratelyn committed Mar 20, 2024
1 parent 8d09a75 commit dd90d78
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions crates/core/app/tests/app_tracks_validator_uptimes.rs
Original file line number Diff line number Diff line change
@@ -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))
}

0 comments on commit dd90d78

Please sign in to comment.