From ea31dd268a02397b73a2e79f29a94321a6d0a26f Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Fri, 29 Nov 2024 13:40:37 +0100 Subject: [PATCH 01/68] Run some checks on windows --- .github/workflows/ci.yml | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d10c834bc..844699245a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,10 @@ on: jobs: test-forge-unit-and-integration: name: Test Forge / Unit and Integration Tests - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, windows-latest ] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -23,7 +26,10 @@ jobs: - run: cargo test --release integration -p forge build-test-forge-e2e-nextest-archive: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, windows-latest ] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -35,16 +41,17 @@ jobs: - name: Upload archive to workflow uses: actions/upload-artifact@v4 with: - name: nextest-archive - path: nextest-archive.tar.zst + name: nextest-archive-${{ matrix.os }} + path: nextest-archive-${{ matrix.os }}.tar.zst test-forge-e2e: name: Test Forge / E2E Tests - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} needs: build-test-forge-e2e-nextest-archive strategy: matrix: partition: [ 1, 2, 3, 4, 5, 6, 7, 8 ] + os: [ ubuntu-latest, windows-latest ] steps: - name: Extract branch name if: github.event_name != 'pull_request' @@ -84,13 +91,16 @@ jobs: - uses: taiki-e/install-action@nextest - uses: actions/download-artifact@v4 with: - name: nextest-archive + name: nextest-archive-${{ matrix.os }} - name: nextest partition ${{ matrix.partition }}/8 - run: cargo nextest run --partition 'count:${{ matrix.partition }}/8' --archive-file 'nextest-archive.tar.zst' e2e + run: cargo nextest run --partition 'count:${{ matrix.partition }}/8' --archive-file 'nextest-archive-${{ matrix.platform.os }}.tar.zst' e2e test-scarb-2-8-3: name: Test scarb 2.8.3 - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, windows-latest ] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -188,7 +198,10 @@ jobs: test-cast: name: Test Cast - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, windows-latest ] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a @@ -229,7 +242,10 @@ jobs: test-scarb-api: name: Test Scarb Api - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, windows-latest ] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable From 3fb3906fce204694714d94837a4951623d4750a8 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Fri, 29 Nov 2024 13:59:30 +0100 Subject: [PATCH 02/68] Remove linux specific expected message --- crates/sncast/src/state/state_file.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/sncast/src/state/state_file.rs b/crates/sncast/src/state/state_file.rs index 920ea6f93c..ef5148e26b 100644 --- a/crates/sncast/src/state/state_file.rs +++ b/crates/sncast/src/state/state_file.rs @@ -396,7 +396,8 @@ mod tests { } #[test] - #[should_panic(expected = "No such file or directory (os error 2)")] + #[should_panic] + // TODO handle system specific panics fn test_load_state_file_invalid_path() { let state_file = Utf8PathBuf::from("bla/bla/crypto.json"); load_state_file(&state_file).unwrap(); From 5ebc63a72c97106b7d692eda4202c5dacfacb4ab Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Fri, 29 Nov 2024 13:59:58 +0100 Subject: [PATCH 03/68] Run 2.8.3 only on ubuntu-latest --- .github/workflows/ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 844699245a..3a314de7c4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,10 +97,7 @@ jobs: test-scarb-2-8-3: name: Test scarb 2.8.3 - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ ubuntu-latest, windows-latest ] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable From b738f1285ee28ed7b89bbfb96e5499c14c6baef6 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Fri, 29 Nov 2024 16:03:00 +0100 Subject: [PATCH 04/68] Ignore fork related integration tests on windows --- crates/forge/tests/integration/cheat_fork.rs | 36 +++++++++++--------- crates/forge/tests/integration/setup_fork.rs | 6 ++++ crates/forge/tests/integration/spy_events.rs | 1 + 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/crates/forge/tests/integration/cheat_fork.rs b/crates/forge/tests/integration/cheat_fork.rs index a1ba19c3de..273f3d4a5b 100644 --- a/crates/forge/tests/integration/cheat_fork.rs +++ b/crates/forge/tests/integration/cheat_fork.rs @@ -4,6 +4,7 @@ use test_utils::runner::assert_passed; use test_utils::running_tests::run_test_case; use test_utils::test_case; +#[cfg(not(target_os = "windows"))] #[test] fn cheat_caller_address_cairo0_contract() { let test = test_case!(formatdoc!( @@ -52,6 +53,7 @@ fn cheat_caller_address_cairo0_contract() { assert_passed(&result); } +#[cfg(not(target_os = "windows"))] #[test] fn cheat_block_number_cairo0_contract() { let test = test_case!(formatdoc!( @@ -100,6 +102,7 @@ fn cheat_block_number_cairo0_contract() { assert_passed(&result); } +#[cfg(not(target_os = "windows"))] #[test] fn cheat_block_timestamp_cairo0_contract() { let test = test_case!(formatdoc!( @@ -151,11 +154,11 @@ fn cheat_block_timestamp_cairo0_contract() { } #[test] -fn mock_call_cairo0_contract() { +fn store_load_cairo0_contract() { let test = test_case!(formatdoc!( r#" use starknet::{{contract_address_const}}; - use snforge_std::{{start_mock_call, stop_mock_call}}; + use snforge_std::{{store, load}}; #[starknet::interface] trait IERC20 {{ @@ -173,13 +176,17 @@ fn mock_call_cairo0_contract() { assert(eth_dispatcher.name() == 'Ether', 'invalid name'); - start_mock_call(eth_dispatcher.contract_address, selector!("name"), 'NotEther'); + let name = load(eth_dispatcher.contract_address, selector!("ERC20_name"), 1); - assert(eth_dispatcher.name() == 'NotEther', 'invalid mocked name'); + assert(name == array!['Ether'], 'invalid load value'); - stop_mock_call(eth_dispatcher.contract_address, selector!("name")); + store(eth_dispatcher.contract_address, selector!("ERC20_name"), array!['NotEther'].span()); - assert(eth_dispatcher.name() == 'Ether', 'invalid name after mock'); + assert(eth_dispatcher.name() == 'NotEther', 'invalid store name'); + + let name = load(eth_dispatcher.contract_address, selector!("ERC20_name"), 1); + + assert(name == array!['NotEther'], 'invalid load2 name'); }} "#, node_rpc_url(), @@ -191,12 +198,13 @@ fn mock_call_cairo0_contract() { assert_passed(&result); } +#[cfg(not(target_os = "windows"))] #[test] -fn store_load_cairo0_contract() { +fn mock_call_cairo0_contract() { let test = test_case!(formatdoc!( r#" use starknet::{{contract_address_const}}; - use snforge_std::{{store, load}}; + use snforge_std::{{start_mock_call, stop_mock_call}}; #[starknet::interface] trait IERC20 {{ @@ -214,17 +222,13 @@ fn store_load_cairo0_contract() { assert(eth_dispatcher.name() == 'Ether', 'invalid name'); - let name = load(eth_dispatcher.contract_address, selector!("ERC20_name"), 1); + start_mock_call(eth_dispatcher.contract_address, selector!("name"), 'NotEther'); - assert(name == array!['Ether'], 'invalid load value'); + assert(eth_dispatcher.name() == 'NotEther', 'invalid mocked name'); - store(eth_dispatcher.contract_address, selector!("ERC20_name"), array!['NotEther'].span()); + stop_mock_call(eth_dispatcher.contract_address, selector!("name")); - assert(eth_dispatcher.name() == 'NotEther', 'invalid store name'); - - let name = load(eth_dispatcher.contract_address, selector!("ERC20_name"), 1); - - assert(name == array!['NotEther'], 'invalid load2 name'); + assert(eth_dispatcher.name() == 'Ether', 'invalid name after mock'); }} "#, node_rpc_url(), diff --git a/crates/forge/tests/integration/setup_fork.rs b/crates/forge/tests/integration/setup_fork.rs index cad6272be1..0dbbc41c28 100644 --- a/crates/forge/tests/integration/setup_fork.rs +++ b/crates/forge/tests/integration/setup_fork.rs @@ -27,6 +27,7 @@ use test_utils::runner::{assert_case_output_contains, assert_failed, assert_pass use test_utils::running_tests::run_test_case; use test_utils::test_case; +#[cfg(not(target_os = "windows"))] #[test] fn fork_simple_decorator() { let test = test_case!(formatdoc!( @@ -70,6 +71,7 @@ fn fork_simple_decorator() { assert_passed(&result); } +#[cfg(not(target_os = "windows"))] #[test] fn fork_aliased_decorator() { let test = test_case!(indoc!( @@ -178,6 +180,7 @@ fn fork_aliased_decorator() { assert_passed(&result); } +#[cfg(not(target_os = "windows"))] #[test] fn fork_aliased_decorator_overrding() { let test = test_case!(indoc!( @@ -268,6 +271,7 @@ fn fork_aliased_decorator_overrding() { assert_passed(&result); } +#[cfg(not(target_os = "windows"))] #[test] fn fork_cairo0_contract() { let test = test_case!(formatdoc!( @@ -298,6 +302,7 @@ fn fork_cairo0_contract() { assert_passed(&result); } +#[cfg(not(target_os = "windows"))] #[test] fn get_block_info_in_forked_block() { let test = test_case!(formatdoc!( @@ -398,6 +403,7 @@ fn get_block_info_in_forked_block() { assert_passed(&result); } +#[cfg(not(target_os = "windows"))] #[test] fn fork_get_block_info_fails() { let test = test_case!(formatdoc!( diff --git a/crates/forge/tests/integration/spy_events.rs b/crates/forge/tests/integration/spy_events.rs index 7cc3469d85..bfff44ec45 100644 --- a/crates/forge/tests/integration/spy_events.rs +++ b/crates/forge/tests/integration/spy_events.rs @@ -632,6 +632,7 @@ fn assert_not_emitted_fails() { assert_case_output_contains(&result, "assert_not_emitted_fails", "keys was emitted"); } +#[cfg(not(target_os = "windows"))] #[test] fn capture_cairo0_event() { let test = test_case!( From a7e4b4b6331456a9456df5cb0553cfe9b56b8962 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Fri, 29 Nov 2024 16:03:29 +0100 Subject: [PATCH 05/68] Ignore fork related integration tests on windows --- crates/forge/tests/integration/store_load.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/forge/tests/integration/store_load.rs b/crates/forge/tests/integration/store_load.rs index 3c3d289257..6af0be20ee 100644 --- a/crates/forge/tests/integration/store_load.rs +++ b/crates/forge/tests/integration/store_load.rs @@ -556,6 +556,7 @@ fn store_load_felt_to_felt() { assert_passed(&result); } +#[cfg(not(target_os = "windows"))] #[test] fn fork_store_load() { let test = test_utils::test_case!(formatdoc!( From 864818a8bc0c4555215016388138e30441d609f0 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Fri, 29 Nov 2024 16:08:32 +0100 Subject: [PATCH 06/68] Do not run coverage and profiler tests on windows --- .github/workflows/ci.yml | 13 +++++-------- crates/forge/tests/e2e/build_profile.rs | 2 ++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a314de7c4..66e16eda77 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,14 +75,6 @@ jobs: - name: Get branch name run: echo 'The branch name is' $BRANCH_NAME - - name: Install cairo-profiler - run: | - curl -L https://raw.githubusercontent.com/software-mansion/cairo-profiler/main/scripts/install.sh | sh - - - name: Install cairo-coverage - run: | - curl -L https://raw.githubusercontent.com/software-mansion/cairo-coverage/main/scripts/install.sh | sh - - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab @@ -111,8 +103,13 @@ jobs: run: | curl -L https://raw.githubusercontent.com/software-mansion/cairo-coverage/main/scripts/install.sh | sh + - name: Install cairo-profiler + run: | + curl -L https://raw.githubusercontent.com/software-mansion/cairo-profiler/main/scripts/install.sh | sh + - run: cargo test --package forge --features scarb_2_8_3 --test main e2e::coverage - run: cargo test --package forge --features scarb_2_8_3 --test main e2e::backtrace + - run: cargo test --package forge --features scarb_2_8_3 --test main e2e::build_profile test-coverage-error: name: Test coverage error diff --git a/crates/forge/tests/e2e/build_profile.rs b/crates/forge/tests/e2e/build_profile.rs index 975c8e452e..19a7e8b0ff 100644 --- a/crates/forge/tests/e2e/build_profile.rs +++ b/crates/forge/tests/e2e/build_profile.rs @@ -2,6 +2,7 @@ use super::common::runner::{setup_package, test_runner}; use forge_runner::profiler_api::PROFILE_DIR; #[test] +#[cfg_attr(not(feature = "scarb_2_8_3"), ignore)] fn simple_package_build_profile() { let temp = setup_package("simple_package"); @@ -29,6 +30,7 @@ fn simple_package_build_profile() { } #[test] +#[cfg_attr(not(feature = "scarb_2_8_3"), ignore)] fn simple_package_build_profile_and_pass_args() { let temp = setup_package("simple_package"); From 6c7cb4516986d80fc6067a6a7d3b706338352e61 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Fri, 29 Nov 2024 16:19:26 +0100 Subject: [PATCH 07/68] Add install_devnet.ps1 --- scripts/install_devnet.ps1 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 scripts/install_devnet.ps1 diff --git a/scripts/install_devnet.ps1 b/scripts/install_devnet.ps1 new file mode 100644 index 0000000000..1f8d1c5620 --- /dev/null +++ b/scripts/install_devnet.ps1 @@ -0,0 +1,21 @@ +# Set strict mode +Set-StrictMode -Version Latest + +# Stop the script on error +$ErrorActionPreference = "Stop" + +# Get the path of the top-level Git directory +$DEVNET_INSTALL_DIR = Join-Path (git rev-parse --show-toplevel) "crates\sncast\tests\utils\devnet" + +# Set the DEVNET repository and revision +$DEVNET_REPO = "https://github.com/0xSpaceShard/starknet-devnet-rs.git" +$DEVNET_TAG = "0.2.2" + +# Perform cargo install +cargo install --locked --git $DEVNET_REPO --tag $DEVNET_TAG --root $DEVNET_INSTALL_DIR --force + +# Output completion message +Write-Host "All done!" + +# Exit with success +exit 0 \ No newline at end of file From 72fd826765ab8d70b21f99352b19cb2dd5657a93 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Fri, 29 Nov 2024 16:21:06 +0100 Subject: [PATCH 08/68] Run install_devnet.ps1 on windows --- .github/workflows/ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 66e16eda77..c7852baa8d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -203,7 +203,12 @@ jobs: toolchain: stable - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab - name: Install starknet-devnet-rs - run: ./scripts/install_devnet.sh + run: | + if [[ "${{ runner.os }}" == "Windows" ]]; then + powershell .\scripts\install_devnet.ps1 + else + ./scripts/install_devnet.sh + fi - uses: software-mansion/setup-scarb@v1 with: scarb-version: "2.7.0" From f4e15ead958d9acdffdc9c0e2920e7a10c4a2648 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Fri, 29 Nov 2024 16:22:51 +0100 Subject: [PATCH 09/68] Fix nextest platform specific uploads --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c7852baa8d..1f585949ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,7 @@ jobs: - name: Install nextest uses: taiki-e/install-action@nextest - name: Build and archive tests - run: cargo nextest archive --release -p forge --archive-file nextest-archive.tar.zst + run: cargo nextest archive --release -p forge --archive-file 'nextest-archive-${{ matrix.os }}.tar.zst' - name: Upload archive to workflow uses: actions/upload-artifact@v4 with: From 527325b936337839817f35c74b10ee2f0cfcbdcb Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Fri, 29 Nov 2024 16:26:32 +0100 Subject: [PATCH 10/68] Always run step in bash --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f585949ca..f2f0a2649a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -209,6 +209,7 @@ jobs: else ./scripts/install_devnet.sh fi + shell: bash - uses: software-mansion/setup-scarb@v1 with: scarb-version: "2.7.0" From cccb52b2bea75562a5fccc373d8fef648ac42915 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Fri, 29 Nov 2024 16:42:57 +0100 Subject: [PATCH 11/68] Change path on windows --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f2f0a2649a..9b029c80a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -205,7 +205,7 @@ jobs: - name: Install starknet-devnet-rs run: | if [[ "${{ runner.os }}" == "Windows" ]]; then - powershell .\scripts\install_devnet.ps1 + powershell ./scripts/install_devnet.ps1 else ./scripts/install_devnet.sh fi From 49b9ab4d3a84dfea114e293074158885f55c9731 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Fri, 29 Nov 2024 16:44:22 +0100 Subject: [PATCH 12/68] Fix path to platform --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b029c80a4..fc3f643100 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,7 +85,7 @@ jobs: with: name: nextest-archive-${{ matrix.os }} - name: nextest partition ${{ matrix.partition }}/8 - run: cargo nextest run --partition 'count:${{ matrix.partition }}/8' --archive-file 'nextest-archive-${{ matrix.platform.os }}.tar.zst' e2e + run: cargo nextest run --partition 'count:${{ matrix.partition }}/8' --archive-file 'nextest-archive-${{ matrix.os }}.tar.zst' e2e test-scarb-2-8-3: name: Test scarb 2.8.3 From 75dfa7db4f610c8ee7617320e8a5b07b95d976da Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Fri, 29 Nov 2024 16:47:51 +0100 Subject: [PATCH 13/68] Fix tag name in install_devnet.ps1 --- scripts/install_devnet.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install_devnet.ps1 b/scripts/install_devnet.ps1 index 1f8d1c5620..260c8406f8 100644 --- a/scripts/install_devnet.ps1 +++ b/scripts/install_devnet.ps1 @@ -9,7 +9,7 @@ $DEVNET_INSTALL_DIR = Join-Path (git rev-parse --show-toplevel) "crates\sncast\t # Set the DEVNET repository and revision $DEVNET_REPO = "https://github.com/0xSpaceShard/starknet-devnet-rs.git" -$DEVNET_TAG = "0.2.2" +$DEVNET_TAG = "v0.2.2" # Perform cargo install cargo install --locked --git $DEVNET_REPO --tag $DEVNET_TAG --root $DEVNET_INSTALL_DIR --force From 3a849d8947718b96f4e12f4b10e3f2f3df9881bc Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Fri, 29 Nov 2024 17:06:50 +0100 Subject: [PATCH 14/68] Du not run forking e2e tests in windows --- crates/forge/tests/e2e/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/forge/tests/e2e/mod.rs b/crates/forge/tests/e2e/mod.rs index 9fbf0d711c..c57881e399 100644 --- a/crates/forge/tests/e2e/mod.rs +++ b/crates/forge/tests/e2e/mod.rs @@ -11,7 +11,9 @@ mod coverage; mod docs_snippets_validation; mod env; mod features; +#[cfg(not(target_os = "windows"))] mod fork_warning; +#[cfg(not(target_os = "windows"))] mod forking; mod fuzzing; mod io_operations; From 462d5464807a4759713737c7cd7342512e0ded40 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Fri, 29 Nov 2024 17:07:42 +0100 Subject: [PATCH 15/68] Add `--no-fail-fast` to forge e2e tests --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc3f643100..3ad6e0e0e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,7 +85,7 @@ jobs: with: name: nextest-archive-${{ matrix.os }} - name: nextest partition ${{ matrix.partition }}/8 - run: cargo nextest run --partition 'count:${{ matrix.partition }}/8' --archive-file 'nextest-archive-${{ matrix.os }}.tar.zst' e2e + run: cargo nextest run --no-fail-fast --partition 'count:${{ matrix.partition }}/8' --archive-file 'nextest-archive-${{ matrix.os }}.tar.zst' e2e test-scarb-2-8-3: name: Test scarb 2.8.3 From 31ec41f02e9f90217cad361cd8643faff098f093 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Fri, 29 Nov 2024 17:27:45 +0100 Subject: [PATCH 16/68] Add different installation steps for windows and Linux/macOS --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ad6e0e0e0..6367c318b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -202,14 +202,14 @@ jobs: with: toolchain: stable - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab - - name: Install starknet-devnet-rs + - name: Install starknet-devnet-rs on Linux/Macos + if: runner.os != 'Windows' run: | - if [[ "${{ runner.os }}" == "Windows" ]]; then - powershell ./scripts/install_devnet.ps1 - else - ./scripts/install_devnet.sh - fi - shell: bash + ./scripts/install_devnet.sh + - name: Install starknet-devnet-rs on Windows + if: runner.os == 'Windows' + run: | + powershell .\scripts\install_devnet.ps1 - uses: software-mansion/setup-scarb@v1 with: scarb-version: "2.7.0" From 198ba829dd30004769a34281494d54392133ddad Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 2 Dec 2024 12:25:38 +0100 Subject: [PATCH 17/68] Always run e2e prep steps using bash --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6367c318b5..db5a7f53bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,24 +56,30 @@ jobs: - name: Extract branch name if: github.event_name != 'pull_request' run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV + shell: bash - name: Extract branch name on pull request if: github.event_name == 'pull_request' run: echo "BRANCH_NAME=$(echo $GITHUB_HEAD_REF)" >> $GITHUB_ENV + shell: bash - name: Extract repo name and owner if: github.event_name != 'pull_request' run: echo "REPO_NAME=$(echo ${{ github.repository }}.git)" >> $GITHUB_ENV + shell: bash - name: Extract repo name and owner on pull request if: github.event_name == 'pull_request' run: echo "REPO_NAME=$(echo ${{ github.event.pull_request.head.repo.full_name }}.git)" >> $GITHUB_ENV + shell: bash - name: Print repo name run: echo 'The repo name is' $REPO_NAME + shell: bash - name: Get branch name run: echo 'The branch name is' $BRANCH_NAME + shell: bash - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable From 0221ce3ab7617e84d58373ae3724c08a3934239c Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 2 Dec 2024 12:26:50 +0100 Subject: [PATCH 18/68] Disable `setup_fork::incompatible_abi` on windows --- crates/forge/tests/integration/setup_fork.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/forge/tests/integration/setup_fork.rs b/crates/forge/tests/integration/setup_fork.rs index 0dbbc41c28..730fbc594a 100644 --- a/crates/forge/tests/integration/setup_fork.rs +++ b/crates/forge/tests/integration/setup_fork.rs @@ -428,6 +428,7 @@ fn fork_get_block_info_fails() { ); } +#[cfg(not(target_os = "windows"))] #[test] // found in: https://github.com/foundry-rs/starknet-foundry/issues/1175 fn incompatible_abi() { From 97b7eb0c6a80b2e7db6aa8cadeeb41ef40371405 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 2 Dec 2024 12:27:53 +0100 Subject: [PATCH 19/68] Disable `cheat_fork::store_load_cairo0_contract` on windows --- crates/forge/tests/integration/cheat_fork.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/forge/tests/integration/cheat_fork.rs b/crates/forge/tests/integration/cheat_fork.rs index 273f3d4a5b..f3fd428433 100644 --- a/crates/forge/tests/integration/cheat_fork.rs +++ b/crates/forge/tests/integration/cheat_fork.rs @@ -153,6 +153,7 @@ fn cheat_block_timestamp_cairo0_contract() { assert_passed(&result); } +#[cfg(not(target_os = "windows"))] #[test] fn store_load_cairo0_contract() { let test = test_case!(formatdoc!( From 1945681508a9bd37f1faca8b97d5612356ba4607 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 2 Dec 2024 12:56:38 +0100 Subject: [PATCH 20/68] System specific devnet path --- crates/sncast/tests/helpers/devnet.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/sncast/tests/helpers/devnet.rs b/crates/sncast/tests/helpers/devnet.rs index 491f0634fb..b65e2ee319 100644 --- a/crates/sncast/tests/helpers/devnet.rs +++ b/crates/sncast/tests/helpers/devnet.rs @@ -34,7 +34,13 @@ fn start_devnet() { } } - Command::new("tests/utils/devnet/starknet-devnet") + let devnet_path = if cfg!(target_os = "windows") { + "tests/utils/devnet/starknet-devnet/bin/starknet-devnet.exe" + } else { + "tests/utils/devnet/starknet-devnet" + }; + + Command::new(devnet_path) .args([ "--port", &port, From 45c531dab5212492e7c7cb663227f000f4f2ca70 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 2 Dec 2024 12:58:53 +0100 Subject: [PATCH 21/68] System specific devnet killing --- crates/sncast/tests/helpers/devnet.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/crates/sncast/tests/helpers/devnet.rs b/crates/sncast/tests/helpers/devnet.rs index b65e2ee319..cd9793d0c4 100644 --- a/crates/sncast/tests/helpers/devnet.rs +++ b/crates/sncast/tests/helpers/devnet.rs @@ -87,11 +87,17 @@ fn start_devnet() { #[dtor] fn stop_devnet() { let port = Url::parse(URL).unwrap().port().unwrap_or(80).to_string(); - Command::new("pkill") - .args([ - "-f", - &format!("starknet-devnet.*{}.*{}", &port, &SEED.to_string())[..], - ]) - .spawn() - .expect("Failed to kill devnet processes"); + let pattern = format!("starknet-devnet.*{}.*{}", port, SEED); + + if cfg!(target_os = "windows") { + Command::new("taskkill") + .args(["/IM", &pattern, "/F"]) + .output() + .expect("Failed to kill devnet processes"); + } else { + Command::new("pkill") + .args(["-f", &pattern]) + .output() + .expect("Failed to kill devnet processes"); + } } From 5c9100ca5af8816946838e32b43581d78cf7b25c Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 2 Dec 2024 13:32:00 +0100 Subject: [PATCH 22/68] Fix windows devnet path --- crates/sncast/tests/helpers/devnet.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/sncast/tests/helpers/devnet.rs b/crates/sncast/tests/helpers/devnet.rs index cd9793d0c4..2547e6844c 100644 --- a/crates/sncast/tests/helpers/devnet.rs +++ b/crates/sncast/tests/helpers/devnet.rs @@ -35,7 +35,7 @@ fn start_devnet() { } let devnet_path = if cfg!(target_os = "windows") { - "tests/utils/devnet/starknet-devnet/bin/starknet-devnet.exe" + "tests/utils/devnet/bin/starknet-devnet.exe" } else { "tests/utils/devnet/starknet-devnet" }; From e3f49d93cd4b630e13c433e2b21d9169587fb286 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 2 Dec 2024 15:48:06 +0100 Subject: [PATCH 23/68] Remove os specific error from `test_invalid_private_key_file_path` --- crates/sncast/tests/e2e/account/import.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/sncast/tests/e2e/account/import.rs b/crates/sncast/tests/e2e/account/import.rs index cfbe7daa2c..4e0f7e6d50 100644 --- a/crates/sncast/tests/e2e/account/import.rs +++ b/crates/sncast/tests/e2e/account/import.rs @@ -455,7 +455,7 @@ pub async fn test_invalid_private_key_file_path() { output, indoc! {r" command: account import - error: Failed to obtain private key from the file my_private_key: No such file or directory (os error 2) + error: Failed to obtain private key from the file my_private_key: [..] "}, ); } From 6c73d275c98a2ecbbdbaee409282ddb0c589c8b1 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 2 Dec 2024 15:49:00 +0100 Subject: [PATCH 24/68] Remove os specific error from `test_directory_non_existent` --- crates/sncast/tests/e2e/multicall/new.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/sncast/tests/e2e/multicall/new.rs b/crates/sncast/tests/e2e/multicall/new.rs index 79a8703ebc..6cdfa18fd7 100644 --- a/crates/sncast/tests/e2e/multicall/new.rs +++ b/crates/sncast/tests/e2e/multicall/new.rs @@ -77,7 +77,7 @@ async fn test_directory_non_existent() { output, indoc! {r" command: multicall new - error: No such file or directory[..] + error: [..] "}, ); } From 0a3384d524db1a202120857789d74227a59a4494 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 2 Dec 2024 15:50:00 +0100 Subject: [PATCH 25/68] Handle `.exe` in sncast name in `test_no_output_path_specified` --- crates/sncast/tests/e2e/multicall/new.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/sncast/tests/e2e/multicall/new.rs b/crates/sncast/tests/e2e/multicall/new.rs index 6cdfa18fd7..97361052f7 100644 --- a/crates/sncast/tests/e2e/multicall/new.rs +++ b/crates/sncast/tests/e2e/multicall/new.rs @@ -47,7 +47,7 @@ async fn test_no_output_path_specified() { error: the following required arguments were not provided: - Usage: sncast multicall new + Usage: sncast[..] multicall new For more information, try '--help'. "}; From ee04138f440bfa71d55e387a8bd2cd2bfa442c79 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 2 Dec 2024 15:50:27 +0100 Subject: [PATCH 26/68] Remove os specific error from `test_invalid_path` --- crates/sncast/tests/e2e/multicall/run.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/sncast/tests/e2e/multicall/run.rs b/crates/sncast/tests/e2e/multicall/run.rs index 9a378486f7..79e15f78ce 100644 --- a/crates/sncast/tests/e2e/multicall/run.rs +++ b/crates/sncast/tests/e2e/multicall/run.rs @@ -122,7 +122,7 @@ async fn test_invalid_path() { output, indoc! {r" command: multicall run - error: No such file or directory [..] + error: [..] "}, ); } From 6707dc70cc5b1106d709ae297c986b1d68c83303 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 2 Dec 2024 15:50:57 +0100 Subject: [PATCH 27/68] Remove os specific path from `test_initialized_script_compiles` --- crates/sncast/tests/e2e/script/init.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/sncast/tests/e2e/script/init.rs b/crates/sncast/tests/e2e/script/init.rs index 704f11d9b5..9e09090049 100644 --- a/crates/sncast/tests/e2e/script/init.rs +++ b/crates/sncast/tests/e2e/script/init.rs @@ -133,7 +133,7 @@ fn test_initialized_script_compiles() { formatdoc! {r" [WARNING] The newly created script isn't auto-added to the workspace. [..] command: script init - message: Successfully initialized `{script_name}` at [..]/scripts/{script_name} + message: Successfully initialized `{script_name}` at [..]{script_name} "}, ); From ea8c9afcf1cb347792c7963fc412eb3b7d857446 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 2 Dec 2024 15:56:29 +0100 Subject: [PATCH 28/68] Use different scripts depending on the os --- crates/sncast/tests/e2e/call.rs | 5 ++++- crates/sncast/tests/e2e/deploy.rs | 3 ++- crates/sncast/tests/e2e/invoke.rs | 3 ++- crates/sncast/tests/shell/call.ps1 | 17 +++++++++++++++++ crates/sncast/tests/shell/deploy.ps1 | 14 ++++++++++++++ crates/sncast/tests/shell/invoke.ps1 | 21 +++++++++++++++++++++ 6 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 crates/sncast/tests/shell/call.ps1 create mode 100644 crates/sncast/tests/shell/deploy.ps1 create mode 100644 crates/sncast/tests/shell/invoke.ps1 diff --git a/crates/sncast/tests/e2e/call.rs b/crates/sncast/tests/e2e/call.rs index 157102e856..c31762e920 100644 --- a/crates/sncast/tests/e2e/call.rs +++ b/crates/sncast/tests/e2e/call.rs @@ -231,7 +231,10 @@ fn test_wrong_block_id() { #[test] fn test_happy_case_shell() { - let test_path = PathBuf::from("tests/shell/call.sh").canonicalize().unwrap(); + let script_extension = if cfg!(windows) { ".ps1" } else { ".sh" }; + let test_path = PathBuf::from(format!("tests/shell/call{script_extension}")) + .canonicalize() + .unwrap(); let binary_path = cargo_bin!("sncast"); let snapbox = Command::new(test_path) diff --git a/crates/sncast/tests/e2e/deploy.rs b/crates/sncast/tests/e2e/deploy.rs index feb57b8f0a..2b921d060c 100644 --- a/crates/sncast/tests/e2e/deploy.rs +++ b/crates/sncast/tests/e2e/deploy.rs @@ -440,7 +440,8 @@ fn test_too_low_max_fee() { async fn test_happy_case_shell() { let tempdir = create_and_deploy_oz_account().await; - let test_path = PathBuf::from("tests/shell/deploy.sh") + let script_extension = if cfg!(windows) { ".ps1" } else { ".sh" }; + let test_path = PathBuf::from(format!("tests/shell/deploy{script_extension}")) .canonicalize() .unwrap(); let binary_path = cargo_bin!("sncast"); diff --git a/crates/sncast/tests/e2e/invoke.rs b/crates/sncast/tests/e2e/invoke.rs index 4d7fa721f2..21d9e13f83 100644 --- a/crates/sncast/tests/e2e/invoke.rs +++ b/crates/sncast/tests/e2e/invoke.rs @@ -429,7 +429,8 @@ async fn test_happy_case_cairo_expression_calldata() { async fn test_happy_case_shell() { let tempdir = create_and_deploy_oz_account().await; - let test_path = PathBuf::from("tests/shell/invoke.sh") + let script_extension = if cfg!(windows) { ".ps1" } else { ".sh" }; + let test_path = PathBuf::from(format!("tests/shell/invoke{script_extension}")) .canonicalize() .unwrap(); let binary_path = cargo_bin!("sncast"); diff --git a/crates/sncast/tests/shell/call.ps1 b/crates/sncast/tests/shell/call.ps1 new file mode 100644 index 0000000000..9df9777dd1 --- /dev/null +++ b/crates/sncast/tests/shell/call.ps1 @@ -0,0 +1,17 @@ +$CAST_BINARY = $args[0] +$URL = $args[1] +$DATA_TRANSFORMER_CONTRACT_ADDRESS_SEPOLIA = $args[2] +& $CAST_BINARY ` + --int-format ` + --json ` + call ` + --url $URL ` + --contract-address $DATA_TRANSFORMER_CONTRACT_ADDRESS_SEPOLIA ` + --function complex_fn ` + --arguments 'array![array![1, 2], array![3, 4, 5], array![6]],' ` + '12,' ` + '-128_i8,' ` + '"Some string (a ByteArray)",' ` + "('a shortstring', 32_u32)," ` + 'true,' ` + '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' diff --git a/crates/sncast/tests/shell/deploy.ps1 b/crates/sncast/tests/shell/deploy.ps1 new file mode 100644 index 0000000000..40f369bad8 --- /dev/null +++ b/crates/sncast/tests/shell/deploy.ps1 @@ -0,0 +1,14 @@ +$CAST_BINARY = $args[0] +$URL = $args[1] +$CONSTRUCTOR_WITH_PARAMS_CONTRACT_CLASS_HASH_SEPOLIA = $args[2] +& $CAST_BINARY ` + --accounts-file accounts.json ` + --account my_account ` + --int-format ` + --json ` + deploy ` + --url $URL ` + --class-hash $CONSTRUCTOR_WITH_PARAMS_CONTRACT_CLASS_HASH_SEPOLIA ` + --arguments '0x420, 0x2137_u256' ` + --max-fee 99999999999999999 ` + --fee-token eth diff --git a/crates/sncast/tests/shell/invoke.ps1 b/crates/sncast/tests/shell/invoke.ps1 new file mode 100644 index 0000000000..08a98fc5b3 --- /dev/null +++ b/crates/sncast/tests/shell/invoke.ps1 @@ -0,0 +1,21 @@ +$CAST_BINARY = $args[0] +$URL = $args[1] +$DATA_TRANSFORMER_CONTRACT_ADDRESS_SEPOLIA = $args[2] +& $CAST_BINARY ` + --accounts-file accounts.json ` + --account my_account ` + --int-format ` + --json ` + invoke ` + --url $URL ` + --contract-address $DATA_TRANSFORMER_CONTRACT_ADDRESS_SEPOLIA ` + --function complex_fn ` + --arguments 'array![array![1, 2], array![3, 4, 5], array![6]],' ` + '12,' ` + '-128_i8,' ` + '"Some string (a ByteArray)",' ` + "('a shortstring', 32_u32)," ` + 'true,' ` + '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' ` + --max-fee 99999999999999999 ` + --fee-token eth From 988d6d791e77d8d1a371bdd25c1cdd817b46e84b Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 2 Dec 2024 17:20:59 +0100 Subject: [PATCH 29/68] Use powershell on windows --- crates/sncast/tests/e2e/call.rs | 8 +++++++- crates/sncast/tests/e2e/deploy.rs | 11 +++++++++-- crates/sncast/tests/e2e/invoke.rs | 8 +++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/crates/sncast/tests/e2e/call.rs b/crates/sncast/tests/e2e/call.rs index c31762e920..61551ecd24 100644 --- a/crates/sncast/tests/e2e/call.rs +++ b/crates/sncast/tests/e2e/call.rs @@ -237,7 +237,13 @@ fn test_happy_case_shell() { .unwrap(); let binary_path = cargo_bin!("sncast"); - let snapbox = Command::new(test_path) + let command = if cfg!(windows) { + Command::new("powershell").arg(test_path) + } else { + Command::new(test_path) + }; + + let snapbox = command .arg(binary_path) .arg(URL) .arg(DATA_TRANSFORMER_CONTRACT_ADDRESS_SEPOLIA); diff --git a/crates/sncast/tests/e2e/deploy.rs b/crates/sncast/tests/e2e/deploy.rs index 2b921d060c..ba3a4bb90e 100644 --- a/crates/sncast/tests/e2e/deploy.rs +++ b/crates/sncast/tests/e2e/deploy.rs @@ -1,6 +1,7 @@ use crate::helpers::constants::{ ACCOUNT, ACCOUNT_FILE_PATH, CONSTRUCTOR_WITH_PARAMS_CONTRACT_CLASS_HASH_SEPOLIA, - DEVNET_OZ_CLASS_HASH_CAIRO_0, MAP_CONTRACT_CLASS_HASH_SEPOLIA, URL, + DATA_TRANSFORMER_CONTRACT_ADDRESS_SEPOLIA, DEVNET_OZ_CLASS_HASH_CAIRO_0, + MAP_CONTRACT_CLASS_HASH_SEPOLIA, URL, }; use crate::helpers::fixtures::{ create_and_deploy_account, create_and_deploy_oz_account, get_transaction_hash, @@ -446,7 +447,13 @@ async fn test_happy_case_shell() { .unwrap(); let binary_path = cargo_bin!("sncast"); - let snapbox = Command::new(test_path) + let command = if cfg!(windows) { + Command::new("powershell").arg(test_path) + } else { + Command::new(test_path) + }; + + let snapbox = command .current_dir(tempdir.path()) .arg(binary_path) .arg(URL) diff --git a/crates/sncast/tests/e2e/invoke.rs b/crates/sncast/tests/e2e/invoke.rs index 21d9e13f83..54d534755a 100644 --- a/crates/sncast/tests/e2e/invoke.rs +++ b/crates/sncast/tests/e2e/invoke.rs @@ -435,7 +435,13 @@ async fn test_happy_case_shell() { .unwrap(); let binary_path = cargo_bin!("sncast"); - let snapbox = Command::new(test_path) + let command = if cfg!(windows) { + Command::new("powershell").arg(test_path) + } else { + Command::new(test_path) + }; + + let snapbox = command .current_dir(tempdir.path()) .arg(binary_path) .arg(URL) From fad159aa6e936e044ac4a3332a504431e8d90713 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 2 Dec 2024 17:23:22 +0100 Subject: [PATCH 30/68] Fix powershell syntax --- crates/sncast/tests/shell/call.ps1 | 16 +++++++++------- crates/sncast/tests/shell/invoke.ps1 | 16 +++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/crates/sncast/tests/shell/call.ps1 b/crates/sncast/tests/shell/call.ps1 index 9df9777dd1..12bcf8fbc3 100644 --- a/crates/sncast/tests/shell/call.ps1 +++ b/crates/sncast/tests/shell/call.ps1 @@ -8,10 +8,12 @@ $DATA_TRANSFORMER_CONTRACT_ADDRESS_SEPOLIA = $args[2] --url $URL ` --contract-address $DATA_TRANSFORMER_CONTRACT_ADDRESS_SEPOLIA ` --function complex_fn ` - --arguments 'array![array![1, 2], array![3, 4, 5], array![6]],' ` - '12,' ` - '-128_i8,' ` - '"Some string (a ByteArray)",' ` - "('a shortstring', 32_u32)," ` - 'true,' ` - '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' + --arguments @' +array![array![1, 2], array![3, 4, 5], array![6]], +12, +-128_i8, +\"Some string (a ByteArray)\", +('a shortstring', 32_u32), +true, +0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +'@ diff --git a/crates/sncast/tests/shell/invoke.ps1 b/crates/sncast/tests/shell/invoke.ps1 index 08a98fc5b3..acec51e0e6 100644 --- a/crates/sncast/tests/shell/invoke.ps1 +++ b/crates/sncast/tests/shell/invoke.ps1 @@ -10,12 +10,14 @@ $DATA_TRANSFORMER_CONTRACT_ADDRESS_SEPOLIA = $args[2] --url $URL ` --contract-address $DATA_TRANSFORMER_CONTRACT_ADDRESS_SEPOLIA ` --function complex_fn ` - --arguments 'array![array![1, 2], array![3, 4, 5], array![6]],' ` - '12,' ` - '-128_i8,' ` - '"Some string (a ByteArray)",' ` - "('a shortstring', 32_u32)," ` - 'true,' ` - '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' ` + --arguments @' +array![array![1, 2], array![3, 4, 5], array![6]], +12, +-128_i8, +\"Some string (a ByteArray)\", +('a shortstring', 32_u32), +true, +0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +'@ --max-fee 99999999999999999 ` --fee-token eth From 0b7af368eda50337023f10534ee5d3d8cf9e9bb4 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 2 Dec 2024 17:24:35 +0100 Subject: [PATCH 31/68] Remove unused constant --- crates/sncast/tests/e2e/deploy.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/sncast/tests/e2e/deploy.rs b/crates/sncast/tests/e2e/deploy.rs index ba3a4bb90e..547fce5dd3 100644 --- a/crates/sncast/tests/e2e/deploy.rs +++ b/crates/sncast/tests/e2e/deploy.rs @@ -1,7 +1,6 @@ use crate::helpers::constants::{ ACCOUNT, ACCOUNT_FILE_PATH, CONSTRUCTOR_WITH_PARAMS_CONTRACT_CLASS_HASH_SEPOLIA, - DATA_TRANSFORMER_CONTRACT_ADDRESS_SEPOLIA, DEVNET_OZ_CLASS_HASH_CAIRO_0, - MAP_CONTRACT_CLASS_HASH_SEPOLIA, URL, + DEVNET_OZ_CLASS_HASH_CAIRO_0, MAP_CONTRACT_CLASS_HASH_SEPOLIA, URL, }; use crate::helpers::fixtures::{ create_and_deploy_account, create_and_deploy_oz_account, get_transaction_hash, From a2c3d0a4f8e7c6ec37b77bd3e6109007de8688dc Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 2 Dec 2024 17:28:01 +0100 Subject: [PATCH 32/68] Use strings in `format!` directly --- crates/sncast/tests/helpers/devnet.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/sncast/tests/helpers/devnet.rs b/crates/sncast/tests/helpers/devnet.rs index 2547e6844c..63ebc92281 100644 --- a/crates/sncast/tests/helpers/devnet.rs +++ b/crates/sncast/tests/helpers/devnet.rs @@ -87,7 +87,7 @@ fn start_devnet() { #[dtor] fn stop_devnet() { let port = Url::parse(URL).unwrap().port().unwrap_or(80).to_string(); - let pattern = format!("starknet-devnet.*{}.*{}", port, SEED); + let pattern = format!("starknet-devnet.*{port}.*{SEED}"); if cfg!(target_os = "windows") { Command::new("taskkill") From 9dbfada1888c0e1e88702f61332ccd951c82a765 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 2 Dec 2024 17:52:09 +0100 Subject: [PATCH 33/68] Sanitise file name for traces --- Cargo.lock | 12 +++++++++++- Cargo.toml | 1 + crates/forge-runner/Cargo.toml | 1 + crates/forge-runner/src/build_trace_data.rs | 2 +- crates/forge-runner/src/lib.rs | 5 +++-- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 63cec86a7f..9545bf9e79 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -2247,6 +2247,7 @@ dependencies = [ "rand", "rayon", "runtime", + "sanitize-filename", "scarb-api", "semver", "serde", @@ -4449,6 +4450,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "sanitize-filename" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc984f4f9ceb736a7bb755c3e3bd17dc56370af2600c9780dcc48c66453da34d" +dependencies = [ + "regex", +] + [[package]] name = "scarb-api" version = "1.0.0" diff --git a/Cargo.toml b/Cargo.toml index 694ea4aaae..e6d0fc4c67 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -124,3 +124,4 @@ serde_path_to_error = "0.1.16" wiremock = "0.6.0" const-hex = "1.13.1" indicatif = "0.17.8" +sanitize-filename = "0.6.0" diff --git a/crates/forge-runner/Cargo.toml b/crates/forge-runner/Cargo.toml index a9e35b7012..9aca86e5be 100644 --- a/crates/forge-runner/Cargo.toml +++ b/crates/forge-runner/Cargo.toml @@ -55,3 +55,4 @@ shared = { path = "../shared" } universal-sierra-compiler-api = { path = "../universal-sierra-compiler-api" } fs4.workspace = true which.workspace = true +sanitize-filename.workspace = true diff --git a/crates/forge-runner/src/build_trace_data.rs b/crates/forge-runner/src/build_trace_data.rs index 845775c234..4c8382ebdf 100644 --- a/crates/forge-runner/src/build_trace_data.rs +++ b/crates/forge-runner/src/build_trace_data.rs @@ -307,7 +307,7 @@ fn build_profiler_trace_entry(value: &RelocatedTraceEntry) -> ProfilerTraceEntry } pub fn save_trace_data( - test_name: &String, + test_name: &str, trace_data: &VersionedProfilerCallTrace, ) -> Result { let serialized_trace = diff --git a/crates/forge-runner/src/lib.rs b/crates/forge-runner/src/lib.rs index 8608f685e6..6f879b36b6 100644 --- a/crates/forge-runner/src/lib.rs +++ b/crates/forge-runner/src/lib.rs @@ -68,9 +68,10 @@ pub fn maybe_save_trace_and_profile( }) = result { if execution_data_to_save.is_vm_trace_needed() { - let trace_path = save_trace_data(name, trace_data)?; + let name = sanitize_filename::sanitize(name); + let trace_path = save_trace_data(&name, trace_data)?; if execution_data_to_save.profile { - run_profiler(name, &trace_path, &execution_data_to_save.additional_args)?; + run_profiler(&name, &trace_path, &execution_data_to_save.additional_args)?; } return Ok(Some(trace_path)); } From 85dbaaefd69efe75263ba7028dfd83aaacd101b5 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 2 Dec 2024 17:57:11 +0100 Subject: [PATCH 34/68] Replace `::` in file names --- crates/forge-runner/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/forge-runner/src/lib.rs b/crates/forge-runner/src/lib.rs index 6f879b36b6..d3aebf4887 100644 --- a/crates/forge-runner/src/lib.rs +++ b/crates/forge-runner/src/lib.rs @@ -68,7 +68,7 @@ pub fn maybe_save_trace_and_profile( }) = result { if execution_data_to_save.is_vm_trace_needed() { - let name = sanitize_filename::sanitize(name); + let name = sanitize_filename::sanitize(name.replace("::", "_")); let trace_path = save_trace_data(&name, trace_data)?; if execution_data_to_save.profile { run_profiler(&name, &trace_path, &execution_data_to_save.additional_args)?; From c5c994c6f724e53064006d908be2e6048e598355 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 2 Dec 2024 18:01:33 +0100 Subject: [PATCH 35/68] Disable fail-fast for matrix tests --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db5a7f53bc..a20c915b45 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,7 @@ jobs: build-test-forge-e2e-nextest-archive: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: [ ubuntu-latest, windows-latest ] steps: @@ -49,6 +50,7 @@ jobs: runs-on: ${{ matrix.os }} needs: build-test-forge-e2e-nextest-archive strategy: + fail-fast: false matrix: partition: [ 1, 2, 3, 4, 5, 6, 7, 8 ] os: [ ubuntu-latest, windows-latest ] From 4b2302f1fb162a1b561e7e64da762362a4feb6ee Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Tue, 3 Dec 2024 13:31:22 +0100 Subject: [PATCH 36/68] Change trace related paths --- crates/forge/tests/e2e/build_trace_data.rs | 16 ++++++++-------- crates/forge/tests/e2e/trace_resources.rs | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/forge/tests/e2e/build_trace_data.rs b/crates/forge/tests/e2e/build_trace_data.rs index 2f9f6502f6..438adc0f89 100644 --- a/crates/forge/tests/e2e/build_trace_data.rs +++ b/crates/forge/tests/e2e/build_trace_data.rs @@ -16,24 +16,24 @@ fn simple_package_save_trace() { assert!(temp .join(TRACE_DIR) - .join("simple_package::tests::test_fib.json") + .join("simple_package_tests_test_fib.json") .exists()); assert!(!temp .join(TRACE_DIR) - .join("simple_package_integrationtest::test_simple::test_failing.json") + .join("simple_package_integrationtest_test_simple_test_failing.json") .exists()); assert!(!temp .join(TRACE_DIR) - .join("simple_package::tests::ignored_test.json") + .join("simple_package_tests_ignored_test.json") .exists()); assert!(temp .join(TRACE_DIR) - .join("simple_package_integrationtest::ext_function_test::test_simple.json") + .join("simple_package_integrationtest_ext_function_test_test_simple.json") .exists()); let trace_data = fs::read_to_string( temp.join(TRACE_DIR) - .join("simple_package_integrationtest::ext_function_test::test_simple.json"), + .join("simple_package_integrationtest_ext_function_test_test_simple.json"), ) .unwrap(); @@ -56,7 +56,7 @@ fn trace_has_contract_and_function_names() { let trace_data = fs::read_to_string( temp.join(TRACE_DIR) - .join("trace_info_integrationtest::test_trace::test_trace.json"), + .join("trace_info_integrationtest_test_trace_test_trace.json"), ) .unwrap(); @@ -103,7 +103,7 @@ fn trace_has_cairo_execution_info() { let trace_data = fs::read_to_string( temp.join(TRACE_DIR) - .join("trace_info_integrationtest::test_trace::test_trace.json"), + .join("trace_info_integrationtest_test_trace_test_trace.json"), ) .unwrap(); @@ -145,7 +145,7 @@ fn trace_has_deploy_with_no_constructor_phantom_nodes() { let trace_data = fs::read_to_string( temp.join(TRACE_DIR) - .join("trace_info_integrationtest::test_trace::test_trace.json"), + .join("trace_info_integrationtest_test_trace_test_trace.json"), ) .unwrap(); diff --git a/crates/forge/tests/e2e/trace_resources.rs b/crates/forge/tests/e2e/trace_resources.rs index 7ceb37373f..8d2b69651a 100644 --- a/crates/forge/tests/e2e/trace_resources.rs +++ b/crates/forge/tests/e2e/trace_resources.rs @@ -65,7 +65,7 @@ fn assert_resources_for_test( fn deserialize_call_trace(test_name: &str, temp_dir: &TempDir) -> VersionedProfilerCallTrace { let trace_data = fs::read_to_string(temp_dir.join(TRACE_DIR).join(format!( - "trace_resources_tests::{test_name}::{test_name}.json" + "trace_resources_tests_{test_name}_{test_name}.json" ))) .unwrap(); serde_json::from_str(&trace_data).expect("Failed to parse call trace") From 8138b9948b7fb7c969ebb80f8ab1ed7795674deb Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Tue, 3 Dec 2024 13:31:38 +0100 Subject: [PATCH 37/68] Remove os specific errors --- crates/forge/tests/e2e/io_operations.rs | 2 +- crates/forge/tests/e2e/running.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/forge/tests/e2e/io_operations.rs b/crates/forge/tests/e2e/io_operations.rs index af7394c16e..5637e6158a 100644 --- a/crates/forge/tests/e2e/io_operations.rs +++ b/crates/forge/tests/e2e/io_operations.rs @@ -21,7 +21,7 @@ fn file_reading() { [FAIL] file_reading_integrationtest::test::json_non_existent Failure data: - "No such file or directory [..]" + [..] [FAIL] file_reading_integrationtest::test::invalid_json diff --git a/crates/forge/tests/e2e/running.rs b/crates/forge/tests/e2e/running.rs index fd85ca524e..4424000e18 100644 --- a/crates/forge/tests/e2e/running.rs +++ b/crates/forge/tests/e2e/running.rs @@ -1045,7 +1045,7 @@ fn catch_runtime_errors() { use snforge_std::fs::{FileTrait, read_txt}; #[test] - #[should_panic(expected: "No such file or directory (os error 2)")] + #[should_panic(expected: "file")] fn catch_no_such_file() { let file = FileTrait::new("no_way_this_file_exists"); let content = read_txt(@file); From 115b2a73105d57688028c69c68a6331e456d0400 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Tue, 3 Dec 2024 13:58:54 +0100 Subject: [PATCH 38/68] Replace `::` --- crates/forge/tests/e2e/build_profile.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/forge/tests/e2e/build_profile.rs b/crates/forge/tests/e2e/build_profile.rs index 19a7e8b0ff..f668baf319 100644 --- a/crates/forge/tests/e2e/build_profile.rs +++ b/crates/forge/tests/e2e/build_profile.rs @@ -10,19 +10,19 @@ fn simple_package_build_profile() { assert!(temp .join(PROFILE_DIR) - .join("simple_package::tests::test_fib.pb.gz") + .join("simple_package_tests_test_fib.pb.gz") .is_file()); assert!(!temp .join(PROFILE_DIR) - .join("simple_package_integrationtest::test_simple::test_failing.pb.gz") + .join("simple_package_integrationtest_test_simple_test_failing.pb.gz") .is_file()); assert!(!temp .join(PROFILE_DIR) - .join("simple_package::tests::ignored_test.pb.gz") + .join("simple_package_tests_ignored_test.pb.gz") .is_file()); assert!(temp .join(PROFILE_DIR) - .join("simple_package_integrationtest::ext_function_test::test_simple.pb.gz") + .join("simple_package_integrationtest_ext_function_test_test_simple.pb.gz") .is_file()); // Check if it doesn't crash in case some data already exists From 3924657e1f7b35cf037ed06192660520d1209b04 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Tue, 3 Dec 2024 14:07:26 +0100 Subject: [PATCH 39/68] Force `lf` line endings on windows --- crates/sncast/src/state/state_file.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/sncast/src/state/state_file.rs b/crates/sncast/src/state/state_file.rs index ef5148e26b..70b51a6dec 100644 --- a/crates/sncast/src/state/state_file.rs +++ b/crates/sncast/src/state/state_file.rs @@ -396,7 +396,7 @@ mod tests { } #[test] - #[should_panic] + #[should_panic(expected = "Failed to load state file")] // TODO handle system specific panics fn test_load_state_file_invalid_path() { let state_file = Utf8PathBuf::from("bla/bla/crypto.json"); From f3cde9984ec913d0514e15ddfe73706af6355e33 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Tue, 3 Dec 2024 15:21:19 +0100 Subject: [PATCH 40/68] Bypass powershell execution policy --- crates/sncast/tests/e2e/call.rs | 6 +++++- crates/sncast/tests/e2e/deploy.rs | 6 +++++- crates/sncast/tests/e2e/invoke.rs | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/crates/sncast/tests/e2e/call.rs b/crates/sncast/tests/e2e/call.rs index 61551ecd24..6dd3e846ec 100644 --- a/crates/sncast/tests/e2e/call.rs +++ b/crates/sncast/tests/e2e/call.rs @@ -238,7 +238,11 @@ fn test_happy_case_shell() { let binary_path = cargo_bin!("sncast"); let command = if cfg!(windows) { - Command::new("powershell").arg(test_path) + Command::new("powershell") + .arg("-ExecutionPolicy") + .arg("Bypass") + .arg("-File") + .arg(test_path) } else { Command::new(test_path) }; diff --git a/crates/sncast/tests/e2e/deploy.rs b/crates/sncast/tests/e2e/deploy.rs index 547fce5dd3..3de61512d4 100644 --- a/crates/sncast/tests/e2e/deploy.rs +++ b/crates/sncast/tests/e2e/deploy.rs @@ -447,7 +447,11 @@ async fn test_happy_case_shell() { let binary_path = cargo_bin!("sncast"); let command = if cfg!(windows) { - Command::new("powershell").arg(test_path) + Command::new("powershell") + .arg("-ExecutionPolicy") + .arg("Bypass") + .arg("-File") + .arg(test_path) } else { Command::new(test_path) }; diff --git a/crates/sncast/tests/e2e/invoke.rs b/crates/sncast/tests/e2e/invoke.rs index 54d534755a..63c85afba3 100644 --- a/crates/sncast/tests/e2e/invoke.rs +++ b/crates/sncast/tests/e2e/invoke.rs @@ -436,7 +436,11 @@ async fn test_happy_case_shell() { let binary_path = cargo_bin!("sncast"); let command = if cfg!(windows) { - Command::new("powershell").arg(test_path) + Command::new("powershell") + .arg("-ExecutionPolicy") + .arg("Bypass") + .arg("-File") + .arg(test_path) } else { Command::new(test_path) }; From 3000fffd7aab52f9228d0e7ef1219886d6ef1a40 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Tue, 3 Dec 2024 15:26:56 +0100 Subject: [PATCH 41/68] Force `lf` line endings on windows --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..a52bd184c2 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.* text eol=lf \ No newline at end of file From e416b0c12c1570b620e01fb46154bb22bd5a8f01 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Tue, 3 Dec 2024 15:34:42 +0100 Subject: [PATCH 42/68] Remove OS specific error --- crates/forge/tests/e2e/io_operations.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/forge/tests/e2e/io_operations.rs b/crates/forge/tests/e2e/io_operations.rs index 5637e6158a..340d24d449 100644 --- a/crates/forge/tests/e2e/io_operations.rs +++ b/crates/forge/tests/e2e/io_operations.rs @@ -31,7 +31,7 @@ fn file_reading() { [FAIL] file_reading_integrationtest::test::non_existent Failure data: - "No such file or directory [..]" + "[..] file [..]" [FAIL] file_reading_integrationtest::test::non_ascii From 7fde1e7687eac6868a47647a229407925bdbe635 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Tue, 3 Dec 2024 15:42:48 +0100 Subject: [PATCH 43/68] Cache devnet on Windows --- .github/workflows/ci.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a20c915b45..2bc78fb38b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,8 @@ name: CI +env: + DEVNET_TAG: "v0.2.2" + on: pull_request: merge_group: @@ -214,10 +217,18 @@ jobs: if: runner.os != 'Windows' run: | ./scripts/install_devnet.sh - - name: Install starknet-devnet-rs on Windows + - name: Cache devnet build if: runner.os == 'Windows' + id: windows-devnet-cache + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}\starknet-foundry\crates\sncast\tests\utils\devnet + key: ${{ runner.os }}-devnet-${{ env.DEVNET_TAG }} + - name: Install devnet + if: runner.os == 'Windows' && steps.windows-devnet-cache.outputs.cache-hit != 'true' run: | - powershell .\scripts\install_devnet.ps1 + $DEVNET_INSTALL_DIR = "${{ github.workspace }}\starknet-foundry\crates\sncast\tests\utils\devnet" + cargo install --git https://github.com/0xSpaceShard/starknet-devnet-rs.git --locked --tag ${{ env.DEVNET_TAG }} --root $DEVNET_INSTALL_DIR - uses: software-mansion/setup-scarb@v1 with: scarb-version: "2.7.0" From e3164ab6341632997d619bc50e03331f0fd08e39 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Tue, 3 Dec 2024 15:45:15 +0100 Subject: [PATCH 44/68] Fix path to devnet --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2bc78fb38b..c9c25b4463 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -222,12 +222,12 @@ jobs: id: windows-devnet-cache uses: actions/cache@v4 with: - path: ${{ github.workspace }}\starknet-foundry\crates\sncast\tests\utils\devnet + path: ${{ github.workspace }}\crates\sncast\tests\utils\devnet key: ${{ runner.os }}-devnet-${{ env.DEVNET_TAG }} - name: Install devnet if: runner.os == 'Windows' && steps.windows-devnet-cache.outputs.cache-hit != 'true' run: | - $DEVNET_INSTALL_DIR = "${{ github.workspace }}\starknet-foundry\crates\sncast\tests\utils\devnet" + $DEVNET_INSTALL_DIR = "${{ github.workspace }}\crates\sncast\tests\utils\devnet" cargo install --git https://github.com/0xSpaceShard/starknet-devnet-rs.git --locked --tag ${{ env.DEVNET_TAG }} --root $DEVNET_INSTALL_DIR - uses: software-mansion/setup-scarb@v1 with: From 3bb66d724c67f6f2102291fd0abb6e3cb82d60de Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Tue, 3 Dec 2024 16:14:50 +0100 Subject: [PATCH 45/68] Make hard_test harder --- .../forge/tests/data/exit_first/tests/ext_function_test.cairo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/forge/tests/data/exit_first/tests/ext_function_test.cairo b/crates/forge/tests/data/exit_first/tests/ext_function_test.cairo index 09d8dc6c93..e74e9adb88 100644 --- a/crates/forge/tests/data/exit_first/tests/ext_function_test.cairo +++ b/crates/forge/tests/data/exit_first/tests/ext_function_test.cairo @@ -2,7 +2,7 @@ use exit_first::fib; #[test] fn hard_test() { - fib(0, 1, 30344); + fib(0, 1, 99999999999999999999999); assert(2 == 2, 'simple check'); } From 4135145206a3178c4845824c20b0ce783b45180c Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Tue, 3 Dec 2024 17:36:10 +0100 Subject: [PATCH 46/68] Add missing ``` --- crates/sncast/tests/shell/invoke.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/sncast/tests/shell/invoke.ps1 b/crates/sncast/tests/shell/invoke.ps1 index acec51e0e6..e9eeb02f07 100644 --- a/crates/sncast/tests/shell/invoke.ps1 +++ b/crates/sncast/tests/shell/invoke.ps1 @@ -18,6 +18,6 @@ array![array![1, 2], array![3, 4, 5], array![6]], ('a shortstring', 32_u32), true, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -'@ +'@ ` --max-fee 99999999999999999 ` --fee-token eth From f95d30f44f13ac3daad4d571dfe86c4fb3da63b7 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Wed, 4 Dec 2024 12:39:26 +0100 Subject: [PATCH 47/68] Build devnet cache --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9c25b4463..ce07a27582 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -233,10 +233,10 @@ jobs: with: scarb-version: "2.7.0" - uses: software-mansion/setup-universal-sierra-compiler@v1 - - name: Run tests - run: cargo test --release -p sncast - - name: Run test in debug profile - run: cargo test -p sncast test_happy_case_common_arguments_after_subcommand +# - name: Run tests +# run: cargo test --release -p sncast +# - name: Run test in debug profile +# run: cargo test -p sncast test_happy_case_common_arguments_after_subcommand test-conversions: name: Test Conversions From 5085d3216aea121b0031f95be5b00a46604f6ccc Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Wed, 4 Dec 2024 17:47:59 +0100 Subject: [PATCH 48/68] Uncomment tests --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce07a27582..c9c25b4463 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -233,10 +233,10 @@ jobs: with: scarb-version: "2.7.0" - uses: software-mansion/setup-universal-sierra-compiler@v1 -# - name: Run tests -# run: cargo test --release -p sncast -# - name: Run test in debug profile -# run: cargo test -p sncast test_happy_case_common_arguments_after_subcommand + - name: Run tests + run: cargo test --release -p sncast + - name: Run test in debug profile + run: cargo test -p sncast test_happy_case_common_arguments_after_subcommand test-conversions: name: Test Conversions From 023f4fac674d4992d497615620cc9ae25721e22b Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Wed, 4 Dec 2024 18:39:14 +0100 Subject: [PATCH 49/68] Remove steps running non-existent test --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9c25b4463..24d39bdd0f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -235,8 +235,6 @@ jobs: - uses: software-mansion/setup-universal-sierra-compiler@v1 - name: Run tests run: cargo test --release -p sncast - - name: Run test in debug profile - run: cargo test -p sncast test_happy_case_common_arguments_after_subcommand test-conversions: name: Test Conversions From 000aa1d1757deb5602f83aaf86bf2d09fc21c983 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Thu, 5 Dec 2024 11:20:28 +0100 Subject: [PATCH 50/68] Add newline to .gitattributes --- .gitattributes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index a52bd184c2..7cc205090b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -*.* text eol=lf \ No newline at end of file +*.* text eol=lf From 10faf2338f4b505fec21c3cdd3963a8a567cebf5 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Thu, 5 Dec 2024 11:22:51 +0100 Subject: [PATCH 51/68] Use proper cfg for windows --- crates/forge/tests/e2e/build_profile.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/forge/tests/e2e/build_profile.rs b/crates/forge/tests/e2e/build_profile.rs index f668baf319..6b3fc59974 100644 --- a/crates/forge/tests/e2e/build_profile.rs +++ b/crates/forge/tests/e2e/build_profile.rs @@ -2,7 +2,7 @@ use super::common::runner::{setup_package, test_runner}; use forge_runner::profiler_api::PROFILE_DIR; #[test] -#[cfg_attr(not(feature = "scarb_2_8_3"), ignore)] +#[cfg(not(target_os = "windows"))] fn simple_package_build_profile() { let temp = setup_package("simple_package"); @@ -30,7 +30,7 @@ fn simple_package_build_profile() { } #[test] -#[cfg_attr(not(feature = "scarb_2_8_3"), ignore)] +#[cfg(not(target_os = "windows"))] fn simple_package_build_profile_and_pass_args() { let temp = setup_package("simple_package"); From 10dde829e94011c2eeabd54ba68199eabb30396c Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Thu, 5 Dec 2024 11:24:08 +0100 Subject: [PATCH 52/68] Restore tests order --- crates/forge/tests/integration/cheat_fork.rs | 32 ++++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/crates/forge/tests/integration/cheat_fork.rs b/crates/forge/tests/integration/cheat_fork.rs index f3fd428433..215b25d9f9 100644 --- a/crates/forge/tests/integration/cheat_fork.rs +++ b/crates/forge/tests/integration/cheat_fork.rs @@ -155,11 +155,11 @@ fn cheat_block_timestamp_cairo0_contract() { #[cfg(not(target_os = "windows"))] #[test] -fn store_load_cairo0_contract() { +fn mock_call_cairo0_contract() { let test = test_case!(formatdoc!( r#" use starknet::{{contract_address_const}}; - use snforge_std::{{store, load}}; + use snforge_std::{{start_mock_call, stop_mock_call}}; #[starknet::interface] trait IERC20 {{ @@ -177,17 +177,13 @@ fn store_load_cairo0_contract() { assert(eth_dispatcher.name() == 'Ether', 'invalid name'); - let name = load(eth_dispatcher.contract_address, selector!("ERC20_name"), 1); + start_mock_call(eth_dispatcher.contract_address, selector!("name"), 'NotEther'); - assert(name == array!['Ether'], 'invalid load value'); + assert(eth_dispatcher.name() == 'NotEther', 'invalid mocked name'); - store(eth_dispatcher.contract_address, selector!("ERC20_name"), array!['NotEther'].span()); + stop_mock_call(eth_dispatcher.contract_address, selector!("name")); - assert(eth_dispatcher.name() == 'NotEther', 'invalid store name'); - - let name = load(eth_dispatcher.contract_address, selector!("ERC20_name"), 1); - - assert(name == array!['NotEther'], 'invalid load2 name'); + assert(eth_dispatcher.name() == 'Ether', 'invalid name after mock'); }} "#, node_rpc_url(), @@ -201,11 +197,11 @@ fn store_load_cairo0_contract() { #[cfg(not(target_os = "windows"))] #[test] -fn mock_call_cairo0_contract() { +fn store_load_cairo0_contract() { let test = test_case!(formatdoc!( r#" use starknet::{{contract_address_const}}; - use snforge_std::{{start_mock_call, stop_mock_call}}; + use snforge_std::{{store, load}}; #[starknet::interface] trait IERC20 {{ @@ -223,13 +219,17 @@ fn mock_call_cairo0_contract() { assert(eth_dispatcher.name() == 'Ether', 'invalid name'); - start_mock_call(eth_dispatcher.contract_address, selector!("name"), 'NotEther'); + let name = load(eth_dispatcher.contract_address, selector!("ERC20_name"), 1); - assert(eth_dispatcher.name() == 'NotEther', 'invalid mocked name'); + assert(name == array!['Ether'], 'invalid load value'); - stop_mock_call(eth_dispatcher.contract_address, selector!("name")); + store(eth_dispatcher.contract_address, selector!("ERC20_name"), array!['NotEther'].span()); - assert(eth_dispatcher.name() == 'Ether', 'invalid name after mock'); + assert(eth_dispatcher.name() == 'NotEther', 'invalid store name'); + + let name = load(eth_dispatcher.contract_address, selector!("ERC20_name"), 1); + + assert(name == array!['NotEther'], 'invalid load2 name'); }} "#, node_rpc_url(), From b9527aa34fd04bd506a7ccb5ca184f89a709440f Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Thu, 5 Dec 2024 11:26:17 +0100 Subject: [PATCH 53/68] Disable whole modules on windows --- crates/forge/tests/integration/cheat_fork.rs | 5 ----- crates/forge/tests/integration/mod.rs | 2 ++ crates/forge/tests/integration/setup_fork.rs | 7 ------- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/crates/forge/tests/integration/cheat_fork.rs b/crates/forge/tests/integration/cheat_fork.rs index 215b25d9f9..a1ba19c3de 100644 --- a/crates/forge/tests/integration/cheat_fork.rs +++ b/crates/forge/tests/integration/cheat_fork.rs @@ -4,7 +4,6 @@ use test_utils::runner::assert_passed; use test_utils::running_tests::run_test_case; use test_utils::test_case; -#[cfg(not(target_os = "windows"))] #[test] fn cheat_caller_address_cairo0_contract() { let test = test_case!(formatdoc!( @@ -53,7 +52,6 @@ fn cheat_caller_address_cairo0_contract() { assert_passed(&result); } -#[cfg(not(target_os = "windows"))] #[test] fn cheat_block_number_cairo0_contract() { let test = test_case!(formatdoc!( @@ -102,7 +100,6 @@ fn cheat_block_number_cairo0_contract() { assert_passed(&result); } -#[cfg(not(target_os = "windows"))] #[test] fn cheat_block_timestamp_cairo0_contract() { let test = test_case!(formatdoc!( @@ -153,7 +150,6 @@ fn cheat_block_timestamp_cairo0_contract() { assert_passed(&result); } -#[cfg(not(target_os = "windows"))] #[test] fn mock_call_cairo0_contract() { let test = test_case!(formatdoc!( @@ -195,7 +191,6 @@ fn mock_call_cairo0_contract() { assert_passed(&result); } -#[cfg(not(target_os = "windows"))] #[test] fn store_load_cairo0_contract() { let test = test_case!(formatdoc!( diff --git a/crates/forge/tests/integration/mod.rs b/crates/forge/tests/integration/mod.rs index 50358ba7a3..6332e29e26 100644 --- a/crates/forge/tests/integration/mod.rs +++ b/crates/forge/tests/integration/mod.rs @@ -3,6 +3,7 @@ mod cheat_block_number; mod cheat_block_timestamp; mod cheat_caller_address; mod cheat_execution_info; +#[cfg(not(target_os = "windows"))] mod cheat_fork; mod cheat_sequencer_address; mod declare; @@ -23,6 +24,7 @@ mod pure_cairo; mod replace_bytecode; mod resources; mod runtime; +#[cfg(not(target_os = "windows"))] mod setup_fork; mod should_panic; mod signing; diff --git a/crates/forge/tests/integration/setup_fork.rs b/crates/forge/tests/integration/setup_fork.rs index 730fbc594a..cad6272be1 100644 --- a/crates/forge/tests/integration/setup_fork.rs +++ b/crates/forge/tests/integration/setup_fork.rs @@ -27,7 +27,6 @@ use test_utils::runner::{assert_case_output_contains, assert_failed, assert_pass use test_utils::running_tests::run_test_case; use test_utils::test_case; -#[cfg(not(target_os = "windows"))] #[test] fn fork_simple_decorator() { let test = test_case!(formatdoc!( @@ -71,7 +70,6 @@ fn fork_simple_decorator() { assert_passed(&result); } -#[cfg(not(target_os = "windows"))] #[test] fn fork_aliased_decorator() { let test = test_case!(indoc!( @@ -180,7 +178,6 @@ fn fork_aliased_decorator() { assert_passed(&result); } -#[cfg(not(target_os = "windows"))] #[test] fn fork_aliased_decorator_overrding() { let test = test_case!(indoc!( @@ -271,7 +268,6 @@ fn fork_aliased_decorator_overrding() { assert_passed(&result); } -#[cfg(not(target_os = "windows"))] #[test] fn fork_cairo0_contract() { let test = test_case!(formatdoc!( @@ -302,7 +298,6 @@ fn fork_cairo0_contract() { assert_passed(&result); } -#[cfg(not(target_os = "windows"))] #[test] fn get_block_info_in_forked_block() { let test = test_case!(formatdoc!( @@ -403,7 +398,6 @@ fn get_block_info_in_forked_block() { assert_passed(&result); } -#[cfg(not(target_os = "windows"))] #[test] fn fork_get_block_info_fails() { let test = test_case!(formatdoc!( @@ -428,7 +422,6 @@ fn fork_get_block_info_fails() { ); } -#[cfg(not(target_os = "windows"))] #[test] // found in: https://github.com/foundry-rs/starknet-foundry/issues/1175 fn incompatible_abi() { From d9cefbc5725feb04a4c8b014365e0841e6bd87d4 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Thu, 5 Dec 2024 11:28:07 +0100 Subject: [PATCH 54/68] Update asserts --- crates/sncast/tests/e2e/multicall/new.rs | 2 +- crates/sncast/tests/e2e/multicall/run.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/sncast/tests/e2e/multicall/new.rs b/crates/sncast/tests/e2e/multicall/new.rs index 97361052f7..db8638946a 100644 --- a/crates/sncast/tests/e2e/multicall/new.rs +++ b/crates/sncast/tests/e2e/multicall/new.rs @@ -77,7 +77,7 @@ async fn test_directory_non_existent() { output, indoc! {r" command: multicall new - error: [..] + error: [..]file[..] "}, ); } diff --git a/crates/sncast/tests/e2e/multicall/run.rs b/crates/sncast/tests/e2e/multicall/run.rs index 79e15f78ce..b53d0c883c 100644 --- a/crates/sncast/tests/e2e/multicall/run.rs +++ b/crates/sncast/tests/e2e/multicall/run.rs @@ -122,7 +122,7 @@ async fn test_invalid_path() { output, indoc! {r" command: multicall run - error: [..] + error: [..]file[..] "}, ); } From c5f45ec03418c6f6a59e68eb84546d7982081384 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Thu, 5 Dec 2024 11:28:19 +0100 Subject: [PATCH 55/68] Add missing newline to install_devnet.ps1 --- scripts/install_devnet.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install_devnet.ps1 b/scripts/install_devnet.ps1 index 260c8406f8..e17ab65876 100644 --- a/scripts/install_devnet.ps1 +++ b/scripts/install_devnet.ps1 @@ -18,4 +18,4 @@ cargo install --locked --git $DEVNET_REPO --tag $DEVNET_TAG --root $DEVNET_INSTA Write-Host "All done!" # Exit with success -exit 0 \ No newline at end of file +exit 0 From 84f40bf8aa26f60c29cc87cddc633cb30fb9751c Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Thu, 5 Dec 2024 11:56:06 +0100 Subject: [PATCH 56/68] Run profiler only on not windows --- .github/workflows/ci.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24d39bdd0f..e00bf3200a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,6 +86,15 @@ jobs: run: echo 'The branch name is' $BRANCH_NAME shell: bash + - name: Install cairo-profiler + if: runner.os != 'Windows' + run: | + curl -L https://raw.githubusercontent.com/software-mansion/cairo-profiler/main/scripts/install.sh | sh + - name: Install cairo-coverage + if: runner.os != 'Windows' + run: | + curl -L https://raw.githubusercontent.com/software-mansion/cairo-coverage/main/scripts/install.sh | sh + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab @@ -120,7 +129,6 @@ jobs: - run: cargo test --package forge --features scarb_2_8_3 --test main e2e::coverage - run: cargo test --package forge --features scarb_2_8_3 --test main e2e::backtrace - - run: cargo test --package forge --features scarb_2_8_3 --test main e2e::build_profile test-coverage-error: name: Test coverage error From 409eeab0cef09f7f03b999a4890f74471da42e2a Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Thu, 5 Dec 2024 12:02:46 +0100 Subject: [PATCH 57/68] Remove os specific asserts --- crates/sncast/tests/e2e/multicall/new.rs | 2 +- crates/sncast/tests/e2e/multicall/run.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/sncast/tests/e2e/multicall/new.rs b/crates/sncast/tests/e2e/multicall/new.rs index db8638946a..97361052f7 100644 --- a/crates/sncast/tests/e2e/multicall/new.rs +++ b/crates/sncast/tests/e2e/multicall/new.rs @@ -77,7 +77,7 @@ async fn test_directory_non_existent() { output, indoc! {r" command: multicall new - error: [..]file[..] + error: [..] "}, ); } diff --git a/crates/sncast/tests/e2e/multicall/run.rs b/crates/sncast/tests/e2e/multicall/run.rs index b53d0c883c..79e15f78ce 100644 --- a/crates/sncast/tests/e2e/multicall/run.rs +++ b/crates/sncast/tests/e2e/multicall/run.rs @@ -122,7 +122,7 @@ async fn test_invalid_path() { output, indoc! {r" command: multicall run - error: [..]file[..] + error: [..] "}, ); } From 34178da308820dcb0e1262a993cfb0f5c4f8a721 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 9 Dec 2024 17:00:45 +0100 Subject: [PATCH 58/68] Remove unnecessary profiler installation --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e00bf3200a..4d1a7e654a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -123,10 +123,6 @@ jobs: run: | curl -L https://raw.githubusercontent.com/software-mansion/cairo-coverage/main/scripts/install.sh | sh - - name: Install cairo-profiler - run: | - curl -L https://raw.githubusercontent.com/software-mansion/cairo-profiler/main/scripts/install.sh | sh - - run: cargo test --package forge --features scarb_2_8_3 --test main e2e::coverage - run: cargo test --package forge --features scarb_2_8_3 --test main e2e::backtrace From 92c025b4088a69a68064a39f0d2906f6a6a8debb Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 9 Dec 2024 17:03:55 +0100 Subject: [PATCH 59/68] Mention trace file changes in CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d65aae31f..416f9702fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Forge + +#### Changed + +- Trace files saved in `snfoundry_trace` directory will now use `_` as separators instead of `::` + ### `snforge_scarb_plugin` #### Changed From 833320c99395079dd36c252eb1f3bcc003625bf7 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 9 Dec 2024 17:04:52 +0100 Subject: [PATCH 60/68] Remove unnecessary todo --- crates/sncast/src/state/state_file.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/sncast/src/state/state_file.rs b/crates/sncast/src/state/state_file.rs index 70b51a6dec..bd0258d666 100644 --- a/crates/sncast/src/state/state_file.rs +++ b/crates/sncast/src/state/state_file.rs @@ -397,7 +397,6 @@ mod tests { #[test] #[should_panic(expected = "Failed to load state file")] - // TODO handle system specific panics fn test_load_state_file_invalid_path() { let state_file = Utf8PathBuf::from("bla/bla/crypto.json"); load_state_file(&state_file).unwrap(); From 1a51b130d6cdd40fb4e71a61edbcc1856f162e99 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Mon, 9 Dec 2024 17:08:10 +0100 Subject: [PATCH 61/68] Use revision instead of tag --- scripts/install_devnet.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install_devnet.ps1 b/scripts/install_devnet.ps1 index e17ab65876..17379fff0f 100644 --- a/scripts/install_devnet.ps1 +++ b/scripts/install_devnet.ps1 @@ -9,10 +9,10 @@ $DEVNET_INSTALL_DIR = Join-Path (git rev-parse --show-toplevel) "crates\sncast\t # Set the DEVNET repository and revision $DEVNET_REPO = "https://github.com/0xSpaceShard/starknet-devnet-rs.git" -$DEVNET_TAG = "v0.2.2" +$DEVNET_REV = "ef789b700770fa27a2fc057b3d1c610771be27d9" # Perform cargo install -cargo install --locked --git $DEVNET_REPO --tag $DEVNET_TAG --root $DEVNET_INSTALL_DIR --force +cargo install --locked --git $DEVNET_REPO --rev $DEVNET_REV --root $DEVNET_INSTALL_DIR --force # Output completion message Write-Host "All done!" From e9e18edcc4ee6a5f818c32ea31c52b05d58aa773 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Tue, 10 Dec 2024 14:55:07 +0100 Subject: [PATCH 62/68] Restore OS specific errors for files --- crates/forge/tests/e2e/io_operations.rs | 16 +++++++++----- crates/forge/tests/e2e/running.rs | 26 ++++++++++++++++------- crates/sncast/tests/e2e/account/import.rs | 12 ++++++++--- crates/sncast/tests/e2e/multicall/new.rs | 15 +++++++++---- crates/sncast/tests/e2e/multicall/run.rs | 15 +++++++++---- 5 files changed, 60 insertions(+), 24 deletions(-) diff --git a/crates/forge/tests/e2e/io_operations.rs b/crates/forge/tests/e2e/io_operations.rs index 340d24d449..e5ed33f889 100644 --- a/crates/forge/tests/e2e/io_operations.rs +++ b/crates/forge/tests/e2e/io_operations.rs @@ -1,6 +1,6 @@ use super::common::runner::{setup_package_with_file_patterns, test_runner, BASE_FILE_PATTERNS}; use assert_fs::fixture::PathChild; -use indoc::indoc; +use indoc::{formatdoc, indoc}; use shared::test_utils::output_assert::assert_stdout_contains; #[test] @@ -11,7 +11,13 @@ fn file_reading() { &[BASE_FILE_PATTERNS, &["**/*.txt", "**/*.json"]].concat(), ); - let expected = indoc! {r#" + let expected_file_error = if cfg!(target_os = "windows") { + "The system cannot find the file specified [..]" + } else { + "No such file or directory [..]" + }; + + let expected = formatdoc! {r#" [..]Compiling[..] [..]Finished[..] @@ -21,7 +27,7 @@ fn file_reading() { [FAIL] file_reading_integrationtest::test::json_non_existent Failure data: - [..] + "{}" [FAIL] file_reading_integrationtest::test::invalid_json @@ -31,7 +37,7 @@ fn file_reading() { [FAIL] file_reading_integrationtest::test::non_existent Failure data: - "[..] file [..]" + "{}" [FAIL] file_reading_integrationtest::test::non_ascii @@ -62,7 +68,7 @@ fn file_reading() { file_reading_integrationtest::test::non_ascii file_reading_integrationtest::test::valid_content_different_folder file_reading_integrationtest::test::negative_number - "#}; + "#, expected_file_error, expected_file_error}; // run from different directories to make sure cwd is always set to package directory let output = test_runner(&temp).assert().code(1); diff --git a/crates/forge/tests/e2e/running.rs b/crates/forge/tests/e2e/running.rs index 4424000e18..7d675bb96b 100644 --- a/crates/forge/tests/e2e/running.rs +++ b/crates/forge/tests/e2e/running.rs @@ -1039,21 +1039,31 @@ fn detailed_resources_flag() { fn catch_runtime_errors() { let temp = setup_package("simple_package"); + let expected_panic = if cfg!(target_os = "windows") { + "The system cannot find the file specified" + } else { + "No such file or directory" + }; + temp.child("tests/test.cairo") - .write_str(indoc!( - r#" - use snforge_std::fs::{FileTrait, read_txt}; + .write_str( + formatdoc!( + r#" + use snforge_std::fs::{{FileTrait, read_txt}}; #[test] - #[should_panic(expected: "file")] - fn catch_no_such_file() { + #[should_panic(expected: "{}")] + fn catch_no_such_file() {{ let file = FileTrait::new("no_way_this_file_exists"); let content = read_txt(@file); assert!(false); - } - "# - )) + }} + "#, + expected_panic + ) + .as_str(), + ) .unwrap(); let output = test_runner(&temp).assert(); diff --git a/crates/sncast/tests/e2e/account/import.rs b/crates/sncast/tests/e2e/account/import.rs index 4e0f7e6d50..b34a692670 100644 --- a/crates/sncast/tests/e2e/account/import.rs +++ b/crates/sncast/tests/e2e/account/import.rs @@ -451,12 +451,18 @@ pub async fn test_invalid_private_key_file_path() { let snapbox = runner(&args); let output = snapbox.assert().success(); + let expected_file_error = if cfg!(target_os = "windows") { + "The system cannot find the file specified [..]" + } else { + "No such file or directory [..]" + }; + assert_stderr_contains( output, - indoc! {r" + formatdoc! {r" command: account import - error: Failed to obtain private key from the file my_private_key: [..] - "}, + error: Failed to obtain private key from the file my_private_key: {} + ", expected_file_error}, ); } diff --git a/crates/sncast/tests/e2e/multicall/new.rs b/crates/sncast/tests/e2e/multicall/new.rs index 97361052f7..185a57018e 100644 --- a/crates/sncast/tests/e2e/multicall/new.rs +++ b/crates/sncast/tests/e2e/multicall/new.rs @@ -1,6 +1,6 @@ use crate::helpers::constants::ACCOUNT_FILE_PATH; use crate::helpers::runner::runner; -use indoc::indoc; +use indoc::{formatdoc, indoc}; use shared::test_utils::output_assert::{assert_stderr_contains, assert_stdout_contains, AsOutput}; use sncast::helpers::constants::DEFAULT_MULTICALL_CONTENTS; use tempfile::tempdir; @@ -73,12 +73,19 @@ async fn test_directory_non_existent() { let output = snapbox.assert().success(); assert!(output.as_stdout().is_empty()); + + let expected_file_error = if cfg!(target_os = "windows") { + "The system cannot find the file specified [..]" + } else { + "No such file or directory [..]" + }; + assert_stderr_contains( output, - indoc! {r" + formatdoc! {r" command: multicall new - error: [..] - "}, + error: {} + ", expected_file_error}, ); } diff --git a/crates/sncast/tests/e2e/multicall/run.rs b/crates/sncast/tests/e2e/multicall/run.rs index 79e15f78ce..bd81b6f91a 100644 --- a/crates/sncast/tests/e2e/multicall/run.rs +++ b/crates/sncast/tests/e2e/multicall/run.rs @@ -1,7 +1,7 @@ use crate::helpers::constants::{ACCOUNT_FILE_PATH, MULTICALL_CONFIGS_DIR, URL}; use crate::helpers::fixtures::create_and_deploy_oz_account; use crate::helpers::runner::runner; -use indoc::indoc; +use indoc::{formatdoc, indoc}; use shared::test_utils::output_assert::{assert_stderr_contains, AsOutput}; use std::path::Path; use test_case::test_case; @@ -118,12 +118,19 @@ async fn test_invalid_path() { let output = snapbox.assert().success(); assert!(output.as_stdout().is_empty()); + + let expected_file_error = if cfg!(target_os = "windows") { + "The system cannot find the file specified [..]" + } else { + "No such file or directory [..]" + }; + assert_stderr_contains( output, - indoc! {r" + formatdoc! {r" command: multicall run - error: [..] - "}, + error: {} + ", expected_file_error}, ); } From 04637a9479821a352e27a165d3c4df1d0354f79c Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Tue, 10 Dec 2024 14:57:57 +0100 Subject: [PATCH 63/68] Lint, use reference --- crates/forge/tests/e2e/io_operations.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/forge/tests/e2e/io_operations.rs b/crates/forge/tests/e2e/io_operations.rs index e5ed33f889..bfe1c12768 100644 --- a/crates/forge/tests/e2e/io_operations.rs +++ b/crates/forge/tests/e2e/io_operations.rs @@ -1,6 +1,6 @@ use super::common::runner::{setup_package_with_file_patterns, test_runner, BASE_FILE_PATTERNS}; use assert_fs::fixture::PathChild; -use indoc::{formatdoc, indoc}; +use indoc::formatdoc; use shared::test_utils::output_assert::assert_stdout_contains; #[test] @@ -73,19 +73,19 @@ fn file_reading() { // run from different directories to make sure cwd is always set to package directory let output = test_runner(&temp).assert().code(1); - assert_stdout_contains(output, expected); + assert_stdout_contains(output, &expected); let output = test_runner(&temp) .current_dir(temp.child("src")) .assert() .code(1); - assert_stdout_contains(output, expected); + assert_stdout_contains(output, &expected); let output = test_runner(&temp) .current_dir(temp.child("data")) .assert() .code(1); - assert_stdout_contains(output, expected); + assert_stdout_contains(output, &expected); } From cbefce3a2784151e8c838b5fe4d81bf79bee39e9 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Tue, 10 Dec 2024 15:57:36 +0100 Subject: [PATCH 64/68] Fix windows error --- crates/forge/tests/e2e/io_operations.rs | 2 +- crates/sncast/tests/e2e/account/import.rs | 2 +- crates/sncast/tests/e2e/multicall/new.rs | 2 +- crates/sncast/tests/e2e/multicall/run.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/forge/tests/e2e/io_operations.rs b/crates/forge/tests/e2e/io_operations.rs index bfe1c12768..f5731d8e7e 100644 --- a/crates/forge/tests/e2e/io_operations.rs +++ b/crates/forge/tests/e2e/io_operations.rs @@ -12,7 +12,7 @@ fn file_reading() { ); let expected_file_error = if cfg!(target_os = "windows") { - "The system cannot find the file specified [..]" + "The system cannot find the file specified[..]" } else { "No such file or directory [..]" }; diff --git a/crates/sncast/tests/e2e/account/import.rs b/crates/sncast/tests/e2e/account/import.rs index b34a692670..c94b6dc56f 100644 --- a/crates/sncast/tests/e2e/account/import.rs +++ b/crates/sncast/tests/e2e/account/import.rs @@ -452,7 +452,7 @@ pub async fn test_invalid_private_key_file_path() { let output = snapbox.assert().success(); let expected_file_error = if cfg!(target_os = "windows") { - "The system cannot find the file specified [..]" + "The system cannot find the file specified[..]" } else { "No such file or directory [..]" }; diff --git a/crates/sncast/tests/e2e/multicall/new.rs b/crates/sncast/tests/e2e/multicall/new.rs index 185a57018e..4f5324904c 100644 --- a/crates/sncast/tests/e2e/multicall/new.rs +++ b/crates/sncast/tests/e2e/multicall/new.rs @@ -75,7 +75,7 @@ async fn test_directory_non_existent() { assert!(output.as_stdout().is_empty()); let expected_file_error = if cfg!(target_os = "windows") { - "The system cannot find the file specified [..]" + "The system cannot find the file specified[..]" } else { "No such file or directory [..]" }; diff --git a/crates/sncast/tests/e2e/multicall/run.rs b/crates/sncast/tests/e2e/multicall/run.rs index bd81b6f91a..d6f4e40973 100644 --- a/crates/sncast/tests/e2e/multicall/run.rs +++ b/crates/sncast/tests/e2e/multicall/run.rs @@ -120,7 +120,7 @@ async fn test_invalid_path() { assert!(output.as_stdout().is_empty()); let expected_file_error = if cfg!(target_os = "windows") { - "The system cannot find the file specified [..]" + "The system cannot find the file specified[..]" } else { "No such file or directory [..]" }; From e351f64d16effa6a8afa2193996ac30dd7b1ede8 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Tue, 10 Dec 2024 17:06:23 +0100 Subject: [PATCH 65/68] Fix windows error --- crates/sncast/tests/e2e/multicall/new.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/sncast/tests/e2e/multicall/new.rs b/crates/sncast/tests/e2e/multicall/new.rs index 4f5324904c..0e813c085e 100644 --- a/crates/sncast/tests/e2e/multicall/new.rs +++ b/crates/sncast/tests/e2e/multicall/new.rs @@ -75,7 +75,7 @@ async fn test_directory_non_existent() { assert!(output.as_stdout().is_empty()); let expected_file_error = if cfg!(target_os = "windows") { - "The system cannot find the file specified[..]" + "The system cannot find the path specified[..]" } else { "No such file or directory [..]" }; From 0112d709705364ba8d9465bcde5beebbc86fa341 Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Tue, 10 Dec 2024 17:11:07 +0100 Subject: [PATCH 66/68] Use devnet revision on ci --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d1a7e654a..0431952086 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,7 @@ name: CI env: - DEVNET_TAG: "v0.2.2" + DEVNET_REV: "ef789b700770fa27a2fc057b3d1c610771be27d9" on: pull_request: @@ -227,12 +227,12 @@ jobs: uses: actions/cache@v4 with: path: ${{ github.workspace }}\crates\sncast\tests\utils\devnet - key: ${{ runner.os }}-devnet-${{ env.DEVNET_TAG }} + key: ${{ runner.os }}-devnet-${{ env.DEVNET_REV }} - name: Install devnet if: runner.os == 'Windows' && steps.windows-devnet-cache.outputs.cache-hit != 'true' run: | $DEVNET_INSTALL_DIR = "${{ github.workspace }}\crates\sncast\tests\utils\devnet" - cargo install --git https://github.com/0xSpaceShard/starknet-devnet-rs.git --locked --tag ${{ env.DEVNET_TAG }} --root $DEVNET_INSTALL_DIR + cargo install --git https://github.com/0xSpaceShard/starknet-devnet-rs.git --locked --rev ${{ env.DEVNET_REV }} --root $DEVNET_INSTALL_DIR - uses: software-mansion/setup-scarb@v1 with: scarb-version: "2.7.0" From aa534d1f0581d67edfd07e3466efdcc26510654e Mon Sep 17 00:00:00 2001 From: Artur Michalek Date: Tue, 10 Dec 2024 17:11:21 +0100 Subject: [PATCH 67/68] Remove comments --- scripts/install_devnet.ps1 | 7 ------- 1 file changed, 7 deletions(-) diff --git a/scripts/install_devnet.ps1 b/scripts/install_devnet.ps1 index 17379fff0f..f73ea76f62 100644 --- a/scripts/install_devnet.ps1 +++ b/scripts/install_devnet.ps1 @@ -1,21 +1,14 @@ -# Set strict mode Set-StrictMode -Version Latest -# Stop the script on error $ErrorActionPreference = "Stop" -# Get the path of the top-level Git directory $DEVNET_INSTALL_DIR = Join-Path (git rev-parse --show-toplevel) "crates\sncast\tests\utils\devnet" -# Set the DEVNET repository and revision $DEVNET_REPO = "https://github.com/0xSpaceShard/starknet-devnet-rs.git" $DEVNET_REV = "ef789b700770fa27a2fc057b3d1c610771be27d9" -# Perform cargo install cargo install --locked --git $DEVNET_REPO --rev $DEVNET_REV --root $DEVNET_INSTALL_DIR --force -# Output completion message Write-Host "All done!" -# Exit with success exit 0 From 91d8ec5e6ae6fb1504a1fbc53741ba0022c895c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20Micha=C5=82ek?= <52135326+cptartur@users.noreply.github.com> Date: Tue, 10 Dec 2024 17:29:30 +0100 Subject: [PATCH 68/68] Update .github/workflows/ci.yml Co-authored-by: Franciszek Job <54181625+franciszekjob@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0431952086..2f9f3ebbac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,7 @@ name: CI env: - DEVNET_REV: "ef789b700770fa27a2fc057b3d1c610771be27d9" + DEVNET_REV: ef789b700770fa27a2fc057b3d1c610771be27d9 on: pull_request: