Skip to content

Commit 2ee25e4

Browse files
committed
build: use feature = "testing" to build stackslib test code, and suppress unused warnings in tests
1 parent f20061f commit 2ee25e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+162
-147
lines changed

stackslib/src/burnchains/bitcoin/indexer.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl BitcoinIndexerConfig {
167167
}
168168
}
169169

170-
#[cfg(test)]
170+
#[cfg(any(test, feature = "testing"))]
171171
pub fn test_default(spv_headers_path: String) -> BitcoinIndexerConfig {
172172
BitcoinIndexerConfig {
173173
peer_host: "127.0.0.1".to_string(),
@@ -203,7 +203,7 @@ impl BitcoinIndexerRuntime {
203203
}
204204

205205
impl BitcoinIndexer {
206-
#[cfg(test)]
206+
#[cfg(any(test, feature = "testing"))]
207207
pub fn new(
208208
config: BitcoinIndexerConfig,
209209
runtime: BitcoinIndexerRuntime,
@@ -216,7 +216,7 @@ impl BitcoinIndexer {
216216
}
217217
}
218218

219-
#[cfg(test)]
219+
#[cfg(any(test, feature = "testing"))]
220220
pub fn new_unit_test(working_dir: &str) -> BitcoinIndexer {
221221
let mut working_dir_path = PathBuf::from(working_dir);
222222
if fs::metadata(&working_dir_path).is_err() {
@@ -861,7 +861,7 @@ impl BitcoinIndexer {
861861
Ok(new_tip)
862862
}
863863

864-
#[cfg(test)]
864+
#[cfg(any(test, feature = "testing"))]
865865
pub fn raw_store_header(&mut self, header: BurnchainBlockHeader) -> Result<(), btc_error> {
866866
let mut spv_client = SpvClient::new(
867867
&self.config.spv_headers_path,
@@ -887,7 +887,7 @@ impl BitcoinIndexer {
887887
Ok(())
888888
}
889889

890-
#[cfg(test)]
890+
#[cfg(any(test, feature = "testing"))]
891891
pub fn mock_bitcoin_header(
892892
parent_block_hash: &BurnchainHeaderHash,
893893
timestamp: u32,

stackslib/src/burnchains/bitcoin/spv.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl SpvClient {
182182
Ok(client)
183183
}
184184

185-
#[cfg(test)]
185+
#[cfg(any(test, feature = "testing"))]
186186
pub fn new_without_migration(
187187
headers_path: &str,
188188
start_block: u64,
@@ -211,7 +211,7 @@ impl SpvClient {
211211
Ok(client)
212212
}
213213

214-
#[cfg(test)]
214+
#[cfg(any(test, feature = "testing"))]
215215
pub fn disable_check_txcount(&mut self) {
216216
self.check_txcount = false;
217217
}
@@ -220,7 +220,7 @@ impl SpvClient {
220220
&self.headers_db
221221
}
222222

223-
#[cfg(test)]
223+
#[cfg(any(test, feature = "testing"))]
224224
pub fn conn_mut(&mut self) -> &mut DBConn {
225225
&mut self.headers_db
226226
}
@@ -277,7 +277,7 @@ impl SpvClient {
277277
.and_then(|_| Ok(()))
278278
}
279279

280-
#[cfg(test)]
280+
#[cfg(any(test, feature = "testing"))]
281281
pub fn test_db_migrate(conn: &mut DBConn) -> Result<(), btc_error> {
282282
SpvClient::db_migrate(conn)
283283
}
@@ -925,7 +925,7 @@ impl SpvClient {
925925
Ok(())
926926
}
927927

928-
#[cfg(test)]
928+
#[cfg(any(test, feature = "testing"))]
929929
pub fn test_write_block_headers(
930930
&mut self,
931931
height: u64,

stackslib/src/burnchains/burnchain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ impl Burnchain {
623623
ret
624624
}
625625

626-
#[cfg(test)]
626+
#[cfg(any(test, feature = "testing"))]
627627
pub fn default_unittest(
628628
first_block_height: u64,
629629
first_block_hash: &BurnchainHeaderHash,

stackslib/src/burnchains/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub mod burnchain;
5757
pub mod db;
5858
pub mod indexer;
5959

60-
#[cfg(test)]
60+
#[cfg(any(test, feature = "testing"))]
6161
pub mod tests;
6262

6363
pub struct Txid(pub [u8; 32]);
@@ -351,7 +351,7 @@ impl PoxConstants {
351351
_shadow: PhantomData,
352352
}
353353
}
354-
#[cfg(test)]
354+
#[cfg(any(test, feature = "testing"))]
355355
pub fn test_default() -> PoxConstants {
356356
// 20 reward slots; 10 prepare-phase slots
357357
PoxConstants::new(
@@ -369,7 +369,7 @@ impl PoxConstants {
369369
)
370370
}
371371

372-
#[cfg(test)]
372+
#[cfg(any(test, feature = "testing"))]
373373
/// Create a PoX constants used in tests with 5-block cycles,
374374
/// 3-block prepare phases, a threshold of 3, rejection fraction of 25%,
375375
/// a participation threshold of 5% and no sunset or transition to pox-2 or beyond.
@@ -821,7 +821,7 @@ impl From<btc_error> for Error {
821821
}
822822

823823
impl BurnchainView {
824-
#[cfg(test)]
824+
#[cfg(any(test, feature = "testing"))]
825825
pub fn make_test_data(&mut self) {
826826
let oldest_height = if self.burn_stable_block_height < MAX_NEIGHBOR_BLOCK_DELAY {
827827
0

stackslib/src/burnchains/tests/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl BurnchainDB {
4949

5050
/// Get back all of the parsed burnchain operations for a given block.
5151
/// Used in testing to replay burnchain data.
52-
#[cfg(test)]
52+
#[cfg(any(test, feature = "testing"))]
5353
pub fn get_burnchain_block_ops(
5454
&self,
5555
block_hash: &BurnchainHeaderHash,

stackslib/src/burnchains/tests/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//
1414
// You should have received a copy of the GNU General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
#![allow(unused)]
1617

1718
pub mod affirmation;
1819
pub mod burnchain;

stackslib/src/chainstate/burn/db/sortdb.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5482,7 +5482,7 @@ impl<'a> SortitionHandleTx<'a> {
54825482
sn.canonical_stacks_tip_height,
54835483
)?;
54845484

5485-
#[cfg(test)]
5485+
#[cfg(any(test, feature = "testing"))]
54865486
{
54875487
let (block_consensus_hash, block_bhh) =
54885488
SortitionDB::get_canonical_stacks_chain_tip_hash(self).unwrap();
@@ -6566,7 +6566,7 @@ impl ChainstateDB for SortitionDB {
65666566
}
65676567
}
65686568

6569-
#[cfg(test)]
6569+
#[cfg(any(test, feature = "testing"))]
65706570
pub mod tests {
65716571
use std::sync::mpsc::sync_channel;
65726572
use std::thread;

stackslib/src/chainstate/burn/distribution.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ impl BurnSamplePoint {
424424
}
425425
}
426426

427-
#[cfg(test)]
427+
#[cfg(any(test, feature = "testing"))]
428428
mod tests {
429429
use std::marker::PhantomData;
430430

stackslib/src/chainstate/burn/operations/leader_block_commit.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub static OUTPUTS_PER_COMMIT: usize = 2;
9090
pub static BURN_BLOCK_MINED_AT_MODULUS: u64 = 5;
9191

9292
impl LeaderBlockCommitOp {
93-
#[cfg(test)]
93+
#[cfg(any(test, feature = "testing"))]
9494
pub fn initial(
9595
block_header_hash: &BlockHeaderHash,
9696
block_height: u64,
@@ -131,10 +131,10 @@ impl LeaderBlockCommitOp {
131131
}
132132
}
133133

134-
#[cfg(test)]
134+
#[cfg(any(test, feature = "testing"))]
135135
pub fn new(
136136
block_header_hash: &BlockHeaderHash,
137-
block_height: u64,
137+
_block_height: u64,
138138
new_seed: &VRFSeed,
139139
parent: &LeaderBlockCommitOp,
140140
key_block_ptr: u32,
@@ -170,7 +170,7 @@ impl LeaderBlockCommitOp {
170170
}
171171
}
172172

173-
#[cfg(test)]
173+
#[cfg(any(test, feature = "testing"))]
174174
pub fn set_burn_height(&mut self, height: u64) {
175175
self.block_height = height;
176176
let new_burn_parent_modulus = if height > 0 {

stackslib/src/chainstate/burn/operations/leader_key_register.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub struct ParsedData {
4444
}
4545

4646
impl LeaderKeyRegisterOp {
47-
#[cfg(test)]
47+
#[cfg(any(test, feature = "testing"))]
4848
pub fn new(public_key: &VRFPublicKey) -> LeaderKeyRegisterOp {
4949
LeaderKeyRegisterOp {
5050
public_key: public_key.clone(),
@@ -59,10 +59,10 @@ impl LeaderKeyRegisterOp {
5959
}
6060
}
6161

62-
#[cfg(test)]
62+
#[cfg(any(test, feature = "testing"))]
6363
pub fn new_from_secrets(
64-
num_sigs: u16,
65-
hash_mode: &AddressHashMode,
64+
_num_sigs: u16,
65+
_hash_mode: &AddressHashMode,
6666
prover_key: &VRFPrivateKey,
6767
) -> Option<LeaderKeyRegisterOp> {
6868
let prover_pubk = VRFPublicKey::from_private(prover_key);

0 commit comments

Comments
 (0)