Skip to content

Commit

Permalink
Test Pool role behavior if bad coinbase_output..
Browse files Browse the repository at this point in the history
is provided
  • Loading branch information
jbesraa committed Dec 18, 2024
1 parent bf68d8e commit 922ec72
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions roles/pool/src/lib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,38 @@ impl PoolSv2 {
}
}
}

#[cfg(test)]
mod tests {
use super::*;
use ext_config::{Config, File, FileFormat};

#[tokio::test]
async fn pool_bad_coinbase_output() {
let invalid_coinbase_output = vec![mining_pool::CoinbaseOutput::new(
"P2PK".to_string(),
"04466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f276728176c3c6431f8eeda4538dc37c865e2784f3a9e77d044f33e407797e1278".to_string(),
)];
let config_path = "config-examples/pool-config-hosted-tp-example.toml";
let mut config: Configuration = match Config::builder()
.add_source(File::new(config_path, FileFormat::Toml))
.build()
{
Ok(settings) => match settings.try_deserialize::<Configuration>() {
Ok(c) => c,
Err(e) => {
error!("Failed to deserialize config: {}", e);
return;
}
},
Err(e) => {
error!("Failed to build config: {}", e);
return;
}
};
config.coinbase_outputs = invalid_coinbase_output;
let pool = PoolSv2::new(config);
let result = pool.start().await;
assert!(result.is_err());
}
}

0 comments on commit 922ec72

Please sign in to comment.