Skip to content

Commit 7a23180

Browse files
authored
Merge pull request #6103 from fdefelici/test/remove-mut-on-test-utils
test: remove unsused mutable from test utils to improve usabilty
2 parents 1015b9f + f1c9110 commit 7a23180

File tree

7 files changed

+161
-161
lines changed

7 files changed

+161
-161
lines changed

testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,7 +2121,7 @@ impl BitcoinRegtestController {
21212121
/// Produce `num_blocks` regtest bitcoin blocks, sending the bitcoin coinbase rewards
21222122
/// to the bitcoin single sig addresses corresponding to `pks` in a round robin fashion.
21232123
#[cfg(test)]
2124-
pub fn bootstrap_chain_to_pks(&mut self, num_blocks: usize, pks: &[Secp256k1PublicKey]) {
2124+
pub fn bootstrap_chain_to_pks(&self, num_blocks: usize, pks: &[Secp256k1PublicKey]) {
21252125
info!("Creating wallet if it does not exist");
21262126
if let Err(e) = self.create_wallet_if_dne() {
21272127
error!("Error when creating wallet: {e:?}");
@@ -2280,7 +2280,7 @@ impl BurnchainController for BitcoinRegtestController {
22802280
}
22812281

22822282
#[cfg(test)]
2283-
fn bootstrap_chain(&mut self, num_blocks: u64) {
2283+
fn bootstrap_chain(&self, num_blocks: u64) {
22842284
let Some(ref local_mining_pubkey) = &self.config.burnchain.local_mining_public_key else {
22852285
warn!("No local mining pubkey while bootstrapping bitcoin regtest, will not generate bitcoin blocks");
22862286
return;

testnet/stacks-node/src/burnchains/mocknet_controller.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ impl BurnchainController for MocknetController {
309309
}
310310

311311
#[cfg(test)]
312-
fn bootstrap_chain(&mut self, _num_blocks: u64) {}
312+
fn bootstrap_chain(&self, _num_blocks: u64) {}
313313

314314
fn connect_dbs(&mut self) -> Result<(), BurnchainControllerError> {
315315
Ok(())

testnet/stacks-node/src/burnchains/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub trait BurnchainController {
5656
fn get_stacks_epochs(&self) -> EpochList;
5757

5858
#[cfg(test)]
59-
fn bootstrap_chain(&mut self, blocks_count: u64);
59+
fn bootstrap_chain(&self, blocks_count: u64);
6060
}
6161

6262
#[derive(Debug, Clone)]

testnet/stacks-node/src/tests/nakamoto_integrations.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ pub fn naka_neon_integration_conf(seed: Option<&[u8]>) -> (Config, StacksAddress
662662
}
663663

664664
pub fn next_block_and<F>(
665-
btc_controller: &mut BitcoinRegtestController,
665+
btc_controller: &BitcoinRegtestController,
666666
timeout_secs: u64,
667667
mut check: F,
668668
) -> Result<(), String>
@@ -673,12 +673,12 @@ where
673673
}
674674

675675
pub fn next_block_and_controller<F>(
676-
btc_controller: &mut BitcoinRegtestController,
676+
btc_controller: &BitcoinRegtestController,
677677
timeout_secs: u64,
678678
mut check: F,
679679
) -> Result<(), String>
680680
where
681-
F: FnMut(&mut BitcoinRegtestController) -> Result<bool, String>,
681+
F: FnMut(&BitcoinRegtestController) -> Result<bool, String>,
682682
{
683683
eprintln!("Issuing bitcoin block");
684684
btc_controller.build_next_block(1);
@@ -711,7 +711,7 @@ where
711711
/// Mine a bitcoin block, and wait until:
712712
/// (1) a new block has been processed by the coordinator
713713
pub fn next_block_and_process_new_stacks_block(
714-
btc_controller: &mut BitcoinRegtestController,
714+
btc_controller: &BitcoinRegtestController,
715715
timeout_secs: u64,
716716
coord_channels: &Arc<Mutex<CoordinatorChannels>>,
717717
) -> Result<(), String> {
@@ -736,7 +736,7 @@ pub fn next_block_and_process_new_stacks_block(
736736
/// (2) 2 block commits have been issued ** or ** more than 10 seconds have
737737
/// passed since (1) occurred
738738
pub fn next_block_and_mine_commit(
739-
btc_controller: &mut BitcoinRegtestController,
739+
btc_controller: &BitcoinRegtestController,
740740
timeout_secs: u64,
741741
node_conf: &Config,
742742
node_counters: &Counters,
@@ -753,7 +753,7 @@ pub fn next_block_and_mine_commit(
753753
/// Mine a bitcoin block, and wait until a block-commit has been issued, **or** a timeout occurs
754754
/// (timeout_secs)
755755
pub fn next_block_and_commits_only(
756-
btc_controller: &mut BitcoinRegtestController,
756+
btc_controller: &BitcoinRegtestController,
757757
timeout_secs: u64,
758758
node_conf: &Config,
759759
node_counters: &Counters,
@@ -773,7 +773,7 @@ pub fn next_block_and_commits_only(
773773
/// passed since (1) occurred
774774
/// This waits for this check to pass on *all* supplied channels
775775
pub fn next_block_and_wait_for_commits(
776-
btc_controller: &mut BitcoinRegtestController,
776+
btc_controller: &BitcoinRegtestController,
777777
timeout_secs: u64,
778778
node_confs: &[&Config],
779779
node_counters: &[&Counters],
@@ -1237,7 +1237,7 @@ pub fn setup_epoch_3_reward_set(
12371237
blocks_processed: &Arc<AtomicU64>,
12381238
stacker_sks: &[StacksPrivateKey],
12391239
signer_sks: &[StacksPrivateKey],
1240-
btc_regtest_controller: &mut BitcoinRegtestController,
1240+
btc_regtest_controller: &BitcoinRegtestController,
12411241
num_stacking_cycles: Option<u64>,
12421242
) {
12431243
assert_eq!(stacker_sks.len(), signer_sks.len());
@@ -1329,7 +1329,7 @@ pub fn boot_to_epoch_3_reward_set_calculation_boundary(
13291329
blocks_processed: &Arc<AtomicU64>,
13301330
stacker_sks: &[StacksPrivateKey],
13311331
signer_sks: &[StacksPrivateKey],
1332-
btc_regtest_controller: &mut BitcoinRegtestController,
1332+
btc_regtest_controller: &BitcoinRegtestController,
13331333
num_stacking_cycles: Option<u64>,
13341334
) {
13351335
setup_epoch_3_reward_set(
@@ -1374,7 +1374,7 @@ pub fn boot_to_epoch_3_reward_set_calculation_boundary(
13741374
pub fn boot_to_epoch_25(
13751375
naka_conf: &Config,
13761376
blocks_processed: &Arc<AtomicU64>,
1377-
btc_regtest_controller: &mut BitcoinRegtestController,
1377+
btc_regtest_controller: &BitcoinRegtestController,
13781378
) {
13791379
let epochs = naka_conf.burnchain.epochs.clone().unwrap();
13801380
let epoch_25 = &epochs[StacksEpochId::Epoch25];
@@ -1417,7 +1417,7 @@ pub fn boot_to_epoch_3_reward_set(
14171417
blocks_processed: &Arc<AtomicU64>,
14181418
stacker_sks: &[StacksPrivateKey],
14191419
signer_sks: &[StacksPrivateKey],
1420-
btc_regtest_controller: &mut BitcoinRegtestController,
1420+
btc_regtest_controller: &BitcoinRegtestController,
14211421
num_stacking_cycles: Option<u64>,
14221422
) {
14231423
boot_to_epoch_3_reward_set_calculation_boundary(
@@ -9156,7 +9156,7 @@ fn utxo_check_on_startup_panic() {
91569156
btcd_controller
91579157
.start_bitcoind()
91589158
.expect("Failed starting bitcoind");
9159-
let mut btc_regtest_controller = BitcoinRegtestController::new(naka_conf.clone(), None);
9159+
let btc_regtest_controller = BitcoinRegtestController::new(naka_conf.clone(), None);
91609160
// Do not fully bootstrap the chain, so that the UTXOs are not yet available
91619161
btc_regtest_controller.bootstrap_chain(99);
91629162

@@ -9232,7 +9232,7 @@ fn utxo_check_on_startup_recover() {
92329232
btcd_controller
92339233
.start_bitcoind()
92349234
.expect("Failed starting bitcoind");
9235-
let mut btc_regtest_controller = BitcoinRegtestController::new(naka_conf.clone(), None);
9235+
let btc_regtest_controller = BitcoinRegtestController::new(naka_conf.clone(), None);
92369236
// Do not fully bootstrap the chain, so that the UTXOs are not yet available
92379237
btc_regtest_controller.bootstrap_chain(99);
92389238
// btc_regtest_controller.bootstrap_chain(108);
@@ -9905,11 +9905,11 @@ fn test_shadow_recovery() {
99059905
return;
99069906
}
99079907

9908-
let mut signer_test: SignerTest<SpawnedSigner> = SignerTest::new(1, vec![]);
9908+
let signer_test: SignerTest<SpawnedSigner> = SignerTest::new(1, vec![]);
99099909
signer_test.boot_to_epoch_3();
99109910

99119911
let naka_conf = signer_test.running_nodes.conf.clone();
9912-
let btc_regtest_controller = &mut signer_test.running_nodes.btc_regtest_controller;
9912+
let btc_regtest_controller = &signer_test.running_nodes.btc_regtest_controller;
99139913
let counters = signer_test.running_nodes.counters.clone();
99149914

99159915
// make another tenure
@@ -10701,7 +10701,7 @@ fn test_tenure_extend_from_flashblocks() {
1070110701
let deployer_sk = account_keys.pop().unwrap();
1070210702
let deployer_addr = tests::to_addr(&deployer_sk);
1070310703

10704-
let mut signer_test: SignerTest<SpawnedSigner> = SignerTest::new_with_config_modifications(
10704+
let signer_test: SignerTest<SpawnedSigner> = SignerTest::new_with_config_modifications(
1070510705
1,
1070610706
initial_balances,
1070710707
|_| {},
@@ -10714,7 +10714,7 @@ fn test_tenure_extend_from_flashblocks() {
1071410714
let naka_conf = signer_test.running_nodes.conf.clone();
1071510715

1071610716
let http_origin = format!("http://{}", &naka_conf.node.rpc_bind);
10717-
let btc_regtest_controller = &mut signer_test.running_nodes.btc_regtest_controller;
10717+
let btc_regtest_controller = &signer_test.running_nodes.btc_regtest_controller;
1071810718
let coord_channel = signer_test.running_nodes.coord_channel.clone();
1071910719
let counters = signer_test.running_nodes.counters.clone();
1072010720

testnet/stacks-node/src/tests/neon_integrations.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -666,15 +666,15 @@ const PANIC_TIMEOUT_SECS: u64 = 600;
666666

667667
/// Returns `false` on a timeout, true otherwise.
668668
pub fn next_block_and_wait(
669-
btc_controller: &mut BitcoinRegtestController,
669+
btc_controller: &BitcoinRegtestController,
670670
blocks_processed: &Arc<AtomicU64>,
671671
) -> bool {
672672
next_block_and_wait_with_timeout(btc_controller, blocks_processed, PANIC_TIMEOUT_SECS)
673673
}
674674

675675
/// Returns `false` on a timeout, true otherwise.
676676
pub fn next_block_and_wait_with_timeout(
677-
btc_controller: &mut BitcoinRegtestController,
677+
btc_controller: &BitcoinRegtestController,
678678
blocks_processed: &Arc<AtomicU64>,
679679
timeout: u64,
680680
) -> bool {
@@ -702,7 +702,7 @@ pub fn next_block_and_wait_with_timeout(
702702

703703
/// Returns `false` on a timeout, true otherwise.
704704
pub fn next_block_and_iterate(
705-
btc_controller: &mut BitcoinRegtestController,
705+
btc_controller: &BitcoinRegtestController,
706706
blocks_processed: &Arc<AtomicU64>,
707707
iteration_delay_ms: u64,
708708
) -> bool {
@@ -734,7 +734,7 @@ pub fn next_block_and_iterate(
734734
///
735735
/// Returns `false` if `next_block_and_wait` times out.
736736
pub fn run_until_burnchain_height(
737-
btc_regtest_controller: &mut BitcoinRegtestController,
737+
btc_regtest_controller: &BitcoinRegtestController,
738738
blocks_processed: &Arc<AtomicU64>,
739739
target_height: u64,
740740
conf: &Config,
@@ -7337,7 +7337,7 @@ fn test_chainwork_first_intervals() {
73377337
.start_bitcoind()
73387338
.expect("Failed starting bitcoind");
73397339

7340-
let mut btc_regtest_controller = BitcoinRegtestController::new(conf.clone(), None);
7340+
let btc_regtest_controller = BitcoinRegtestController::new(conf.clone(), None);
73417341

73427342
btc_regtest_controller.bootstrap_chain(2016 * 2 - 1);
73437343

@@ -7364,7 +7364,7 @@ fn test_chainwork_partial_interval() {
73647364
.start_bitcoind()
73657365
.expect("Failed starting bitcoind");
73667366

7367-
let mut btc_regtest_controller = BitcoinRegtestController::new(conf.clone(), None);
7367+
let btc_regtest_controller = BitcoinRegtestController::new(conf.clone(), None);
73687368

73697369
btc_regtest_controller.bootstrap_chain(2016 - 1);
73707370

@@ -8345,7 +8345,7 @@ fn push_boot_receipts() {
83458345
.start_bitcoind()
83468346
.expect("Failed starting bitcoind");
83478347

8348-
let mut btc_regtest_controller = BitcoinRegtestController::new(conf.clone(), None);
8348+
let btc_regtest_controller = BitcoinRegtestController::new(conf.clone(), None);
83498349

83508350
btc_regtest_controller.bootstrap_chain(201);
83518351

@@ -9661,7 +9661,7 @@ fn listunspent_max_utxos() {
96619661
.start_bitcoind()
96629662
.expect("Failed starting bitcoind");
96639663

9664-
let mut btc_regtest_controller = BitcoinRegtestController::new(conf.clone(), None);
9664+
let btc_regtest_controller = BitcoinRegtestController::new(conf.clone(), None);
96659665

96669666
btc_regtest_controller.bootstrap_chain(201);
96679667

@@ -9707,7 +9707,7 @@ fn start_stop_bitcoind() {
97079707
.start_bitcoind()
97089708
.expect("Failed starting bitcoind");
97099709

9710-
let mut btc_regtest_controller = BitcoinRegtestController::new(conf, None);
9710+
let btc_regtest_controller = BitcoinRegtestController::new(conf, None);
97119711

97129712
btc_regtest_controller.bootstrap_chain(201);
97139713

0 commit comments

Comments
 (0)