Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add print_stdout/print_stderr lints to workspace level #1425

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ members = [

[workspace.package]
authors = ["Bitcoin Dev Kit Developers"]

[workspace.lints.clippy]
print_stdout = "deny"
print_stderr = "deny"
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv="1.63.0"
msrv="1.63.0"
3 changes: 3 additions & 0 deletions crates/bitcoind_rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ readme = "README.md"

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

[lints]
workspace = true

[dependencies]
bitcoin = { version = "0.32.0", default-features = false }
bitcoincore-rpc = { version = "0.19.0" }
Expand Down
10 changes: 2 additions & 8 deletions crates/bitcoind_rpc/tests/test_emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub fn test_sync_local_chain() -> anyhow::Result<()> {
};

// See if the emitter outputs the right blocks.
println!("first sync:");

while let Some(emission) = emitter.next_block()? {
let height = emission.block_height();
let hash = emission.block_hash();
Expand Down Expand Up @@ -76,7 +76,7 @@ pub fn test_sync_local_chain() -> anyhow::Result<()> {
.collect::<Vec<_>>();

// See if the emitter outputs the right blocks.
println!("after reorg:");

let mut exp_height = exp_hashes.len() - reorged_blocks.len();
while let Some(emission) = emitter.next_block()? {
let height = emission.block_height();
Expand Down Expand Up @@ -132,7 +132,6 @@ pub fn test_sync_local_chain() -> anyhow::Result<()> {
fn test_into_tx_graph() -> anyhow::Result<()> {
let env = TestEnv::new()?;

println!("getting new addresses!");
let addr_0 = env
.rpc_client()
.get_new_address(None, None)?
Expand All @@ -145,11 +144,8 @@ fn test_into_tx_graph() -> anyhow::Result<()> {
.rpc_client()
.get_new_address(None, None)?
.assume_checked();
println!("got new addresses!");

println!("mining block!");
env.mine_blocks(101, None)?;
println!("mined blocks!");

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

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

// the mempool emission (that follows the first block emission after reorg) should only
// include mempool txs introduced at reorg height or greater
Expand Down
3 changes: 3 additions & 0 deletions crates/chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ readme = "README.md"

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

[lints]
workspace = true

[dependencies]
bitcoin = { version = "0.32.0", default-features = false }
serde = { version = "1", optional = true, features = ["derive", "rc"] }
Expand Down
12 changes: 3 additions & 9 deletions crates/chain/tests/test_local_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ enum ExpectedResult<'a> {

impl<'a> TestLocalChain<'a> {
fn run(mut self) {
println!("[TestLocalChain] test: {}", self.name);
let got_changeset = match self.chain.apply_update(self.update) {
Ok(changeset) => changeset,
Err(got_err) => {
Expand Down Expand Up @@ -255,7 +254,7 @@ fn update_local_chain() {
(4, None)
],
init_changeset: &[
(0, Some(h!("_"))),
(0, Some(h!("_"))),
(1, Some(h!("B'"))),
(2, Some(h!("C'"))),
(3, Some(h!("D"))),
Expand Down Expand Up @@ -437,8 +436,6 @@ fn local_chain_disconnect_from() {
];

for (i, t) in test_cases.into_iter().enumerate() {
println!("Case {}: {}", i, t.name);

let mut chain = t.original;
let result = chain.disconnect_from(t.disconnect_from.into());
assert_eq!(
Expand Down Expand Up @@ -491,7 +488,6 @@ fn checkpoint_from_block_ids() {
];

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

for (i, t) in test_cases.into_iter().enumerate() {
println!("Running [{}] '{}'", i, t.name);

for t in test_cases.into_iter() {
let chain = CheckPoint::from_block_ids(
genesis_block().chain(t.chain.iter().copied().map(BlockId::from)),
)
Expand Down Expand Up @@ -792,7 +787,6 @@ fn local_chain_apply_header_connected_to() {
];

for (i, t) in test_cases.into_iter().enumerate() {
println!("running test case {}: '{}'", i, t.name);
let mut chain = t.chain;
let result = chain.apply_header_connected_to(&t.header, t.height, t.connected_to);
let exp_result = t
Expand Down
3 changes: 3 additions & 0 deletions crates/electrum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ description = "Fetch data from electrum in the form BDK accepts"
license = "MIT OR Apache-2.0"
readme = "README.md"

[lints]
workspace = true

[dependencies]
bdk_chain = { path = "../chain", version = "0.17.0" }
electrum-client = { version = "0.21", features = ["proxy"], default-features = false }
Expand Down
3 changes: 3 additions & 0 deletions crates/esplora/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ readme = "README.md"

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

[lints]
workspace = true

[dependencies]
bdk_chain = { path = "../chain", version = "0.17.0", default-features = false }
esplora-client = { version = "0.9.0", default-features = false }
Expand Down
10 changes: 2 additions & 8 deletions crates/esplora/src/async_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ mod test {
#[tokio::test]
pub async fn test_finalize_chain_update() -> anyhow::Result<()> {
struct TestCase<'a> {
#[allow(dead_code)]
name: &'a str,
/// Initial blockchain height to start the env with.
initial_env_height: u32,
Expand Down Expand Up @@ -526,9 +527,7 @@ mod test {
},
];

for (i, t) in test_cases.into_iter().enumerate() {
println!("[{}] running test case: {}", i, t.name);

for t in test_cases.into_iter() {
let env = TestEnv::new()?;
let base_url = format!("http://{}", &env.electrsd.esplora_url.clone().unwrap());
let client = Builder::new(base_url.as_str()).build_async()?;
Expand Down Expand Up @@ -571,7 +570,6 @@ mod test {
chain.apply_update(update)?;
chain
};
println!("local chain height: {}", local_chain.tip().height());

// extend env chain
if let Some(to_mine) = t
Expand Down Expand Up @@ -611,10 +609,6 @@ mod test {
// apply update
let mut updated_local_chain = local_chain.clone();
updated_local_chain.apply_update(update)?;
println!(
"updated local chain height: {}",
updated_local_chain.tip().height()
);

assert!(
{
Expand Down
11 changes: 2 additions & 9 deletions crates/esplora/src/blocking_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ mod test {
#[test]
pub fn test_finalize_chain_update() -> anyhow::Result<()> {
struct TestCase<'a> {
#[allow(dead_code)]
name: &'a str,
/// Initial blockchain height to start the env with.
initial_env_height: u32,
Expand Down Expand Up @@ -526,9 +527,7 @@ mod test {
},
];

for (i, t) in test_cases.into_iter().enumerate() {
println!("[{}] running test case: {}", i, t.name);

for t in test_cases.into_iter() {
let env = TestEnv::new()?;
let base_url = format!("http://{}", &env.electrsd.esplora_url.clone().unwrap());
let client = Builder::new(base_url.as_str()).build_blocking();
Expand Down Expand Up @@ -570,7 +569,6 @@ mod test {
chain.apply_update(update)?;
chain
};
println!("local chain height: {}", local_chain.tip().height());

// extend env chain
if let Some(to_mine) = t
Expand Down Expand Up @@ -609,10 +607,6 @@ mod test {
// apply update
let mut updated_local_chain = local_chain.clone();
updated_local_chain.apply_update(update)?;
println!(
"updated local chain height: {}",
updated_local_chain.tip().height()
);

assert!(
{
Expand Down Expand Up @@ -773,7 +767,6 @@ mod test {
];

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

let mock_anchors = t
Expand Down
3 changes: 3 additions & 0 deletions crates/file_store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ keywords = ["bitcoin", "persist", "persistence", "bdk", "file"]
authors = ["Bitcoin Dev Kit Developers"]
readme = "README.md"

[lints]
workspace = true

[dependencies]
bdk_chain = { path = "../chain", version = "0.17.0", features = [ "serde", "miniscript" ] }
bincode = { version = "1" }
Expand Down
2 changes: 0 additions & 2 deletions crates/file_store/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ mod test {

for short_write_len in 1..last_changeset_bytes.len() - 1 {
let file_path = temp_dir.path().join(format!("{}.dat", short_write_len));
println!("Test file: {:?}", file_path);

// simulate creating a file, writing data where the last write is incomplete
{
Expand Down Expand Up @@ -406,7 +405,6 @@ mod test {

for read_count in 0..changesets.len() {
let file_path = temp_dir.path().join(format!("{}.dat", read_count));
println!("Test file: {:?}", file_path);

// First, we create the file with all the changesets!
let mut db = Store::<TestChangeSet>::create_new(&TEST_MAGIC_BYTES, &file_path).unwrap();
Expand Down
3 changes: 3 additions & 0 deletions crates/hwi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ description = "Utilities to use bdk with hardware wallets"
license = "MIT OR Apache-2.0"
readme = "README.md"

[lints]
workspace = true

[dependencies]
bdk_wallet = { path = "../wallet", version = "1.0.0-beta.1" }
hwi = { version = "0.9.0", features = [ "miniscript"] }
3 changes: 3 additions & 0 deletions crates/testenv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ readme = "README.md"

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

[lints]
workspace = true

[dependencies]
bdk_chain = { path = "../chain", version = "0.17", default-features = false }
electrsd = { version = "0.28.0", features = ["bitcoind_25_0", "esplora_a33e97e1", "legacy"] }
Expand Down
3 changes: 3 additions & 0 deletions crates/wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ authors = ["Bitcoin Dev Kit Developers"]
edition = "2021"
rust-version = "1.63"

[lints]
workspace = true

[dependencies]
rand_core = { version = "0.6.0" }
miniscript = { version = "12.0.0", features = ["serde"], default-features = false }
Expand Down
1 change: 1 addition & 0 deletions crates/wallet/examples/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use bdk_wallet::{KeychainKind, Wallet};
///
/// This example demonstrates the interaction between a bdk wallet and miniscript policy.

#[allow(clippy::print_stdout)]
fn main() -> Result<(), Box<dyn Error>> {
// We start with a miniscript policy string
let policy_str = "or(
Expand Down
1 change: 1 addition & 0 deletions crates/wallet/examples/mnemonic_to_descriptors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use std::str::FromStr;

/// This example demonstrates how to generate a mnemonic phrase
/// using BDK and use that to generate a descriptor string.
#[allow(clippy::print_stdout)]
fn main() -> Result<(), anyhow::Error> {
let secp = Secp256k1::new();

Expand Down
1 change: 1 addition & 0 deletions crates/wallet/examples/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use bdk_wallet::signer::SignersContainer;
/// This example demos a Policy output for a 2of2 multisig between between 2 parties, where the wallet holds
/// one of the Extend Private key.

#[allow(clippy::print_stdout)]
fn main() -> Result<(), Box<dyn Error>> {
let secp = bitcoin::secp256k1::Secp256k1::new();

Expand Down
1 change: 0 additions & 1 deletion crates/wallet/src/wallet/coin_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1579,7 +1579,6 @@ mod test {
];

for (i, t) in test_cases.into_iter().enumerate() {
println!("Case {}: {}", i, t.name);
let (required, optional) =
filter_duplicates(to_utxo_vec(t.required), to_utxo_vec(t.optional));
assert_eq!(
Expand Down
Loading