Skip to content

Commit a8d52e6

Browse files
committed
Merge #1425: chore: add print_stdout/print_stderr lints to workspace level
e063ad8 fix(esplora+wallet+file_store): remove remaining `println!` usage (Leonardo Lima) b32b944 chore(examples): allow `clippy::print_stdout` in examples (Leonardo Lima) b614237 fix(tests)!: remove println! usage from tests (Leonardo Lima) eaa1917 chore: add `print_stdout`/`print_stderr` lints to workspace level (Leonardo Lima) Pull request description: potentially fixes #1362 <!-- You can erase any parts of this template not applicable to your Pull Request. --> ### Description It adds both `print_stdout` and `print_stderr` deny level lints on workspace level, but it does allow it on test fns through `clippy.toml` settings, and explicitly allow it on example code. <!-- Describe the purpose of this PR, what's being adding and/or fixed --> ### Notes to the reviewers It currently has the setting allowing it on test fns, but open for discussion below. <!-- In this section you can include notes directed to the reviewers, like explaining why some parts of the PR were done in a specific way --> ### Changelog notice - Add both `print_stdout` and `print_stderr` deny level lints on workspace level <!-- Notice the release manager should include in the release tag message changelog --> <!-- See https://keepachangelog.com/en/1.0.0/ for examples --> ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### New Features: * [x] I've added tests for the new feature * [x] I've added docs for the new feature ACKs for top commit: notmandatory: ACK e063ad8 Tree-SHA512: b3348efd86d09944eb36e4d87799eebc23f4e423861b3bad08365d286449f61b29ad332157eecfb7307191ef61d3b8285341e0ccb868581e54b570d6dd37547c
2 parents 775e4ae + e063ad8 commit a8d52e6

File tree

19 files changed

+41
-38
lines changed

19 files changed

+41
-38
lines changed

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ members = [
2222

2323
[workspace.package]
2424
authors = ["Bitcoin Dev Kit Developers"]
25+
26+
[workspace.lints.clippy]
27+
print_stdout = "deny"
28+
print_stderr = "deny"

clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
msrv="1.63.0"
1+
msrv="1.63.0"

crates/bitcoind_rpc/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ readme = "README.md"
1212

1313
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1414

15+
[lints]
16+
workspace = true
17+
1518
[dependencies]
1619
bitcoin = { version = "0.32.0", default-features = false }
1720
bitcoincore-rpc = { version = "0.19.0" }

crates/bitcoind_rpc/tests/test_emitter.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub fn test_sync_local_chain() -> anyhow::Result<()> {
3636
};
3737

3838
// See if the emitter outputs the right blocks.
39-
println!("first sync:");
39+
4040
while let Some(emission) = emitter.next_block()? {
4141
let height = emission.block_height();
4242
let hash = emission.block_hash();
@@ -76,7 +76,7 @@ pub fn test_sync_local_chain() -> anyhow::Result<()> {
7676
.collect::<Vec<_>>();
7777

7878
// See if the emitter outputs the right blocks.
79-
println!("after reorg:");
79+
8080
let mut exp_height = exp_hashes.len() - reorged_blocks.len();
8181
while let Some(emission) = emitter.next_block()? {
8282
let height = emission.block_height();
@@ -132,7 +132,6 @@ pub fn test_sync_local_chain() -> anyhow::Result<()> {
132132
fn test_into_tx_graph() -> anyhow::Result<()> {
133133
let env = TestEnv::new()?;
134134

135-
println!("getting new addresses!");
136135
let addr_0 = env
137136
.rpc_client()
138137
.get_new_address(None, None)?
@@ -145,11 +144,8 @@ fn test_into_tx_graph() -> anyhow::Result<()> {
145144
.rpc_client()
146145
.get_new_address(None, None)?
147146
.assume_checked();
148-
println!("got new addresses!");
149147

150-
println!("mining block!");
151148
env.mine_blocks(101, None)?;
152-
println!("mined blocks!");
153149

154150
let (mut chain, _) = LocalChain::from_genesis_hash(env.rpc_client().get_block_hash(0)?);
155151
let mut indexed_tx_graph = IndexedTxGraph::<BlockId, _>::new({
@@ -609,7 +605,6 @@ fn mempool_during_reorg() -> anyhow::Result<()> {
609605
// perform reorgs at different heights, these reorgs will not confirm transactions in the
610606
// mempool
611607
for reorg_count in 1..TIP_DIFF {
612-
println!("REORG COUNT: {}", reorg_count);
613608
env.reorg_empty_blocks(reorg_count)?;
614609

615610
// This is a map of mempool txids to tip height where the tx was introduced to the mempool
@@ -627,7 +622,6 @@ fn mempool_during_reorg() -> anyhow::Result<()> {
627622
// `next_header` emits the replacement block of the reorg
628623
if let Some(emission) = emitter.next_header()? {
629624
let height = emission.block_height();
630-
println!("\t- replacement height: {}", height);
631625

632626
// the mempool emission (that follows the first block emission after reorg) should only
633627
// include mempool txs introduced at reorg height or greater

crates/chain/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ readme = "README.md"
1212

1313
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1414

15+
[lints]
16+
workspace = true
17+
1518
[dependencies]
1619
bitcoin = { version = "0.32.0", default-features = false }
1720
bdk_core = { path = "../core", version = "0.1", default-features = false }

crates/chain/tests/test_local_chain.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ enum ExpectedResult<'a> {
3434

3535
impl<'a> TestLocalChain<'a> {
3636
fn run(mut self) {
37-
println!("[TestLocalChain] test: {}", self.name);
3837
let got_changeset = match self.chain.apply_update(self.update) {
3938
Ok(changeset) => changeset,
4039
Err(got_err) => {
@@ -255,7 +254,7 @@ fn update_local_chain() {
255254
(4, None)
256255
],
257256
init_changeset: &[
258-
(0, Some(h!("_"))),
257+
(0, Some(h!("_"))),
259258
(1, Some(h!("B'"))),
260259
(2, Some(h!("C'"))),
261260
(3, Some(h!("D"))),
@@ -437,8 +436,6 @@ fn local_chain_disconnect_from() {
437436
];
438437

439438
for (i, t) in test_cases.into_iter().enumerate() {
440-
println!("Case {}: {}", i, t.name);
441-
442439
let mut chain = t.original;
443440
let result = chain.disconnect_from(t.disconnect_from.into());
444441
assert_eq!(
@@ -491,7 +488,6 @@ fn checkpoint_from_block_ids() {
491488
];
492489

493490
for (i, t) in test_cases.into_iter().enumerate() {
494-
println!("running test case {}: '{}'", i, t.name);
495491
let result = CheckPoint::from_block_ids(
496492
t.blocks
497493
.iter()
@@ -583,6 +579,7 @@ fn checkpoint_query() {
583579
fn checkpoint_insert() {
584580
struct TestCase<'a> {
585581
/// The name of the test.
582+
#[allow(dead_code)]
586583
name: &'a str,
587584
/// The original checkpoint chain to call [`CheckPoint::insert`] on.
588585
chain: &'a [(u32, BlockHash)],
@@ -629,9 +626,7 @@ fn checkpoint_insert() {
629626
core::iter::once((0, h!("_"))).map(BlockId::from)
630627
}
631628

632-
for (i, t) in test_cases.into_iter().enumerate() {
633-
println!("Running [{}] '{}'", i, t.name);
634-
629+
for t in test_cases.into_iter() {
635630
let chain = CheckPoint::from_block_ids(
636631
genesis_block().chain(t.chain.iter().copied().map(BlockId::from)),
637632
)
@@ -792,7 +787,6 @@ fn local_chain_apply_header_connected_to() {
792787
];
793788

794789
for (i, t) in test_cases.into_iter().enumerate() {
795-
println!("running test case {}: '{}'", i, t.name);
796790
let mut chain = t.chain;
797791
let result = chain.apply_header_connected_to(&t.header, t.height, t.connected_to);
798792
let exp_result = t

crates/electrum/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ description = "Fetch data from electrum in the form BDK accepts"
99
license = "MIT OR Apache-2.0"
1010
readme = "README.md"
1111

12+
[lints]
13+
workspace = true
14+
1215
[dependencies]
1316
bdk_core = { path = "../core", version = "0.1" }
1417
electrum-client = { version = "0.21", features = [ "proxy" ], default-features = false }

crates/esplora/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ readme = "README.md"
1111

1212
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1313

14+
[lints]
15+
workspace = true
16+
1417
[dependencies]
1518
bdk_core = { path = "../core", version = "0.1", default-features = false }
1619
esplora-client = { version = "0.9.0", default-features = false }

crates/esplora/src/async_ext.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ mod test {
506506
#[tokio::test]
507507
pub async fn test_finalize_chain_update() -> anyhow::Result<()> {
508508
struct TestCase<'a> {
509+
#[allow(dead_code)]
509510
name: &'a str,
510511
/// Initial blockchain height to start the env with.
511512
initial_env_height: u32,
@@ -542,9 +543,7 @@ mod test {
542543
},
543544
];
544545

545-
for (i, t) in test_cases.into_iter().enumerate() {
546-
println!("[{}] running test case: {}", i, t.name);
547-
546+
for t in test_cases.into_iter() {
548547
let env = TestEnv::new()?;
549548
let base_url = format!("http://{}", &env.electrsd.esplora_url.clone().unwrap());
550549
let client = Builder::new(base_url.as_str()).build_async()?;
@@ -590,7 +589,6 @@ mod test {
590589
chain.apply_update(update)?;
591590
chain
592591
};
593-
println!("local chain height: {}", local_chain.tip().height());
594592

595593
// extend env chain
596594
if let Some(to_mine) = t
@@ -633,10 +631,6 @@ mod test {
633631
// apply update
634632
let mut updated_local_chain = local_chain.clone();
635633
updated_local_chain.apply_update(update)?;
636-
println!(
637-
"updated local chain height: {}",
638-
updated_local_chain.tip().height()
639-
);
640634

641635
assert!(
642636
{

crates/esplora/src/blocking_ext.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ mod test {
495495
#[test]
496496
pub fn test_finalize_chain_update() -> anyhow::Result<()> {
497497
struct TestCase<'a> {
498+
#[allow(dead_code)]
498499
name: &'a str,
499500
/// Initial blockchain height to start the env with.
500501
initial_env_height: u32,
@@ -531,9 +532,7 @@ mod test {
531532
},
532533
];
533534

534-
for (i, t) in test_cases.into_iter().enumerate() {
535-
println!("[{}] running test case: {}", i, t.name);
536-
535+
for t in test_cases.into_iter() {
537536
let env = TestEnv::new()?;
538537
let base_url = format!("http://{}", &env.electrsd.esplora_url.clone().unwrap());
539538
let client = Builder::new(base_url.as_str()).build_blocking();
@@ -578,7 +577,6 @@ mod test {
578577
chain.apply_update(update)?;
579578
chain
580579
};
581-
println!("local chain height: {}", local_chain.tip().height());
582580

583581
// extend env chain
584582
if let Some(to_mine) = t
@@ -620,10 +618,6 @@ mod test {
620618
// apply update
621619
let mut updated_local_chain = local_chain.clone();
622620
updated_local_chain.apply_update(update)?;
623-
println!(
624-
"updated local chain height: {}",
625-
updated_local_chain.tip().height()
626-
);
627621

628622
assert!(
629623
{
@@ -784,7 +778,6 @@ mod test {
784778
];
785779

786780
for (i, t) in test_cases.into_iter().enumerate() {
787-
println!("Case {}: {}", i, t.name);
788781
let mut chain = t.chain;
789782

790783
let mock_anchors = t

0 commit comments

Comments
 (0)