]> Untitled Git - bdk/commitdiff
fix(tests)!: remove println! usage from tests
authorLeonardo Lima <oleonardolima@users.noreply.github.com>
Thu, 15 Aug 2024 14:46:29 +0000 (11:46 -0300)
committerLeonardo Lima <oleonardolima@users.noreply.github.com>
Thu, 15 Aug 2024 15:00:10 +0000 (12:00 -0300)
crates/bitcoind_rpc/tests/test_emitter.rs
crates/chain/tests/test_local_chain.rs

index 3a5c67055db4f330503dd2975373caf16113d8b9..8c41efc0321a69ac0e81ff71e78bcc8add145b3a 100644 (file)
@@ -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();
@@ -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();
@@ -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)?
@@ -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({
@@ -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
@@ -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
index 6819e3da1509a1f724a855f45c09323a69732076..29686564db29fbd41eae420f2a2f4be28ff986d5 100644 (file)
@@ -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) => {
@@ -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"))),
@@ -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!(
@@ -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()
@@ -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)],
@@ -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)),
         )
@@ -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