Skip to content
Closed
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
1 change: 1 addition & 0 deletions crates/bitcoind_rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ bdk_core = { path = "../core", version = "0.3.0", default-features = false }
[dev-dependencies]
bdk_testenv = { path = "../testenv", default-features = false }
bdk_chain = { path = "../chain" }
serial_test = { version = "=0.8.0" }

[features]
default = ["std"]
Expand Down
9 changes: 9 additions & 0 deletions crates/bitcoind_rpc/tests/test_emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use bdk_chain::{
use bdk_testenv::{anyhow, TestEnv};
use bitcoin::{hashes::Hash, Block, OutPoint, ScriptBuf, WScriptHash};
use bitcoincore_rpc::RpcApi;
use serial_test::serial;

/// Ensure that blocks are emitted in order even after reorg.
///
Expand All @@ -18,6 +19,7 @@ use bitcoincore_rpc::RpcApi;
/// 3. Reorg highest 6 blocks.
/// 4. Emit blocks from [`Emitter`] and re-update the [`LocalChain`].
#[test]
#[serial]
pub fn test_sync_local_chain() -> anyhow::Result<()> {
let env = TestEnv::new()?;
let network_tip = env.rpc_client().get_block_count()?;
Expand Down Expand Up @@ -129,6 +131,7 @@ pub fn test_sync_local_chain() -> anyhow::Result<()> {
///
/// [`EmittedUpdate::into_tx_graph_update`]: bdk_bitcoind_rpc::EmittedUpdate::into_tx_graph_update
#[test]
#[serial]
fn test_into_tx_graph() -> anyhow::Result<()> {
let env = TestEnv::new()?;

Expand Down Expand Up @@ -240,6 +243,7 @@ fn test_into_tx_graph() -> anyhow::Result<()> {
/// TODO: If the reorg height is lower than the fallback height, how do we find a block height to
/// emit that can connect with our receiver chain?
#[test]
#[serial]
fn ensure_block_emitted_after_reorg_is_at_reorg_height() -> anyhow::Result<()> {
const EMITTER_START_HEIGHT: usize = 100;
const CHAIN_TIP_HEIGHT: usize = 110;
Expand Down Expand Up @@ -315,6 +319,7 @@ fn get_balance(
/// If a block is reorged out, ensure that containing transactions that do not exist in the
/// replacement block(s) become unconfirmed.
#[test]
#[serial]
fn tx_can_become_unconfirmed_after_reorg() -> anyhow::Result<()> {
const PREMINE_COUNT: usize = 101;
const ADDITIONAL_COUNT: usize = 11;
Expand Down Expand Up @@ -406,6 +411,7 @@ fn tx_can_become_unconfirmed_after_reorg() -> anyhow::Result<()> {
/// When we call Emitter::mempool multiple times, mempool txs should not be re-emitted, even if the
/// chain tip is extended.
#[test]
#[serial]
fn mempool_avoids_re_emission() -> anyhow::Result<()> {
const BLOCKS_TO_MINE: usize = 101;
const MEMPOOL_TX_COUNT: usize = 2;
Expand Down Expand Up @@ -471,6 +477,7 @@ fn mempool_avoids_re_emission() -> anyhow::Result<()> {
/// that `mempool` should always re-emit txs that have introduced at a height greater than the last
/// emitted block height.
#[test]
#[serial]
fn mempool_re_emits_if_tx_introduction_height_not_reached() -> anyhow::Result<()> {
const PREMINE_COUNT: usize = 101;
const MEMPOOL_TX_COUNT: usize = 21;
Expand Down Expand Up @@ -559,6 +566,7 @@ fn mempool_re_emits_if_tx_introduction_height_not_reached() -> anyhow::Result<()

/// Ensure we force re-emit all mempool txs after reorg.
#[test]
#[serial]
fn mempool_during_reorg() -> anyhow::Result<()> {
const TIP_DIFF: usize = 10;
const PREMINE_COUNT: usize = 101;
Expand Down Expand Up @@ -682,6 +690,7 @@ fn mempool_during_reorg() -> anyhow::Result<()> {
/// The block hash of 99b should be different than 99a, but their previous block hashes should
/// be the same.
#[test]
#[serial]
fn no_agreement_point() -> anyhow::Result<()> {
const PREMINE_COUNT: usize = 101;

Expand Down
1 change: 1 addition & 0 deletions crates/electrum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ electrum-client = { version = "0.21", features = [ "proxy" ], default-features =
[dev-dependencies]
bdk_testenv = { path = "../testenv", default-features = false }
bdk_chain = { path = "../chain" }
serial_test = { version = "=0.8.0" }

[features]
default = ["use-rustls"]
Expand Down
5 changes: 5 additions & 0 deletions crates/electrum/tests/test_electrum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use bdk_chain::{
use bdk_electrum::BdkElectrumClient;
use bdk_testenv::{anyhow, bitcoincore_rpc::RpcApi, TestEnv};
use core::time::Duration;
use serial_test::serial;
use std::collections::{BTreeSet, HashSet};
use std::str::FromStr;

Expand Down Expand Up @@ -55,6 +56,7 @@ where
}

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

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

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