Skip to content

Commit 7483090

Browse files
authoredJan 8, 2025··
Merge pull request #1306 from jbesraa/2024-12-18-pool-bad-cb-config
Test Pool role behavior if bad `coinbase_output` is provided
2 parents dbc349b + 3201b7e commit 7483090

File tree

4 files changed

+37
-210
lines changed

4 files changed

+37
-210
lines changed
 

‎.github/workflows/mg.yaml

+2-14
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,6 @@ on:
1111
- main
1212

1313
jobs:
14-
bad-pool-config-test:
15-
runs-on: ubuntu-latest
16-
steps:
17-
- name: Checkout repository
18-
uses: actions/checkout@v4
19-
- name: Install cargo-llvm-cov
20-
run: cargo install cargo-llvm-cov
21-
- name: Run bad-pool-config-test
22-
run: sh ./test/message-generator/test/bad-pool-config-test/bad-pool-config-test.sh
23-
2414
interop-jd-translator:
2515
runs-on: ubuntu-latest
2616
steps:
@@ -167,7 +157,6 @@ jobs:
167157
runs-on: ubuntu-latest
168158
if: always()
169159
needs: [
170-
bad-pool-config-test,
171160
interop-jd-translator,
172161
interop-proxy-with-multi-ups,
173162
interop-proxy-with-multi-ups-extended,
@@ -188,8 +177,7 @@ jobs:
188177
steps:
189178
- name: Aggregate Results
190179
run: |
191-
if [ "${{ needs.bad-pool-config-test.result }}" != "success" ] ||
192-
[ "${{ needs.interop-jd-translator.result }}" != "success" ] ||
180+
if [ "${{ needs.interop-jd-translator.result }}" != "success" ] ||
193181
[ "${{ needs.interop-proxy-with-multi-ups.result }}" != "success" ] ||
194182
[ "${{ needs.interop-proxy-with-multi-ups-extended.result }}" != "success" ] ||
195183
[ "${{ needs.jds-do-not-fail-on-wrong-tsdatasucc.result }}" != "success" ] ||
@@ -209,4 +197,4 @@ jobs:
209197
exit 1
210198
else
211199
echo "All MG tests completed successfully"
212-
fi
200+
fi

‎roles/pool/src/lib/mod.rs

+35
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,38 @@ impl PoolSv2 {
101101
}
102102
}
103103
}
104+
105+
#[cfg(test)]
106+
mod tests {
107+
use super::*;
108+
use ext_config::{Config, File, FileFormat};
109+
110+
#[tokio::test]
111+
async fn pool_bad_coinbase_output() {
112+
let invalid_coinbase_output = vec![mining_pool::CoinbaseOutput::new(
113+
"P2PK".to_string(),
114+
"wrong".to_string(),
115+
)];
116+
let config_path = "config-examples/pool-config-hosted-tp-example.toml";
117+
let mut config: Configuration = match Config::builder()
118+
.add_source(File::new(config_path, FileFormat::Toml))
119+
.build()
120+
{
121+
Ok(settings) => match settings.try_deserialize::<Configuration>() {
122+
Ok(c) => c,
123+
Err(e) => {
124+
error!("Failed to deserialize config: {}", e);
125+
return;
126+
}
127+
},
128+
Err(e) => {
129+
error!("Failed to build config: {}", e);
130+
return;
131+
}
132+
};
133+
config.coinbase_outputs = invalid_coinbase_output;
134+
let pool = PoolSv2::new(config);
135+
let result = pool.start().await;
136+
assert!(result.is_err());
137+
}
138+
}

‎test/message-generator/test/bad-pool-config-test/bad-pool-config-test.json

-187
This file was deleted.

‎test/message-generator/test/bad-pool-config-test/bad-pool-config-test.sh

-9
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.