Skip to content

Commit

Permalink
Merge pull request #1306 from jbesraa/2024-12-18-pool-bad-cb-config
Browse files Browse the repository at this point in the history
Test Pool role behavior if bad `coinbase_output` is provided
  • Loading branch information
plebhash authored Jan 8, 2025
2 parents dbc349b + 3201b7e commit 7483090
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 210 deletions.
16 changes: 2 additions & 14 deletions .github/workflows/mg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ on:
- main

jobs:
bad-pool-config-test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install cargo-llvm-cov
run: cargo install cargo-llvm-cov
- name: Run bad-pool-config-test
run: sh ./test/message-generator/test/bad-pool-config-test/bad-pool-config-test.sh

interop-jd-translator:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -167,7 +157,6 @@ jobs:
runs-on: ubuntu-latest
if: always()
needs: [
bad-pool-config-test,
interop-jd-translator,
interop-proxy-with-multi-ups,
interop-proxy-with-multi-ups-extended,
Expand All @@ -188,8 +177,7 @@ jobs:
steps:
- name: Aggregate Results
run: |
if [ "${{ needs.bad-pool-config-test.result }}" != "success" ] ||
[ "${{ needs.interop-jd-translator.result }}" != "success" ] ||
if [ "${{ needs.interop-jd-translator.result }}" != "success" ] ||
[ "${{ needs.interop-proxy-with-multi-ups.result }}" != "success" ] ||
[ "${{ needs.interop-proxy-with-multi-ups-extended.result }}" != "success" ] ||
[ "${{ needs.jds-do-not-fail-on-wrong-tsdatasucc.result }}" != "success" ] ||
Expand All @@ -209,4 +197,4 @@ jobs:
exit 1
else
echo "All MG tests completed successfully"
fi
fi
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(),
"wrong".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());
}
}

This file was deleted.

This file was deleted.

0 comments on commit 7483090

Please sign in to comment.