Skip to content

Commit 432dcd4

Browse files
authored
Merge pull request #6034 from fdefelici/test/pinny-stacks-node
test: integrate pinny on stacks-node
2 parents 574e188 + 820b8b7 commit 432dcd4

File tree

5 files changed

+50
-12
lines changed

5 files changed

+50
-12
lines changed

CONTRIBUTING.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,17 +361,31 @@ A non-exhaustive list of examples of consensus-critical changes include:
361361

362362
- Every consensus-critical change needs an integration test to verify that the feature activates only when the hard fork activates.
363363

364-
PRs must include test coverage. However, if your PR includes large tests or tests which cannot run in parallel
364+
- PRs must include test coverage. However, if your PR includes large tests or tests which cannot run in parallel
365365
(which is the default operation of the `cargo test` command), these tests should be decorated with `#[ignore]`.
366-
367366
A test should be marked `#[ignore]` if:
368367

369-
1. It does not _always_ pass `cargo test` in a vanilla environment
368+
1. It does not _always_ pass `cargo test` in a vanilla environment
370369
(i.e., it does not need to run with `--test-threads 1`).
371370

372-
2. Or, it runs for over a minute via a normal `cargo test` execution
371+
2. Or, it runs for over a minute via a normal `cargo test` execution
373372
(the `cargo test` command will warn if this is not the case).
374373

374+
- **Integration tests need to be properly tagged** using [pinny-rs](https://github.com/BitcoinL2-Labs/pinny-rs/) crate. Tagging requires two fundamental steps:
375+
1. Define allowed tags in the package `Cargo.toml` file (if needed).
376+
2. Apply relevant tags to the tests, picking from the allowed set.
377+
378+
Then it will be possible to run tests with filtering based on the tags using `cargo test` and `cargo nextest` runner.
379+
> For more information and examples on how tagging works, refer to the [pinny-rs](https://github.com/BitcoinL2-Labs/pinny-rs/) readme.
380+
381+
Below the tag set currently defined with related purpose:
382+
383+
| Tag | Description |
384+
|-----------------|----------------------------------------------|
385+
| `slow` | tests running over a minute |
386+
| `bitcoind` | tests requiring bitcoin daemon |
387+
| `flaky` | tests that exhibit flaky behavior |
388+
375389
## Formatting
376390

377391
PRs will be checked against `rustfmt` and will _fail_ if not properly formatted.

Cargo.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testnet/stacks-node/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ http-types = "2.12"
5151
tempfile = "3.3"
5252
mockito = "1.5"
5353
serial_test = "3.2.0"
54+
pinny = { git = "https://github.com/BitcoinL2-Labs/pinny-rs.git", rev = "54ba9d533a7b84525a5e65a3eae1a3ae76b9ea49" } #v0.0.2
5455
madhouse = { git = "https://github.com/stacks-network/madhouse-rs.git", rev = "fc651ddcbaf85e888b06d4a87aa788c4b7ba9309" }
5556
proptest = { git = "https://github.com/proptest-rs/proptest.git", rev = "c9bdf18c232665b2b740c667c81866b598d06dc7" }
5657

@@ -68,3 +69,6 @@ slog_json = ["stacks/slog_json", "stacks-common/slog_json", "clarity/slog_json"]
6869
prod-genesis-chainstate = []
6970
default = []
7071
testing = []
72+
73+
[package.metadata.pinny]
74+
allowed = ["bitcoind", "flaky", "slow"]

testnet/stacks-node/src/tests/integrations.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use clarity::vm::types::{
1313
};
1414
use clarity::vm::{ClarityVersion, Value};
1515
use lazy_static::lazy_static;
16+
use pinny::tag;
1617
use reqwest;
1718
use serde_json::json;
1819
use stacks::burnchains::Address;
@@ -41,7 +42,7 @@ use stacks::net::api::getistraitimplemented::GetIsTraitImplementedResponse;
4142
use stacks_common::types::chainstate::{StacksAddress, StacksBlockId, VRFSeed};
4243
use stacks_common::util::hash::{hex_bytes, to_hex, Sha256Sum};
4344

44-
use super::{ADDR_4, SK_1, SK_2, SK_3};
45+
use super::{new_test_conf, ADDR_4, SK_1, SK_2, SK_3};
4546
use crate::helium::RunLoop;
4647

4748
const OTHER_CONTRACT: &str = "
@@ -162,10 +163,11 @@ lazy_static! {
162163
static ref HTTP_BINDING: Mutex<Option<String>> = Mutex::new(None);
163164
}
164165

166+
#[tag(slow)]
165167
#[test]
166168
#[ignore]
167169
fn integration_test_get_info() {
168-
let mut conf = super::new_test_conf();
170+
let mut conf = new_test_conf();
169171
let spender_addr = to_addr(&StacksPrivateKey::from_hex(SK_3).unwrap()).into();
170172
let principal_sk = StacksPrivateKey::from_hex(SK_2).unwrap();
171173
let contract_sk = StacksPrivateKey::from_hex(SK_1).unwrap();
@@ -1086,9 +1088,10 @@ const FAUCET_CONTRACT: &str = "
10861088
(print (as-contract (stx-transfer? u1 .faucet recipient)))))
10871089
";
10881090

1091+
#[tag(slow)]
10891092
#[test]
10901093
fn contract_stx_transfer() {
1091-
let mut conf = super::new_test_conf();
1094+
let mut conf = new_test_conf();
10921095

10931096
let contract_sk = StacksPrivateKey::from_hex(SK_1).unwrap();
10941097
let sk_3 = StacksPrivateKey::from_hex(SK_3).unwrap();
@@ -1452,7 +1455,7 @@ fn contract_stx_transfer() {
14521455

14531456
#[test]
14541457
fn mine_transactions_out_of_order() {
1455-
let mut conf = super::new_test_conf();
1458+
let mut conf = new_test_conf();
14561459

14571460
let sk = StacksPrivateKey::from_hex(SK_3).unwrap();
14581461
let addr = to_addr(&sk);
@@ -1624,7 +1627,7 @@ fn mine_transactions_out_of_order() {
16241627
/// in the block it was processed for. Tests issue #1540
16251628
#[test]
16261629
fn mine_contract_twice() {
1627-
let mut conf = super::new_test_conf();
1630+
let mut conf = new_test_conf();
16281631
let contract_sk = StacksPrivateKey::from_hex(SK_1).unwrap();
16291632

16301633
conf.burnchain.commit_anchor_block_within = 1000;
@@ -1710,7 +1713,7 @@ fn mine_contract_twice() {
17101713

17111714
#[test]
17121715
fn bad_contract_tx_rollback() {
1713-
let mut conf = super::new_test_conf();
1716+
let mut conf = new_test_conf();
17141717

17151718
let contract_sk = StacksPrivateKey::from_hex(SK_1).unwrap();
17161719
let sk_2 = StacksPrivateKey::from_hex(SK_2).unwrap();
@@ -1994,7 +1997,7 @@ fn make_keys(seed: &str, count: u64) -> Vec<StacksPrivateKey> {
19941997

19951998
#[test]
19961999
fn block_limit_runtime_test() {
1997-
let mut conf = super::new_test_conf();
2000+
let mut conf = new_test_conf();
19982001

19992002
conf.burnchain.epochs = Some(EpochList::new(&[
20002003
StacksEpoch {
@@ -2179,7 +2182,7 @@ fn block_limit_runtime_test() {
21792182

21802183
#[test]
21812184
fn mempool_errors() {
2182-
let mut conf = super::new_test_conf();
2185+
let mut conf = new_test_conf();
21832186

21842187
conf.burnchain.commit_anchor_block_within = 5000;
21852188

testnet/stacks-node/src/tests/signer/v0.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use libsigner::{
3030
BlockProposal, BlockProposalData, SignerSession, StackerDBSession, VERSION_STRING,
3131
};
3232
use madhouse::{execute_commands, prop_allof, scenario, Command};
33+
use pinny::tag;
3334
use proptest::prelude::Strategy;
3435
use rand::{thread_rng, Rng};
3536
use rusqlite::Connection;
@@ -1487,6 +1488,7 @@ pub fn wait_for_state_machine_update(
14871488
})
14881489
}
14891490

1491+
#[tag(bitcoind)]
14901492
#[test]
14911493
#[ignore]
14921494
/// Test that a signer can respond to an invalid block proposal
@@ -10420,6 +10422,7 @@ fn multiple_miners_empty_sortition() {
1042010422
miners.shutdown();
1042110423
}
1042210424

10425+
#[tag(bitcoind, flaky, slow)]
1042310426
#[test]
1042410427
#[ignore]
1042510428
/// This test spins up a single nakamoto node configured to mine.

0 commit comments

Comments
 (0)