diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml index bd9205f4ee..69d440c056 100644 --- a/.github/workflows/smoke.yml +++ b/.github/workflows/smoke.yml @@ -64,7 +64,7 @@ jobs: uses: astriaorg/buildjet-rust-cache@v2.5.1 - name: run the pmonitor integration tests - run: nix develop --command just test-pmonitor + run: nix develop --command just integration-pmonitor # Integration tests that run against the public testnet endpoints. # Temporarily enabling these in CI, to provide assurance during refactoring. diff --git a/Cargo.lock b/Cargo.lock index 8d2b0829cd..2b8d657bda 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -408,7 +408,7 @@ dependencies = [ "nom", "num-traits", "rusticata-macros", - "thiserror 1.0.61", + "thiserror 1.0.69", "time", ] @@ -569,7 +569,7 @@ dependencies = [ "lazy_static", "log", "rustls-pki-types", - "thiserror 1.0.61", + "thiserror 1.0.69", "webpki-roots", ] @@ -1741,7 +1741,7 @@ dependencies = [ "decaf377", "proptest", "rand_core", - "thiserror 1.0.61", + "thiserror 1.0.69", ] [[package]] @@ -1768,7 +1768,7 @@ dependencies = [ "hex", "proptest", "rand_core", - "thiserror 1.0.61", + "thiserror 1.0.69", "zeroize", "zeroize_derive", ] @@ -1787,7 +1787,7 @@ dependencies = [ "hex", "rand_core", "serde", - "thiserror 1.0.61", + "thiserror 1.0.69", "zeroize", ] @@ -1996,7 +1996,7 @@ dependencies = [ "rand_core", "serde", "sha2 0.9.9", - "thiserror 1.0.61", + "thiserror 1.0.69", "zeroize", ] @@ -2287,7 +2287,7 @@ dependencies = [ "rand_core", "serde", "serdect", - "thiserror 1.0.61", + "thiserror 1.0.69", "visibility", "zeroize", ] @@ -2617,6 +2617,8 @@ version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ + "allocator-api2", + "equivalent", "foldhash", ] @@ -3498,7 +3500,7 @@ dependencies = [ "num-traits", "serde", "sha2 0.10.8", - "thiserror 1.0.61", + "thiserror 1.0.69", "tracing", ] @@ -3800,7 +3802,7 @@ dependencies = [ "metrics", "metrics-util 0.19.0", "quanta", - "thiserror 1.0.61", + "thiserror 1.0.69", "tokio", "tracing", ] @@ -4151,6 +4153,17 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "openapiv3" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc02deea53ffe807708244e5914f6b099ad7015a207ee24317c22112e17d9c5c" +dependencies = [ + "indexmap 2.7.1", + "serde", + "serde_json", +] + [[package]] name = "openssl" version = "0.10.64" @@ -4858,7 +4871,7 @@ dependencies = [ "serde_json", "serde_with", "sha2 0.10.8", - "thiserror 1.0.61", + "thiserror 1.0.69", "tracing", ] @@ -5130,7 +5143,7 @@ dependencies = [ "tap", "tendermint 0.40.1", "tendermint-light-client-verifier", - "thiserror 1.0.61", + "thiserror 1.0.69", "tokio", "tokio-stream", "tonic", @@ -5170,7 +5183,7 @@ dependencies = [ "proptest", "rand", "rand_core", - "thiserror 1.0.61", + "thiserror 1.0.69", "tokio", ] @@ -5272,7 +5285,7 @@ dependencies = [ "serde_json", "tap", "tendermint 0.40.1", - "thiserror 1.0.61", + "thiserror 1.0.69", "tokio", "tonic", "tracing", @@ -5358,7 +5371,7 @@ dependencies = [ "serde", "serde_json", "sha2 0.10.8", - "thiserror 1.0.61", + "thiserror 1.0.69", "tracing", ] @@ -5469,7 +5482,7 @@ dependencies = [ "serde", "serde_json", "sha2 0.10.8", - "thiserror 1.0.61", + "thiserror 1.0.69", "tracing", ] @@ -5574,7 +5587,7 @@ dependencies = [ "tendermint 0.40.1", "tendermint-proto 0.40.1", "tendermint-rpc", - "thiserror 1.0.61", + "thiserror 1.0.69", "tonic", "tower 0.4.13", "tracing", @@ -5665,7 +5678,7 @@ dependencies = [ "serde_json", "tap", "tendermint 0.40.1", - "thiserror 1.0.61", + "thiserror 1.0.69", "tonic", "tracing", ] @@ -5751,7 +5764,7 @@ dependencies = [ "serde", "serde_json", "static_assertions", - "thiserror 1.0.61", + "thiserror 1.0.69", "tracing", ] @@ -5909,7 +5922,7 @@ dependencies = [ "serde_json", "sha2 0.10.8", "tendermint 0.40.1", - "thiserror 1.0.61", + "thiserror 1.0.69", "tokio", "tracing", ] @@ -6199,6 +6212,7 @@ dependencies = [ "penumbra-sdk-stake", "penumbra-sdk-tct", "penumbra-sdk-view", + "process-compose-openapi-client", "regex", "rustls 0.23.21", "serde", @@ -6354,9 +6368,9 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.20" +version = "0.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" +checksum = "6924ced06e1f7dfe3fa48d57b9f74f55d8915f5036121bef647ef4b204895fac" dependencies = [ "proc-macro2 1.0.93", "syn 2.0.96", @@ -6457,6 +6471,21 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "process-compose-openapi-client" +version = "1.40.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fe1021aa3ae3cb55ce80be3ff0f4f16cf0726d5c8af5c99fd6fc1a2985ba056" +dependencies = [ + "prettyplease", + "progenitor", + "progenitor-client", + "reqwest 0.12.9", + "serde", + "serde_json", + "syn 2.0.96", +] + [[package]] name = "procfs" version = "0.17.0" @@ -6479,6 +6508,72 @@ dependencies = [ "hex", ] +[[package]] +name = "progenitor" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "293df5b79211fbf0c1ebad6513ba451d267e9c15f5f19ee5d3da775e2dd27331" +dependencies = [ + "progenitor-client", + "progenitor-impl", + "progenitor-macro", +] + +[[package]] +name = "progenitor-client" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4a5db54eac3cae7007a0785854bc3e89fd418cca7dfc2207b99b43979154c1b" +dependencies = [ + "bytes", + "futures-core", + "percent-encoding", + "reqwest 0.12.9", + "serde", + "serde_json", + "serde_urlencoded", +] + +[[package]] +name = "progenitor-impl" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d85934a440963a69f9f04f48507ff6e7aa2952a5b2d8f96cc37fa3dd5c270f66" +dependencies = [ + "heck 0.5.0", + "http 1.2.0", + "indexmap 2.7.1", + "openapiv3", + "proc-macro2 1.0.93", + "quote", + "regex", + "schemars", + "serde", + "serde_json", + "syn 2.0.96", + "thiserror 1.0.69", + "typify", + "unicode-ident", +] + +[[package]] +name = "progenitor-macro" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d99a5a259e2d65a4933054aa51717c70b6aba0522695731ac354a522124efc9b" +dependencies = [ + "openapiv3", + "proc-macro2 1.0.93", + "progenitor-impl", + "quote", + "schemars", + "serde", + "serde_json", + "serde_tokenstream", + "serde_yaml", + "syn 2.0.96", +] + [[package]] name = "proptest" version = "1.6.0" @@ -6811,7 +6906,7 @@ checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom", "libredox 0.1.3", - "thiserror 1.0.61", + "thiserror 1.0.69", ] [[package]] @@ -6858,6 +6953,16 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +[[package]] +name = "regress" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ef7fa9ed0256d64a688a3747d0fef7a88851c18a5e1d57f115f38ec2e09366" +dependencies = [ + "hashbrown 0.15.2", + "memchr", +] + [[package]] name = "relative-path" version = "1.9.3" @@ -7370,6 +7475,32 @@ dependencies = [ "parking_lot", ] +[[package]] +name = "schemars" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" +dependencies = [ + "chrono", + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", + "uuid", +] + +[[package]] +name = "schemars_derive" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" +dependencies = [ + "proc-macro2 1.0.93", + "quote", + "serde_derive_internals", + "syn 2.0.96", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -7427,12 +7558,15 @@ name = "semver" version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +dependencies = [ + "serde", +] [[package]] name = "serde" -version = "1.0.203" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] @@ -7448,9 +7582,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.217" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +dependencies = [ + "proc-macro2 1.0.93", + "quote", + "syn 2.0.96", +] + +[[package]] +name = "serde_derive_internals" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2 1.0.93", "quote", @@ -7459,12 +7604,13 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.118" +version = "1.0.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d947f6b3163d8857ea16c4fa0dd4840d52f3041039a85decd46867eb1abef2e4" +checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" dependencies = [ "indexmap 2.7.1", "itoa", + "memchr", "ryu", "serde", ] @@ -7499,6 +7645,18 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_tokenstream" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64060d864397305347a78851c51588fd283767e7e7589829e8121d65512340f1" +dependencies = [ + "proc-macro2 1.0.93", + "quote", + "serde", + "syn 2.0.96", +] + [[package]] name = "serde_unit_struct" version = "0.1.3" @@ -7560,6 +7718,19 @@ dependencies = [ "syn 2.0.96", ] +[[package]] +name = "serde_yaml" +version = "0.9.34+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" +dependencies = [ + "indexmap 2.7.1", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + [[package]] name = "serdect" version = "0.2.0" @@ -7804,7 +7975,7 @@ dependencies = [ "sha2 0.10.8", "smallvec", "sqlformat", - "thiserror 1.0.61", + "thiserror 1.0.69", "tokio", "tokio-stream", "tracing", @@ -7890,7 +8061,7 @@ dependencies = [ "smallvec", "sqlx-core", "stringprep", - "thiserror 1.0.61", + "thiserror 1.0.69", "tracing", "whoami", ] @@ -7931,7 +8102,7 @@ dependencies = [ "smallvec", "sqlx-core", "stringprep", - "thiserror 1.0.61", + "thiserror 1.0.69", "tracing", "whoami", ] @@ -8357,7 +8528,7 @@ dependencies = [ "tendermint 0.40.1", "tendermint-config", "tendermint-proto 0.40.1", - "thiserror 1.0.61", + "thiserror 1.0.69", "time", "tokio", "tracing", @@ -8401,11 +8572,11 @@ checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl 1.0.61", + "thiserror-impl 1.0.69", ] [[package]] @@ -8419,9 +8590,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2 1.0.93", "quote", @@ -8826,7 +8997,7 @@ checksum = "b882e5e82ee7440a08335f4d5a2edd9f7678b2cba73eac4826b53c22fd76fdd3" dependencies = [ "futures", "pin-project", - "thiserror 1.0.61", + "thiserror 1.0.69", "tokio", "tokio-util 0.7.11", "tower 0.4.13", @@ -8960,6 +9131,53 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "typify" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c644dda9862f0fef3a570d8ddb3c2cfb1d5ac824a1f2ddfa7bc8f071a5ad8a" +dependencies = [ + "typify-impl", + "typify-macro", +] + +[[package]] +name = "typify-impl" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59ab345b6c0d8ae9500b9ff334a4c7c0d316c1c628dc55726b95887eb8dbd11" +dependencies = [ + "heck 0.5.0", + "log", + "proc-macro2 1.0.93", + "quote", + "regress", + "schemars", + "semver", + "serde", + "serde_json", + "syn 2.0.96", + "thiserror 1.0.69", + "unicode-ident", +] + +[[package]] +name = "typify-macro" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "785e2cdcef0df8160fdd762ed548a637aaec1e83704fdbc14da0df66013ee8d0" +dependencies = [ + "proc-macro2 1.0.93", + "quote", + "schemars", + "semver", + "serde", + "serde_json", + "serde_tokenstream", + "syn 2.0.96", + "typify-impl", +] + [[package]] name = "uint" version = "0.9.5" @@ -9048,6 +9266,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "unsafe-libyaml" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" + [[package]] name = "untrusted" version = "0.9.0" @@ -9579,7 +9803,7 @@ dependencies = [ "nom", "oid-registry", "rusticata-macros", - "thiserror 1.0.61", + "thiserror 1.0.69", "time", ] diff --git a/crates/bin/pmonitor/Cargo.toml b/crates/bin/pmonitor/Cargo.toml index c7899bb40f..d65279fc53 100644 --- a/crates/bin/pmonitor/Cargo.toml +++ b/crates/bin/pmonitor/Cargo.toml @@ -13,6 +13,7 @@ publish = false dist = true [features] +network-integration = [] integration-testnet = [] [dependencies] @@ -49,4 +50,5 @@ uuid = { version = "1.3", features = ["v4", "serde"] } [dev-dependencies] assert_cmd = {workspace = true} once_cell = {workspace = true} +process-compose-openapi-client = "1.40.1" tempfile = {workspace = true} diff --git a/crates/bin/pmonitor/tests/common/mod.rs b/crates/bin/pmonitor/tests/common/mod.rs index 4d37a6ec08..03aa6413a5 100644 --- a/crates/bin/pmonitor/tests/common/mod.rs +++ b/crates/bin/pmonitor/tests/common/mod.rs @@ -8,6 +8,7 @@ use assert_cmd::Command as AssertCommand; use once_cell::sync::Lazy; use pcli::config::PcliConfig; use penumbra_sdk_keys::address::Address; +use process_compose_openapi_client::Client; use std::fs::{create_dir_all, remove_dir_all, File}; use std::io::{BufWriter, Write}; use std::path::PathBuf; @@ -285,7 +286,7 @@ impl PmonitorTestRunner { "'process-compose down' completed, sleeping briefly during teardown" ); - std::thread::sleep(Duration::from_secs(3)); + std::thread::sleep(Duration::from_secs(2)); return Ok(()); } Err(_e) => { @@ -300,7 +301,7 @@ impl PmonitorTestRunner { /// Run a local devnet based on input config. Returns a handle to the spawned process, /// so that cleanup can be handled gracefully. /// We assume that the port `8888` is unique to the process-compose API for this test suite. - pub fn start_devnet(&self) -> anyhow::Result { + pub async fn start_devnet(&self) -> anyhow::Result { // Ensure no other instance is currently running; self.stop_devnet()?; @@ -324,9 +325,52 @@ impl PmonitorTestRunner { .stderr(Stdio::null()) .spawn() .expect("failed to execute devnet start cmd"); - // Sleep a bit, to let network start - // TODO: use process-compose API to check for "Running" status on pd. - std::thread::sleep(Duration::from_secs(8)); + + // Use process-compose API to check for "Running" status on pd. + let _pd_result = poll_for_ready("pd").await?; + let _cmt_result = poll_for_ready("cometbft").await?; + tracing::debug!("all processes ready, devnet is running"); Ok(child) } } + +/// Block until the process-compose service denoted by `process_name` reports "Ready" +/// in its status API. Polls once per second, timing out after 60s. +async fn poll_for_ready(process_name: &str) -> anyhow::Result<()> { + // Connect to the running process-compose service, via the custom port. + let c = Client::new(format!("http://localhost:{}", PROCESS_COMPOSE_PORT).as_str()); + + // Configure timeout, so we can error out if the service never comes up. + let timeout = 60; + let mut elapsed = 0; + while elapsed < timeout { + let resp = c.get_process(process_name).await; + // Ignore error to API server, process-compose may not be up yet. + if let Ok(r) = resp { + let state = r.into_inner().is_ready; + match state.as_deref() { + Some("-") => { + tracing::debug!("still waiting for process to be ready: {}", process_name); + } + Some("Ready") => { + tracing::debug!("process '{}' is ready!", process_name); + return Ok(()); + } + _ => { + tracing::warn!( + "unexpected status for process '{}', waiting...", + process_name + ); + } + } + } + // Sleep and try again + tokio::time::sleep(Duration::from_secs(1)).await; + elapsed = elapsed + 1; + } + anyhow::bail!( + "process '{}' not ready after {} seconds, failing", + process_name, + timeout + ); +} diff --git a/crates/bin/pmonitor/tests/network_integration.rs b/crates/bin/pmonitor/tests/network_integration.rs index c5bad684fb..05c41197d9 100644 --- a/crates/bin/pmonitor/tests/network_integration.rs +++ b/crates/bin/pmonitor/tests/network_integration.rs @@ -1,3 +1,4 @@ +#![cfg(feature = "network-integration")] //! Integration integration testing of `pmonitor` against a local devnet. //! Sets up various scenarios of genesis allocations, and ensures the tool reports //! violations as errors. @@ -12,17 +13,16 @@ mod common; use crate::common::pcli_helpers::{pcli_init_softkms, pcli_migrate_balance, pcli_view_address}; use crate::common::PmonitorTestRunner; -#[ignore] -#[test] +#[tokio::test] /// Tests the simplest happy path for pmonitor: all wallets have genesis balances, /// they never transferred any funds out, nor migrated balances, so all /// current balances equal the genesis balances. In this case `pmonitor` /// should exit 0. -fn audit_passes_on_compliant_wallets() -> anyhow::Result<()> { +async fn audit_passes_on_compliant_wallets() -> anyhow::Result<()> { tracing_subscriber::fmt::try_init().ok(); let p = PmonitorTestRunner::new(); p.create_pcli_wallets()?; - let _network = p.start_devnet()?; + let _network = p.start_devnet().await?; p.initialize_pmonitor()?; // Debugging: uncomment the sleep line below if you want to interact with the pmonitor testbed @@ -38,17 +38,16 @@ fn audit_passes_on_compliant_wallets() -> anyhow::Result<()> { Ok(()) } -#[ignore] -#[test] +#[tokio::test] /// Tests another happy path for pmonitor: all wallets have genesis balances, /// one of the wallets ran `pcli migrate balance` once. This means that all /// wallets still have their genesis balance, save one, which has the genesis /// balance minus gas fees. In this case, `pmonitor` should exit 0, /// because it understood the balance migration and updated the FVK. -fn audit_passes_on_wallets_that_migrated_once() -> anyhow::Result<()> { +async fn audit_passes_on_wallets_that_migrated_once() -> anyhow::Result<()> { let p = PmonitorTestRunner::new(); p.create_pcli_wallets()?; - let _network = p.start_devnet()?; + let _network = p.start_devnet().await?; // Run audit once, to confirm compliance on clean slate. p.initialize_pmonitor()?; p.pmonitor_audit()?; @@ -72,18 +71,17 @@ fn audit_passes_on_wallets_that_migrated_once() -> anyhow::Result<()> { Ok(()) } -#[ignore] -#[test] +#[tokio::test] /// Tests another happy path for pmonitor: all wallets have genesis balances, /// one of the wallets ran `pcli migrate balance` once, then that receiving /// wallet ran `pcli migrate balance` itself, so the genesis funds are now /// two (2) FVKs away from the original account. In this case, /// pmonitor` should exit 0, because it understood all balance migrations /// and updated the FVK in its config file accordingly. -fn audit_passes_on_wallets_that_migrated_twice() -> anyhow::Result<()> { +async fn audit_passes_on_wallets_that_migrated_twice() -> anyhow::Result<()> { let p = PmonitorTestRunner::new(); p.create_pcli_wallets()?; - let _network = p.start_devnet()?; + let _network = p.start_devnet().await?; // Run audit once, to confirm compliance on clean slate. p.initialize_pmonitor()?; p.pmonitor_audit() @@ -127,15 +125,15 @@ fn audit_passes_on_wallets_that_migrated_twice() -> anyhow::Result<()> { Ok(()) } -#[ignore] -#[test] + +#[tokio::test] /// Tests an unhappy path for `pmonitor`: a single wallet has sent all its funds /// to non-genesis account, via `pcli tx send` rather than `pcli migrate balance`. /// In this case, `pmonitor` should exit non-zero. -fn audit_fails_on_misbehaving_wallet_that_sent_funds() -> anyhow::Result<()> { +async fn audit_fails_on_misbehaving_wallet_that_sent_funds() -> anyhow::Result<()> { let p = PmonitorTestRunner::new(); p.create_pcli_wallets()?; - let _network = p.start_devnet()?; + let _network = p.start_devnet().await?; // Run audit once, to confirm compliance on clean slate. p.initialize_pmonitor()?; p.pmonitor_audit()?; @@ -174,17 +172,17 @@ fn audit_fails_on_misbehaving_wallet_that_sent_funds() -> anyhow::Result<()> { Ok(()) } -#[ignore] -#[test] +#[tokio::test] /// Tests a happy path for `pmonitor`: a single wallet has sent all its funds /// to non-genesis account, via `pcli tx send` rather than `pcli migrate balance`, /// but the receiving wallet then sent those funds back. /// In this case, `pmonitor` should exit zero. -fn audit_passes_on_misbehaving_wallet_that_sent_funds_but_got_them_back() -> anyhow::Result<()> { +async fn audit_passes_on_misbehaving_wallet_that_sent_funds_but_got_them_back() -> anyhow::Result<()> +{ tracing_subscriber::fmt::try_init().ok(); let p = PmonitorTestRunner::new(); p.create_pcli_wallets()?; - let _network = p.start_devnet()?; + let _network = p.start_devnet().await?; // Run audit once, to confirm compliance on clean slate. p.initialize_pmonitor()?; p.pmonitor_audit()?; diff --git a/justfile b/justfile index 1c78b564b5..13c246fa8d 100644 --- a/justfile +++ b/justfile @@ -2,15 +2,6 @@ default: @just --list -# Run integration tests for pmonitor tool -test-pmonitor: - # prebuild cargo binaries required for integration tests - cargo -q build --package pcli --package pd --package pmonitor - cargo -q run --release --bin pd -- network unsafe-reset-all - rm -rf /tmp/pmonitor-integration-test - cargo nextest run -p pmonitor --run-ignored=ignored-only --test-threads 1 - # cargo test -p pmonitor -- --ignored --test-threads 1 --nocapture - # Creates and runs a local devnet with solo validator. Includes ancillary services # like metrics, postgres for storing ABCI events, and pindexer for munging those events. dev: @@ -63,6 +54,15 @@ test: integration-testnet: cargo nextest run --release --features integration-testnet -E 'test(/_testnet$/)' +# Run integration tests for pmonitor tool +integration-pmonitor: + ./deployments/scripts/warn-about-pd-state + rm -rf /tmp/pmonitor-integration-test + # Prebuild binaries, so they're available inside the tests without blocking. + cargo build --release --bin pcli --bin pd --bin pmonitor + cargo -q run --release --bin pd -- --help > /dev/null + cargo nextest run --release -p pmonitor --features network-integration --no-capture --no-fail-fast + # Run smoke test suite, via process-compose config. smoke: ./deployments/scripts/check-nix-shell