Skip to content

Commit 57d796b

Browse files
committed
fix test build
1 parent 52b2f68 commit 57d796b

File tree

4 files changed

+31
-25
lines changed

4 files changed

+31
-25
lines changed

stacks-signer/src/client/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ pub(crate) mod tests {
144144
use stacks_common::util::hash::{Hash160, Sha256Sum};
145145

146146
use super::*;
147-
use crate::config::{GlobalConfig, SignerConfig};
147+
use crate::config::{GlobalConfig, SignerConfig, SignerConfigMode};
148148

149149
pub struct MockServerClient {
150150
pub server: TcpListener,
@@ -393,8 +393,10 @@ pub(crate) mod tests {
393393
}
394394
SignerConfig {
395395
reward_cycle,
396-
signer_id: 0,
397-
signer_slot_id: SignerSlotID(rand::thread_rng().gen_range(0..num_signers)), // Give a random signer slot id between 0 and num_signers
396+
signer_mode: SignerConfigMode::Normal {
397+
signer_id: 0,
398+
signer_slot_id: SignerSlotID(rand::thread_rng().gen_range(0..num_signers)), // Give a random signer slot id between 0 and num_signers
399+
},
398400
signer_entries: SignerEntries {
399401
signer_addr_to_id,
400402
signer_id_to_pk,

stacks-signer/src/client/stackerdb.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,25 @@ impl<M: MessageSlotID + 'static> From<&SignerConfig> for StackerDB<M> {
8282
}
8383

8484
impl<M: MessageSlotID + 'static> StackerDB<M> {
85-
/// Create a new StackerDB client running in normal operation
85+
#[cfg(any(test, feature = "testing"))]
86+
/// Create a StackerDB client in normal operation (i.e., not a dry-run signer)
87+
pub fn new_normal(
88+
host: &str,
89+
stacks_private_key: StacksPrivateKey,
90+
is_mainnet: bool,
91+
reward_cycle: u64,
92+
signer_slot_id: SignerSlotID,
93+
) -> Self {
94+
Self::new(
95+
host,
96+
stacks_private_key,
97+
is_mainnet,
98+
reward_cycle,
99+
StackerDBMode::Normal { signer_slot_id },
100+
)
101+
}
102+
103+
/// Create a new StackerDB client
86104
fn new(
87105
host: &str,
88106
stacks_private_key: StacksPrivateKey,

testnet/stacks-node/src/tests/signer/mod.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2020-2024 Stacks Open Internet Foundation
1+
// Copyright (C) 2020-2025 Stacks Open Internet Foundation
22
//
33
// This program is free software: you can redistribute it and/or modify
44
// it under the terms of the GNU General Public License as published by
@@ -15,20 +15,6 @@
1515
mod v0;
1616

1717
use std::collections::HashSet;
18-
// Copyright (C) 2020-2024 Stacks Open Internet Foundation
19-
//
20-
// This program is free software: you can redistribute it and/or modify
21-
// it under the terms of the GNU General Public License as published by
22-
// the Free Software Foundation, either version 3 of the License, or
23-
// (at your option) any later version.
24-
//
25-
// This program is distributed in the hope that it will be useful,
26-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
27-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28-
// GNU General Public License for more details.
29-
//
30-
// You should have received a copy of the GNU General Public License
31-
// along with this program. If not, see <http://www.gnu.org/licenses/>.
3218
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
3319
use std::sync::{Arc, Mutex};
3420
use std::thread;
@@ -696,7 +682,7 @@ impl<S: Signer<T> + Send + 'static, T: SignerEventTrait + 'static> SignerTest<Sp
696682

697683
/// Get the latest block response from the given slot
698684
pub fn get_latest_block_response(&self, slot_id: u32) -> BlockResponse {
699-
let mut stackerdb = StackerDB::new(
685+
let mut stackerdb = StackerDB::new_normal(
700686
&self.running_nodes.conf.node.rpc_bind,
701687
StacksPrivateKey::new(), // We are just reading so don't care what the key is
702688
false,
@@ -764,7 +750,7 @@ impl<S: Signer<T> + Send + 'static, T: SignerEventTrait + 'static> SignerTest<Sp
764750
private_key: &StacksPrivateKey,
765751
reward_cycle: u64,
766752
) {
767-
let mut stackerdb = StackerDB::new(
753+
let mut stackerdb = StackerDB::new_normal(
768754
&self.running_nodes.conf.node.rpc_bind,
769755
private_key.clone(),
770756
false,

testnet/stacks-node/src/tests/signer/v0.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3304,7 +3304,7 @@ fn empty_sortition() {
33043304

33053305
info!("------------------------- Test Delayed Block is Rejected -------------------------");
33063306
let reward_cycle = signer_test.get_current_reward_cycle();
3307-
let mut stackerdb = StackerDB::new(
3307+
let mut stackerdb = StackerDB::new_normal(
33083308
&signer_test.running_nodes.conf.node.rpc_bind,
33093309
StacksPrivateKey::new(), // We are just reading so don't care what the key is
33103310
false,
@@ -10157,7 +10157,7 @@ fn incoming_signers_ignore_block_proposals() {
1015710157
.expect("Timed out waiting for a block to be mined");
1015810158

1015910159
let blocks_before = mined_blocks.load(Ordering::SeqCst);
10160-
let mut stackerdb = StackerDB::new(
10160+
let mut stackerdb = StackerDB::new_normal(
1016110161
&signer_test.running_nodes.conf.node.rpc_bind,
1016210162
StacksPrivateKey::new(), // We are just reading so don't care what the key is
1016310163
false,
@@ -10332,7 +10332,7 @@ fn outgoing_signers_ignore_block_proposals() {
1033210332
.unwrap()
1033310333
.signer_signature_hash;
1033410334
let blocks_before = mined_blocks.load(Ordering::SeqCst);
10335-
let mut stackerdb = StackerDB::new(
10335+
let mut stackerdb = StackerDB::new_normal(
1033610336
&signer_test.running_nodes.conf.node.rpc_bind,
1033710337
StacksPrivateKey::new(), // We are just reading so don't care what the key is
1033810338
false,
@@ -10733,7 +10733,7 @@ fn injected_signatures_are_ignored_across_boundaries() {
1073310733

1073410734
// The first 50% of the signers are the ones that are ignoring block proposals and thus haven't sent a signature yet
1073510735
let forced_signer = &signer_test.signer_stacks_private_keys[ignoring_signers.len()];
10736-
let mut stackerdb = StackerDB::new(
10736+
let mut stackerdb = StackerDB::new_normal(
1073710737
&signer_test.running_nodes.conf.node.rpc_bind,
1073810738
forced_signer.clone(),
1073910739
false,

0 commit comments

Comments
 (0)