From 2737a71dc5d86cd04b908ca19241d3c2282d2921 Mon Sep 17 00:00:00 2001 From: Eric Woolsey Date: Thu, 10 Oct 2024 11:50:59 -0700 Subject: [PATCH] fix tests --- world-chain-builder/Cargo.lock | 41 +++++++++++++++++++++++ world-chain-builder/Cargo.toml | 1 + world-chain-builder/src/e2e_tests/mod.rs | 5 +++ world-chain-builder/src/pool/validator.rs | 18 ---------- 4 files changed, 47 insertions(+), 18 deletions(-) diff --git a/world-chain-builder/Cargo.lock b/world-chain-builder/Cargo.lock index 6638b20b..87285e82 100644 --- a/world-chain-builder/Cargo.lock +++ b/world-chain-builder/Cargo.lock @@ -10064,6 +10064,15 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "scc" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836f1e0f4963ef5288b539b643b35e043e76a32d0f4e47e67febf69576527f50" +dependencies = [ + "sdd", +] + [[package]] name = "schannel" version = "0.1.26" @@ -10121,6 +10130,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" +[[package]] +name = "sdd" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a7b59a5d9b0099720b417b6325d91a52cbf5b3dcb5041d864be53eefa58abc" + [[package]] name = "seahash" version = "4.1.0" @@ -10430,6 +10445,31 @@ dependencies = [ "unsafe-libyaml", ] +[[package]] +name = "serial_test" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b4b487fe2acf240a021cf57c6b2b4903b1e78ca0ecd862a71b71d2a51fed77d" +dependencies = [ + "futures", + "log", + "once_cell", + "parking_lot 0.12.3", + "scc", + "serial_test_derive", +] + +[[package]] +name = "serial_test_derive" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + [[package]] name = "sha1" version = "0.10.6" @@ -12997,6 +13037,7 @@ dependencies = [ "semaphore", "serde", "serde_json", + "serial_test", "strum", "strum_macros", "tempfile", diff --git a/world-chain-builder/Cargo.toml b/world-chain-builder/Cargo.toml index 54d044fa..2c63693e 100644 --- a/world-chain-builder/Cargo.toml +++ b/world-chain-builder/Cargo.toml @@ -91,6 +91,7 @@ bytes = "1.7.2" hex = "0.4.3" [dev-dependencies] +serial_test = "3" tempfile = "3" test-case = "3" ethers-core = { git = "https://github.com/gakonst/ethers-rs", default-features = false } diff --git a/world-chain-builder/src/e2e_tests/mod.rs b/world-chain-builder/src/e2e_tests/mod.rs index 2749c03c..ec076af2 100644 --- a/world-chain-builder/src/e2e_tests/mod.rs +++ b/world-chain-builder/src/e2e_tests/mod.rs @@ -51,6 +51,7 @@ use semaphore::{ protocol::{generate_nullifier_hash, generate_proof}, Field, }; +use serial_test::serial; use std::{ collections::{BTreeMap, HashMap}, sync::Arc, @@ -227,6 +228,7 @@ impl WorldChainBuilderTestContext { } #[tokio::test] +#[serial] async fn test_can_build_pbh_payload() -> eyre::Result<()> { tokio::time::sleep(Duration::from_secs(1)).await; let mut ctx = WorldChainBuilderTestContext::setup().await?; @@ -255,6 +257,7 @@ async fn test_can_build_pbh_payload() -> eyre::Result<()> { } #[tokio::test] +#[serial] async fn test_transaction_pool_ordering() -> eyre::Result<()> { tokio::time::sleep(Duration::from_secs(1)).await; let mut ctx = WorldChainBuilderTestContext::setup().await?; @@ -298,6 +301,7 @@ async fn test_transaction_pool_ordering() -> eyre::Result<()> { } #[tokio::test] +#[serial] async fn test_invalidate_dup_tx_and_nullifier() -> eyre::Result<()> { tokio::time::sleep(Duration::from_secs(1)).await; let ctx = WorldChainBuilderTestContext::setup().await?; @@ -310,6 +314,7 @@ async fn test_invalidate_dup_tx_and_nullifier() -> eyre::Result<()> { } #[tokio::test] +#[serial] async fn test_dup_pbh_nonce() -> eyre::Result<()> { tokio::time::sleep(Duration::from_secs(1)).await; let mut ctx = WorldChainBuilderTestContext::setup().await?; diff --git a/world-chain-builder/src/pool/validator.rs b/world-chain-builder/src/pool/validator.rs index 483e3e30..2d34dd09 100644 --- a/world-chain-builder/src/pool/validator.rs +++ b/world-chain-builder/src/pool/validator.rs @@ -561,24 +561,6 @@ pub mod tests { assert!(res.is_err()); } - #[test] - fn validate_external_nullifier_hash_mismatch() { - let external_nullifier = "v1-012025-1"; - - let validator = world_chain_validator(); - let date = chrono::Utc.with_ymd_and_hms(2025, 1, 1, 0, 0, 0).unwrap(); - - let payload = PbhPayload { - external_nullifier: external_nullifier.to_string(), - nullifier_hash: Field::ZERO, - root: Field::ZERO, - proof: Default::default(), - }; - - let res = validator.validate_external_nullifier(date, &payload); - assert!(res.is_err()); - } - #[test_case("v1-012025-0")] #[test_case("v1-012025-1")] #[test_case("v1-012025-29")]