Skip to content

Commit 7caa75f

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

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

crates/bitcoind_rpc/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +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+
serial_test = { version = "=0.8.0" }
2627

2728
[features]
2829
default = ["std"]

crates/bitcoind_rpc/tests/test_emitter.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use bdk_chain::{
1010
use bdk_testenv::{anyhow, TestEnv};
1111
use bitcoin::{hashes::Hash, Block, OutPoint, ScriptBuf, WScriptHash};
1212
use bitcoincore_rpc::RpcApi;
13+
use serial_test::serial;
1314

1415
/// Ensure that blocks are emitted in order even after reorg.
1516
///
@@ -18,6 +19,7 @@ use bitcoincore_rpc::RpcApi;
1819
/// 3. Reorg highest 6 blocks.
1920
/// 4. Emit blocks from [`Emitter`] and re-update the [`LocalChain`].
2021
#[test]
22+
#[serial]
2123
pub fn test_sync_local_chain() -> anyhow::Result<()> {
2224
let env = TestEnv::new()?;
2325
let network_tip = env.rpc_client().get_block_count()?;
@@ -129,6 +131,7 @@ pub fn test_sync_local_chain() -> anyhow::Result<()> {
129131
///
130132
/// [`EmittedUpdate::into_tx_graph_update`]: bdk_bitcoind_rpc::EmittedUpdate::into_tx_graph_update
131133
#[test]
134+
#[serial]
132135
fn test_into_tx_graph() -> anyhow::Result<()> {
133136
let env = TestEnv::new()?;
134137

@@ -240,6 +243,7 @@ fn test_into_tx_graph() -> anyhow::Result<()> {
240243
/// TODO: If the reorg height is lower than the fallback height, how do we find a block height to
241244
/// emit that can connect with our receiver chain?
242245
#[test]
246+
#[serial]
243247
fn ensure_block_emitted_after_reorg_is_at_reorg_height() -> anyhow::Result<()> {
244248
const EMITTER_START_HEIGHT: usize = 100;
245249
const CHAIN_TIP_HEIGHT: usize = 110;
@@ -315,6 +319,7 @@ fn get_balance(
315319
/// If a block is reorged out, ensure that containing transactions that do not exist in the
316320
/// replacement block(s) become unconfirmed.
317321
#[test]
322+
#[serial]
318323
fn tx_can_become_unconfirmed_after_reorg() -> anyhow::Result<()> {
319324
const PREMINE_COUNT: usize = 101;
320325
const ADDITIONAL_COUNT: usize = 11;
@@ -406,6 +411,7 @@ fn tx_can_become_unconfirmed_after_reorg() -> anyhow::Result<()> {
406411
/// When we call Emitter::mempool multiple times, mempool txs should not be re-emitted, even if the
407412
/// chain tip is extended.
408413
#[test]
414+
#[serial]
409415
fn mempool_avoids_re_emission() -> anyhow::Result<()> {
410416
const BLOCKS_TO_MINE: usize = 101;
411417
const MEMPOOL_TX_COUNT: usize = 2;
@@ -471,6 +477,7 @@ fn mempool_avoids_re_emission() -> anyhow::Result<()> {
471477
/// that `mempool` should always re-emit txs that have introduced at a height greater than the last
472478
/// emitted block height.
473479
#[test]
480+
#[serial]
474481
fn mempool_re_emits_if_tx_introduction_height_not_reached() -> anyhow::Result<()> {
475482
const PREMINE_COUNT: usize = 101;
476483
const MEMPOOL_TX_COUNT: usize = 21;
@@ -559,6 +566,7 @@ fn mempool_re_emits_if_tx_introduction_height_not_reached() -> anyhow::Result<()
559566

560567
/// Ensure we force re-emit all mempool txs after reorg.
561568
#[test]
569+
#[serial]
562570
fn mempool_during_reorg() -> anyhow::Result<()> {
563571
const TIP_DIFF: usize = 10;
564572
const PREMINE_COUNT: usize = 101;
@@ -682,6 +690,7 @@ fn mempool_during_reorg() -> anyhow::Result<()> {
682690
/// The block hash of 99b should be different than 99a, but their previous block hashes should
683691
/// be the same.
684692
#[test]
693+
#[serial]
685694
fn no_agreement_point() -> anyhow::Result<()> {
686695
const PREMINE_COUNT: usize = 101;
687696

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 = "=0.8.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)