Skip to content

Commit 9c33c3d

Browse files
committed
feature(testenv): run tests that ping a local bitcoind or electrsd client in series
1 parent 3bc45b5 commit 9c33c3d

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

crates/bitcoind_rpc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ bdk_core = { path = "../core", version = "0.3.0", default-features = false }
2323
[dev-dependencies]
2424
bdk_testenv = { path = "../testenv", default-features = false }
2525
bdk_chain = { path = "../chain" }
26-
26+
serial_test = { version = "3.2.0" }
2727
[features]
2828
default = ["std"]
2929
std = ["bitcoin/std", "bdk_core/std"]

crates/bitcoind_rpc/tests/test_emitter.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ use bdk_chain::{
1010
use bdk_testenv::{anyhow, TestEnv};
1111
use bitcoin::{hashes::Hash, Block, OutPoint, ScriptBuf, WScriptHash};
1212
use bitcoincore_rpc::RpcApi;
13-
13+
use serial_test::serial;
1414
/// Ensure that blocks are emitted in order even after reorg.
1515
///
1616
/// 1. Mine 101 blocks.
1717
/// 2. Emit blocks from [`Emitter`] and update the [`LocalChain`].
1818
/// 3. Reorg highest 6 blocks.
1919
/// 4. Emit blocks from [`Emitter`] and re-update the [`LocalChain`].
2020
#[test]
21+
#[serial]
2122
pub fn test_sync_local_chain() -> anyhow::Result<()> {
2223
let env = TestEnv::new()?;
2324
let network_tip = env.rpc_client().get_block_count()?;
@@ -129,6 +130,7 @@ pub fn test_sync_local_chain() -> anyhow::Result<()> {
129130
///
130131
/// [`EmittedUpdate::into_tx_graph_update`]: bdk_bitcoind_rpc::EmittedUpdate::into_tx_graph_update
131132
#[test]
133+
#[serial]
132134
fn test_into_tx_graph() -> anyhow::Result<()> {
133135
let env = TestEnv::new()?;
134136

@@ -240,6 +242,7 @@ fn test_into_tx_graph() -> anyhow::Result<()> {
240242
/// TODO: If the reorg height is lower than the fallback height, how do we find a block height to
241243
/// emit that can connect with our receiver chain?
242244
#[test]
245+
#[serial]
243246
fn ensure_block_emitted_after_reorg_is_at_reorg_height() -> anyhow::Result<()> {
244247
const EMITTER_START_HEIGHT: usize = 100;
245248
const CHAIN_TIP_HEIGHT: usize = 110;
@@ -315,6 +318,7 @@ fn get_balance(
315318
/// If a block is reorged out, ensure that containing transactions that do not exist in the
316319
/// replacement block(s) become unconfirmed.
317320
#[test]
321+
#[serial]
318322
fn tx_can_become_unconfirmed_after_reorg() -> anyhow::Result<()> {
319323
const PREMINE_COUNT: usize = 101;
320324
const ADDITIONAL_COUNT: usize = 11;
@@ -406,6 +410,7 @@ fn tx_can_become_unconfirmed_after_reorg() -> anyhow::Result<()> {
406410
/// When we call Emitter::mempool multiple times, mempool txs should not be re-emitted, even if the
407411
/// chain tip is extended.
408412
#[test]
413+
#[serial]
409414
fn mempool_avoids_re_emission() -> anyhow::Result<()> {
410415
const BLOCKS_TO_MINE: usize = 101;
411416
const MEMPOOL_TX_COUNT: usize = 2;
@@ -471,6 +476,7 @@ fn mempool_avoids_re_emission() -> anyhow::Result<()> {
471476
/// that `mempool` should always re-emit txs that have introduced at a height greater than the last
472477
/// emitted block height.
473478
#[test]
479+
#[serial]
474480
fn mempool_re_emits_if_tx_introduction_height_not_reached() -> anyhow::Result<()> {
475481
const PREMINE_COUNT: usize = 101;
476482
const MEMPOOL_TX_COUNT: usize = 21;
@@ -559,6 +565,7 @@ fn mempool_re_emits_if_tx_introduction_height_not_reached() -> anyhow::Result<()
559565

560566
/// Ensure we force re-emit all mempool txs after reorg.
561567
#[test]
568+
#[serial]
562569
fn mempool_during_reorg() -> anyhow::Result<()> {
563570
const TIP_DIFF: usize = 10;
564571
const PREMINE_COUNT: usize = 101;
@@ -682,6 +689,7 @@ fn mempool_during_reorg() -> anyhow::Result<()> {
682689
/// The block hash of 99b should be different than 99a, but their previous block hashes should
683690
/// be the same.
684691
#[test]
692+
#[serial]
685693
fn no_agreement_point() -> anyhow::Result<()> {
686694
const PREMINE_COUNT: usize = 101;
687695

crates/electrum/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ electrum-client = { version = "0.21", features = [ "proxy" ], default-features =
1919
[dev-dependencies]
2020
bdk_testenv = { path = "../testenv", default-features = false }
2121
bdk_chain = { path = "../chain" }
22+
serial_test = { version = "3.2.0" }
2223

2324
[features]
2425
default = ["use-rustls"]

crates/electrum/tests/test_electrum.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use bdk_testenv::{anyhow, bitcoincore_rpc::RpcApi, TestEnv};
1010
use core::time::Duration;
1111
use std::collections::{BTreeSet, HashSet};
1212
use std::str::FromStr;
13+
use serial_test::serial;
1314

1415
// Batch size for `sync_with_electrum`.
1516
const BATCH_SIZE: usize = 5;
@@ -55,6 +56,7 @@ where
5556
}
5657

5758
#[test]
59+
#[serial]
5860
pub fn test_update_tx_graph_without_keychain() -> anyhow::Result<()> {
5961
let env = TestEnv::new()?;
6062
let electrum_client = electrum_client::Client::new(env.electrsd.electrum_url.as_str())?;
@@ -163,6 +165,7 @@ pub fn test_update_tx_graph_without_keychain() -> anyhow::Result<()> {
163165

164166
/// Test the bounds of the address scan depending on the `stop_gap`.
165167
#[test]
168+
#[serial]
166169
pub fn test_update_tx_graph_stop_gap() -> anyhow::Result<()> {
167170
let env = TestEnv::new()?;
168171
let electrum_client = electrum_client::Client::new(env.electrsd.electrum_url.as_str())?;
@@ -290,6 +293,7 @@ pub fn test_update_tx_graph_stop_gap() -> anyhow::Result<()> {
290293
/// reorg and no-reorg situations. After the transaction is confirmed after reorg, check if floating
291294
/// txouts for previous outputs were inserted for transaction fee calculation.
292295
#[test]
296+
#[serial]
293297
fn test_sync() -> anyhow::Result<()> {
294298
const SEND_AMOUNT: Amount = Amount::from_sat(10_000);
295299

@@ -432,6 +436,7 @@ fn test_sync() -> anyhow::Result<()> {
432436
/// 3. Perform 8 separate reorgs on each block with a confirmed tx.
433437
/// 4. Check [`Balance`] after each reorg to ensure unconfirmed amount is correct.
434438
#[test]
439+
#[serial]
435440
fn tx_can_become_unconfirmed_after_reorg() -> anyhow::Result<()> {
436441
const REORG_COUNT: usize = 8;
437442
const SEND_AMOUNT: Amount = Amount::from_sat(10_000);

0 commit comments

Comments
 (0)