diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 83406fdeb..db2dc61bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,8 +38,26 @@ jobs: if: ${{ matrix.rust != '1.65' }} # MSRV run: cargo test --workspace ${{ matrix.flags }} + miri: + name: miri ${{ matrix.flags }} + runs-on: ubuntu-latest + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + flags: ["--no-default-features", "", "--all-features"] + env: + MIRIFLAGS: -Zmiri-strict-provenance + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@miri + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - run: cargo miri setup ${{ matrix.flags }} + - run: cargo miri test ${{ matrix.flags }} + wasm: - name: check WASM runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -54,7 +72,6 @@ jobs: run: cargo check --workspace --target wasm32-unknown-unknown feature-checks: - name: feature checks runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -68,7 +85,6 @@ jobs: run: cargo hack check --feature-powerset --depth 2 --all-targets clippy: - name: clippy runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -82,7 +98,6 @@ jobs: RUSTFLAGS: -Dwarnings docs: - name: docs runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -96,7 +111,6 @@ jobs: RUSTDOCFLAGS: "--cfg docsrs -D warnings" fmt: - name: fmt runs-on: ubuntu-latest timeout-minutes: 30 steps: diff --git a/crates/dyn-abi/src/arbitrary.rs b/crates/dyn-abi/src/arbitrary.rs index b7d0d2c09..2063d82a1 100644 --- a/crates/dyn-abi/src/arbitrary.rs +++ b/crates/dyn-abi/src/arbitrary.rs @@ -521,7 +521,7 @@ fn int_strategy() -> impl Strategy(), any::().prop_map(int_size)) } -#[cfg(test)] +#[cfg(all(test, not(miri)))] // doesn't run in isolation and would take too long mod tests { use super::*; #[cfg(feature = "eip712")] diff --git a/crates/json-abi/tests/abi.rs b/crates/json-abi/tests/abi.rs index 39cfac32a..136488693 100644 --- a/crates/json-abi/tests/abi.rs +++ b/crates/json-abi/tests/abi.rs @@ -2,8 +2,9 @@ use alloy_json_abi::{AbiItem, EventParam, JsonAbi, Param}; use std::collections::HashMap; macro_rules! abi_parse_tests { - ($($name:ident($path:literal, $len:literal))*) => {$( + ($( $(#[$attr:meta])* $name:ident($path:literal, $len:literal))*) => {$( #[test] + $(#[$attr])* fn $name() { parse_test(include_str!($path), $len, $path); } @@ -12,19 +13,22 @@ macro_rules! abi_parse_tests { abi_parse_tests! { abiencoderv2("abi/Abiencoderv2Test.json", 1) + #[cfg_attr(miri, ignore = "takes too long")] console("abi/console.json", 379) event_with_struct("abi/EventWithStruct.json", 1) large_array("abi/LargeArray.json", 1) large_struct("abi/LargeStruct.json", 1) + #[cfg_attr(miri, ignore = "takes too long")] large_structs("abi/LargeStructs.json", 4) large_tuple("abi/LargeTuple.json", 1) + #[cfg_attr(miri, ignore = "takes too long")] seaport("abi/Seaport.json", 69) udvts("abi/Udvts.json", 1) } #[allow(unused_variables)] fn load_test(path: &str, abi: &JsonAbi) { - #[cfg(all(feature = "std", feature = "serde_json"))] + #[cfg(all(feature = "std", feature = "serde_json", not(miri)))] { use std::{fs::File, io::BufReader}; let file_path: String = format!("tests/{path}"); diff --git a/crates/json-abi/tests/test.rs b/crates/json-abi/tests/test.rs index 1f78acb8c..39d84251b 100644 --- a/crates/json-abi/tests/test.rs +++ b/crates/json-abi/tests/test.rs @@ -47,6 +47,7 @@ fn big_function() { } #[test] +#[cfg_attr(miri, ignore = "takes too long")] fn test_constructor() { // Parse the ABI JSON file let abi_items_wo_constructor = include_str!("abi/Abiencoderv2Test.json"); @@ -65,6 +66,7 @@ fn test_constructor() { } #[test] +#[cfg_attr(miri, ignore = "no fs")] fn no_from_reader() { let path = "abi/Abiencoderv2Test.json"; let file_path: String = format!("tests/{path}"); diff --git a/crates/primitives/src/bits/address.rs b/crates/primitives/src/bits/address.rs index 39bdd3743..8525c624f 100644 --- a/crates/primitives/src/bits/address.rs +++ b/crates/primitives/src/bits/address.rs @@ -553,6 +553,7 @@ mod tests { #[test] #[cfg(all(feature = "rlp", feature = "arbitrary"))] + #[cfg_attr(miri, ignore = "doesn't run in isolation and would take too long")] fn create_correctness() { fn create_slow(address: &Address, nonce: u64) -> Address { use alloy_rlp::Encodable; diff --git a/crates/sol-types/src/types/data_type.rs b/crates/sol-types/src/types/data_type.rs index 6fa987b4b..5d18c833a 100644 --- a/crates/sol-types/src/types/data_type.rs +++ b/crates/sol-types/src/types/data_type.rs @@ -970,6 +970,7 @@ mod tests { ($($name:ident($st:ty : $t:ty);)+) => { proptest::proptest! {$( #[test] + #[cfg_attr(miri, ignore = "doesn't run in isolation and would take too long")] fn $name(i: $t) { proptest::prop_assert_eq!(<$st>::detokenize(<$st>::tokenize(&i)), i); } diff --git a/crates/syn-solidity/src/item/function.rs b/crates/syn-solidity/src/item/function.rs index bd0892339..73c6ca9a9 100644 --- a/crates/syn-solidity/src/item/function.rs +++ b/crates/syn-solidity/src/item/function.rs @@ -386,6 +386,7 @@ mod tests { }; #[test] + #[cfg_attr(miri, ignore = "takes too long")] fn getters() { macro_rules! test_getters { ($($var:literal => $f:literal),* $(,)?) => { diff --git a/crates/syn-solidity/tests/contracts.rs b/crates/syn-solidity/tests/contracts.rs index 0525cd6f9..190f438e0 100644 --- a/crates/syn-solidity/tests/contracts.rs +++ b/crates/syn-solidity/tests/contracts.rs @@ -11,6 +11,7 @@ use syn_solidity::{ }; #[test] +#[cfg_attr(miri, ignore = "no fs")] fn contracts() { static PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/contracts"); let root = Path::new(env!("CARGO_MANIFEST_DIR"))