Skip to content

Commit 65c0443

Browse files
committed
tests: use selective serial and explicit parallel annotations
Run only shared-state mining tests under serial execution and mark other integration tests as parallel. Keep serialization for tests that can observe global tip changes or trigger interrupt behavior, while allowing unrelated tests to run concurrently.
1 parent d0e958d commit 65c0443

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ capnpc = "0.25.0"
2020
[dev-dependencies]
2121
capnp-rpc = "0.25.0"
2222
futures = "0.3.0"
23+
serial_test = "3"
2324
tokio = { version = "1", features = ["rt-multi-thread", "net", "macros", "io-util", "time"] }
2425
tokio-util = { version = "0.7.16", features = ["compat"] }

tests/test.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ async fn bootstrap(
8282
}
8383

8484
#[tokio::test]
85+
#[serial_test::parallel]
8586
async fn integration() {
8687
let path = unix_socket_path();
8788
let rpc_network = connect_unix_stream(path).await;
@@ -117,6 +118,7 @@ async fn integration() {
117118
/// server. Cap'n Proto requires sequential ordinals so this placeholder cannot
118119
/// be removed, but the server intentionally rejects it.
119120
#[tokio::test]
121+
#[serial_test::parallel]
120122
async fn make_mining_old2_rejected() {
121123
let path = unix_socket_path();
122124
let rpc_network = connect_unix_stream(path).await;
@@ -169,6 +171,7 @@ async fn destroy_template(template: &block_template::Client, thread: &thread::Cl
169171

170172
/// Check the four mining constants from the capnp schema.
171173
#[test]
174+
#[serial_test::parallel]
172175
fn mining_constants() {
173176
assert_eq!(mining_capnp::MAX_MONEY, 2_100_000_000_000_000i64);
174177
const { assert!(mining_capnp::MAX_DOUBLE > 1e300) };
@@ -181,6 +184,7 @@ fn mining_constants() {
181184

182185
/// isTestChain, isInitialBlockDownload, getTip.
183186
#[tokio::test]
187+
#[serial_test::parallel]
184188
async fn mining_basic_queries() {
185189
let path = unix_socket_path();
186190
let rpc_network = connect_unix_stream(path).await;
@@ -218,6 +222,8 @@ async fn mining_basic_queries() {
218222

219223
/// waitTipChanged with a short timeout.
220224
#[tokio::test]
225+
// Serialized because this assertion is sensitive to concurrent tip changes.
226+
#[serial_test::serial]
221227
async fn mining_wait_tip_changed() {
222228
let path = unix_socket_path();
223229
let rpc_network = connect_unix_stream(path).await;
@@ -252,6 +258,7 @@ async fn mining_wait_tip_changed() {
252258
/// createNewBlock + all BlockTemplate read methods: getBlockHeader, getBlock,
253259
/// getTxFees, getTxSigops, getCoinbaseTx, getCoinbaseMerklePath.
254260
#[tokio::test]
261+
#[serial_test::parallel]
255262
async fn mining_block_template_inspection() {
256263
let path = unix_socket_path();
257264
let rpc_network = connect_unix_stream(path).await;
@@ -319,6 +326,8 @@ async fn mining_block_template_inspection() {
319326

320327
/// waitNext (short timeout), interruptWait, submitSolution (garbage), destroy.
321328
#[tokio::test]
329+
// Serialized because submitSolution behavior depends on current chain tip.
330+
#[serial_test::serial]
322331
async fn mining_block_template_lifecycle() {
323332
let path = unix_socket_path();
324333
let rpc_network = connect_unix_stream(path).await;
@@ -367,6 +376,8 @@ async fn mining_block_template_lifecycle() {
367376

368377
/// checkBlock with a template block payload, and interrupt.
369378
#[tokio::test]
379+
// Serialized because interrupt() can affect other in-flight mining waits.
380+
#[serial_test::serial]
370381
async fn mining_check_block_and_interrupt() {
371382
let path = unix_socket_path();
372383
let rpc_network = connect_unix_stream(path).await;

0 commit comments

Comments
 (0)