-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`Sniffer` allows intercepting messages exchanged between two roles, enabling testing whether a message have been sent/received by a downstream/upstream role.
- Loading branch information
Showing
4 changed files
with
55 additions
and
67 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,16 @@ | ||
use std::str::FromStr; | ||
|
||
mod common; | ||
|
||
#[tokio::test] | ||
async fn success_pool_template_provider_connection() { | ||
assert!(common::start_template_provider_and_pool().await.is_ok()); | ||
} | ||
|
||
#[tokio::test] | ||
async fn pool_bad_coinbase_output() { | ||
let (template_provider, template_provider_port) = common::start_template_provider().await; | ||
let invalid_coinbase_output = vec![pool_sv2::mining_pool::CoinbaseOutput::new( | ||
"P2PK".to_string(), | ||
"04466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f276728176c3c6431f8eeda4538dc37c865e2784f3a9e77d044f33e407797e1278".to_string(), | ||
)]; | ||
let template_provider_address = | ||
std::net::SocketAddr::from_str(&format!("127.0.0.1:{}", template_provider_port)).unwrap(); | ||
let test_pool = common::TestPoolSv2::new( | ||
None, | ||
Some(invalid_coinbase_output), | ||
Some(template_provider_address), | ||
); | ||
let pool = test_pool.pool.clone(); | ||
let state = pool.state().await.safe_lock(|s| s.clone()).unwrap(); | ||
assert_eq!(state, pool_sv2::PoolState::Initial); | ||
assert!(pool.start().await.is_err()); | ||
let state = pool.state().await.safe_lock(|s| s.clone()).unwrap(); | ||
assert_eq!(state, pool_sv2::PoolState::Initial); | ||
template_provider.stop(); | ||
let sniffer_addr = common::get_available_address(); | ||
let tp_addr = common::get_available_address(); | ||
let pool_addr = common::get_available_address(); | ||
let _tp = common::start_template_provider(tp_addr.port()).await; | ||
let sniffer = common::start_sniffer(tp_addr, sniffer_addr).await; | ||
let _ = common::start_pool(Some(pool_addr), None, Some(sniffer_addr)).await; | ||
assert!(sniffer.expect_downstream_setup_connection()); | ||
assert!(sniffer.expect_upstream_setup_connection_success()); | ||
assert!(sniffer.expect_downstream_coinbase_output_data_size()); | ||
assert!(sniffer.expect_upstream_new_template()); | ||
assert!(sniffer.expect_upstream_set_new_prev_hash()); | ||
} |