Skip to content

Commit

Permalink
feat(tests): 💐 pass abci server into test node
Browse files Browse the repository at this point in the history
  • Loading branch information
cratelyn committed Feb 9, 2024
1 parent d7113bd commit fd86535
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
11 changes: 8 additions & 3 deletions crates/core/app/tests/mock_consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
// Note: these should eventually replace the existing test cases. mock consensus tests are placed
// here while the engine is still in development. See #3588.

use {cnidarium::TempStorage, penumbra_app::app::App, penumbra_mock_consensus::TestNode};
use {cnidarium::TempStorage, penumbra_mock_consensus::TestNode};

#[tokio::test]
#[should_panic]
#[allow(unreachable_code, unused)]
async fn an_app_with_mock_consensus_can_be_instantiated() {
let storage = TempStorage::new().await.unwrap();
let app = App::new(storage.latest_snapshot());

// TODO(kate): bind this to an in-memory channel/writer instead.
let addr: std::net::SocketAddr = todo!();
let abci_server = penumbra_app::server::new(todo!()).listen_tcp(addr);

let _engine = TestNode::<()>::builder()
.single_validator()
.app_state(() /*genesis::AppState::default()*/)
.init_chain(app)
.init_chain(abci_server)
.await;
}
19 changes: 8 additions & 11 deletions crates/test/mock-consensus/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub struct TestNode<A> {
_app: A,
pub struct TestNode<S> {
#[allow(dead_code)]
abci_server: S,
_last_app_hash: Vec<u8>,
}

Expand Down Expand Up @@ -35,14 +36,10 @@ impl Builder {
todo!()
}

// this should take the `consensus` thing from pd/main.rs
pub async fn init_chain<A>(self, _: A) -> TestNode<A> {
// https://rustdoc.penumbra.zone/main/tower_abci/v037/struct.ServerBuilder.html
// Engine should be parameterized by the C here
// init_chain should be parameterized by the C here
//
// C: Service<ConsensusRequest, Response = ConsensusResponse, Error = BoxError> + Send + Clone + 'static,
// C::Future: Send + 'static,
todo!()
pub async fn init_chain<S>(self, abci_server: S) -> TestNode<S> {
TestNode {
abci_server,
_last_app_hash: vec![],
}
}
}

0 comments on commit fd86535

Please sign in to comment.