Skip to content

Commit

Permalink
Merge pull request #1 from coleFD/gitgab/test-fix
Browse files Browse the repository at this point in the history
fix pool coinbase output test for config changes
  • Loading branch information
GitGab19 authored Mar 27, 2023
2 parents c4a2b27 + 6338932 commit e1f8e5e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions roles/v2/pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ tracing-subscriber = "0.3"
async-recursion = "1.0.0"
error_handling = { version = "0.1", path = "../../../utils/error-handling" }

[dev-dependencies]
hex = "0.4.3"

[features]
test_only_allow_unencrypted = []
11 changes: 6 additions & 5 deletions roles/v2/pool/src/lib/mining_pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,16 +541,18 @@ impl Pool {

#[cfg(test)]
mod test {
use crate::PublicKeyWrapper;
use binary_sv2::{B0255, B064K};
use bitcoin::{util::psbt::serialize::Serialize, Transaction};
use bitcoin::{util::psbt::serialize::Serialize, PublicKey, Transaction};
use hex;
use std::convert::TryInto;
// this test is used to verify the `coinbase_tx_prefix` and `coinbase_tx_suffix` values tested against in
// message generator `stratum/test/message-generator/test/pool-sri-test-extended.json`
#[test]
fn test_coinbase_outputs_from_config() {
// Load config
let config: crate::Configuration =
toml::from_str(&std::fs::read_to_string("pool-config.toml").unwrap()).unwrap();
let output: PublicKey = PublicKey::from_slice(&hex::decode("04466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f276728176c3c6431f8eeda4538dc37c865e2784f3a9e77d044f33e407797e1278a").unwrap()).unwrap();
let outputs = vec![PublicKeyWrapper { pub_key: output }];
// template from message generator test (mock TP template)
let _extranonce_len = 3;
let coinbase_prefix = vec![1, 16, 0];
Expand All @@ -560,8 +562,7 @@ mod test {
let _coinbase_tx_value_remaining: u64 = 5000000000;
let _coinbase_tx_outputs_count = 0;
let coinbase_tx_locktime = 0;
let coinbase_tx_outputs: Vec<bitcoin::TxOut> = config
.coinbase_outputs
let coinbase_tx_outputs: Vec<bitcoin::TxOut> = outputs
.iter()
.map(|pub_key_wrapper| bitcoin::TxOut {
value: crate::BLOCK_REWARD,
Expand Down

0 comments on commit e1f8e5e

Please sign in to comment.