From 251761c7dc89cbeef69e565584cdf6f54aaaed30 Mon Sep 17 00:00:00 2001 From: Piotr Magiera <56825108+piotmag769@users.noreply.github.com> Date: Wed, 25 Oct 2023 14:08:40 +0200 Subject: [PATCH] Bump Cairo and Scarb to 2.3.0 (#955) Did not verify the new sierra class hashes, but afaik we have a task to automate those tests #929 Wrapping tests in src in `#[cfg(test)]` was needed - it shouldn't have been allowed in the first place before, seems like a fixed compiler bug ## Introduced changes Self-explanatory. ## Checklist - [x] Linked relevant issue - [x] Updated relevant documentation - [x] Added relevant tests - [x] Performed self-review of the code - [x] Added changes to `CHANGELOG.md` --- .github/workflows/ci.yml | 6 +- .gitignore | 2 + CHANGELOG.md | 2 + Cargo.lock | 151 +++++----- Cargo.toml | 38 +-- benchmarks/data/project/Scarb.toml | 2 +- crates/cheatnet/tests/cheatcodes/declare.rs | 4 +- crates/cheatnet/tests/contracts/Scarb.lock | 6 + crates/cheatnet/tests/contracts/Scarb.toml | 2 +- crates/forge/src/scarb.rs | 27 +- .../data/collection_with_lib/src/fab.cairo | 9 +- .../src/fab/fab_impl.cairo | 29 +- .../src/fab/fibfabfob.cairo | 29 +- .../data/collection_with_lib/src/fib.cairo | 29 +- .../data/collection_with_lib/src/fob.cairo | 9 +- .../src/fob/fibfabfob.cairo | 28 +- .../src/fob/fob_impl.cairo | 11 +- .../data/collection_with_lib/src/lib.cairo | 26 +- .../data/collection_without_lib/src/fab.cairo | 9 +- .../src/fab/fab_impl.cairo | 29 +- .../src/fab/fibfabfob.cairo | 27 +- .../data/collection_without_lib/src/fib.cairo | 27 +- .../data/collection_without_lib/src/fob.cairo | 9 +- .../src/fob/fibfabfob.cairo | 28 +- .../src/fob/fob_impl.cairo | 11 +- .../data/collection_without_lib/src/lib.cairo | 26 +- .../tests/data/contract_printing/Scarb.toml | 2 +- .../diagnostics_and_plugins/src/lib.cairo | 11 +- crates/forge/tests/data/env/src/lib.cairo | 17 +- crates/forge/tests/data/exit_first/Scarb.toml | 2 +- .../forge/tests/data/file_reading/Scarb.toml | 2 +- .../tests/data/file_reading/src/lib.cairo | 271 +++++++++--------- crates/forge/tests/data/forking/Scarb.toml | 2 +- crates/forge/tests/data/forking/src/lib.cairo | 46 ++- crates/forge/tests/data/fuzzing/Scarb.toml | 2 +- .../tests/data/hello_workspaces/Scarb.toml | 2 +- .../tests/data/hello_workspaces/src/lib.cairo | 9 +- .../tests/data/simple_package/Scarb.toml | 2 +- .../tests/data/simple_package/src/lib.cairo | 21 +- .../tests/data/virtual_workspace/Scarb.toml | 2 +- crates/forge/tests/e2e/collection.rs | 60 ++-- crates/forge/tests/e2e/common/runner.rs | 6 +- .../tests/e2e/diagnostics_and_plugins.rs | 20 +- crates/forge/tests/e2e/env.rs | 2 +- crates/forge/tests/e2e/forking.rs | 10 +- crates/forge/tests/e2e/fuzzing.rs | 2 +- crates/forge/tests/e2e/io_operations.rs | 30 +- crates/forge/tests/e2e/running.rs | 27 +- crates/forge/tests/e2e/workspaces.rs | 10 +- crates/forge/tests/integration/dispatchers.rs | 2 +- crates/forge/tests/integration/spy_events.rs | 2 +- crates/forge/tests/integration/syscalls.rs | 7 +- crates/test-collector/src/plugin.rs | 11 + docs/src/SUMMARY.md | 4 +- docs/src/appendix/forge/test.md | 2 +- docs/src/testing/contracts.md | 17 +- docs/src/testing/debugging.md | 9 +- docs/src/testing/fuzz-testing.md | 5 +- docs/src/testing/running-tests.md | 34 +-- docs/src/testing/test-collection.md | 3 +- docs/src/testing/testing.md | 43 +-- docs/src/testing/using-cheatcodes.md | 19 +- snforge_std/Scarb.lock | 6 + snforge_std/Scarb.toml | 2 +- 64 files changed, 709 insertions(+), 591 deletions(-) create mode 100644 crates/cheatnet/tests/contracts/Scarb.lock create mode 100644 snforge_std/Scarb.lock diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa5e4800af..0c0375711a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: test-forge-unit-and-integration: name: Test Forge / Unit and Integration Tests env: - SCARB_VERSION: 0.7.0 + SCARB_VERSION: 2.3.0 runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -29,7 +29,7 @@ jobs: test-forge-e2e: name: Test Forge / E2E Tests env: - SCARB_VERSION: 0.7.0 + SCARB_VERSION: 2.3.0 runs-on: ubuntu-latest steps: - name: Extract branch name @@ -67,7 +67,7 @@ jobs: test-cheatnet: name: Test Cheatnet env: - SCARB_VERSION: 0.7.0 + SCARB_VERSION: 2.3.0 runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.gitignore b/.gitignore index cc08810b23..8071a9ee87 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,6 @@ pyproject.toml target .vscode/ .env +Scarb.lock +!snforge_std/Scarb.lock */node_modules diff --git a/CHANGELOG.md b/CHANGELOG.md index 81285f4a16..81f8fd847d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 #### Changed +- updated Cairo version to 2.3.0 - compatible Scarb version is 2.3.0: + - tests in `src` folder now have to be in a module annotated with `#[cfg(test)]` - `snforge_std::PrintTrait` will not convert values representing ASCII control characters to strings - separated `snforge` to subcommands: `snforge test`, `snforge init` and `snforge clean-cache`. Read more [here](https://foundry-rs.github.io/starknet-foundry/appendix/forge.html). diff --git a/Cargo.lock b/Cargo.lock index 30caaed6ff..bea567af7b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -565,9 +565,9 @@ dependencies = [ [[package]] name = "cairo-lang-casm" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc7f7cb89bc3f52c2c738f3e87c8f8773bd3456cae1d322d100d4b0da584f3c" +checksum = "4b89fd5edce5c0b128fa25f76f07db322ae9b28c123619ddcd11df18a73d3217" dependencies = [ "cairo-lang-utils", "indoc", @@ -582,9 +582,9 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4f2c54b065f7fd97bf8d5df76cbcbbd01d8a8c319d281796ee20ecc48e16ca8" +checksum = "7fc2689f520038019ddc8884ee36f6df04a66fe46906c9d1ac76e8e9675e55f0" dependencies = [ "anyhow", "cairo-lang-defs", @@ -600,26 +600,24 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "itertools 0.11.0", - "log", "salsa", - "smol_str", "thiserror", ] [[package]] name = "cairo-lang-debug" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "873ba77d4c3f780c727c7d6c738cded22b3f6d4023e30546dfe14f97a087887e" +checksum = "3544967c563b53066163794d3c400270faf4617cfdd33ba1f74296efdca14e9d" dependencies = [ "cairo-lang-utils", ] [[package]] name = "cairo-lang-defs" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5031fff038c27ed43769b73a6f5d41aeaea34df9af862e024c23fbb4f076249" +checksum = "a07a54c419c573bc2610c2b3d672420723ca38b79a4cae2f24e0287173524e18" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -627,7 +625,6 @@ dependencies = [ "cairo-lang-parser", "cairo-lang-syntax", "cairo-lang-utils", - "indexmap 2.0.0", "itertools 0.11.0", "salsa", "smol_str", @@ -635,34 +632,31 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b6cb1492e5784e1076320a5018ce7584f391b2f3b414bc0a8ab7c289fa118ce" +checksum = "82dc3934a47960155812cc181e7e2a3d48f2df447c23fcdbecff966855244162" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", "cairo-lang-utils", "itertools 0.11.0", - "salsa", ] [[package]] name = "cairo-lang-eq-solver" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c35dddbc63b2a4870891cc74498726aa32bfaa518596352f9bb101411cc4c584" +checksum = "2f944eae57f6c31fa0157811117b584cba4556770e2e5db4fd856459b877680f" dependencies = [ "cairo-lang-utils", "good_lp", - "indexmap 2.0.0", - "itertools 0.11.0", ] [[package]] name = "cairo-lang-filesystem" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32ce0b8e66a6085ae157d43b5c162d60166f0027d6f125c50ee74e4dc7916ff6" +checksum = "79b9b4f02ee6da5526a58b054dae3dce8ff592ae5e740c1d028ebd7e8218e1dc" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -674,9 +668,9 @@ dependencies = [ [[package]] name = "cairo-lang-lowering" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29cc679f501725e03ee703559ed27d084c6f4031bd51ff86378cf845a85ee207" +checksum = "f5654b46630d3e8e740ebb058d344aa62ca92c5b1cbc5febbb993abe1ab622cb" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -695,14 +689,13 @@ dependencies = [ "num-traits 0.2.16", "once_cell", "salsa", - "smol_str", ] [[package]] name = "cairo-lang-parser" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdcadb046659134466bc7e11961ea8a56969dae8a54d8f985955ce0b95185c7f" +checksum = "1f42707f9db24a7c15b82b1d26615c3038323b6136c76739622ea3a3877a8ed7" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -711,7 +704,6 @@ dependencies = [ "cairo-lang-utils", "colored", "itertools 0.11.0", - "log", "num-bigint", "num-traits 0.2.16", "salsa", @@ -721,9 +713,9 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4632790cd4ea11d4849934456a400eae7ed419f6d721f24a6b637df67b7e902f" +checksum = "11b58c906cfb2d64ab630c1417a9dac15dea0859978cc5b2b61dab7fa098a9b9" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -734,16 +726,15 @@ dependencies = [ "indent", "indoc", "itertools 0.11.0", - "num-bigint", "salsa", "smol_str", ] [[package]] name = "cairo-lang-proc-macros" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "170838817fc33ddb65e0a9480526df0b226b148a0fca0a5cd7071be4c6683157" +checksum = "178c68268a904eba03c07714b2c29d1f97d6754e74931f5d465961f901a88d59" dependencies = [ "cairo-lang-debug", "quote", @@ -752,9 +743,9 @@ dependencies = [ [[package]] name = "cairo-lang-project" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4162ee976c61fdeb3b621f4a76fd256e46a5c0890f750a3a9d2c9560a3bc1daf" +checksum = "f5eb369e0b51a8f03ad92dc2981387cb9b35cba6d117271ef307a14a14ff58b0" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", @@ -766,27 +757,19 @@ dependencies = [ [[package]] name = "cairo-lang-runner" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d66ef01350e2e7f7e6b2b43b865da2513a42600082ee1a2975d3af3da7f0ca" +checksum = "b53180d68de6d6b1e48585ec783bc930b65486856d69adb6bd7277c2a064fc2b" dependencies = [ - "anyhow", "ark-ff", "ark-secp256k1", "ark-secp256r1", "ark-std", "cairo-felt", "cairo-lang-casm", - "cairo-lang-compiler", - "cairo-lang-defs", - "cairo-lang-diagnostics", - "cairo-lang-filesystem", - "cairo-lang-lowering", - "cairo-lang-semantic", "cairo-lang-sierra", "cairo-lang-sierra-ap-change", "cairo-lang-sierra-gas", - "cairo-lang-sierra-generator", "cairo-lang-sierra-to-casm", "cairo-lang-sierra-type-size", "cairo-lang-starknet", @@ -797,28 +780,25 @@ dependencies = [ "num-bigint", "num-integer", "num-traits 0.2.16", - "salsa", "thiserror", ] [[package]] name = "cairo-lang-semantic" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e544fa9a222bf2d007df2b5fc9b21c2a20ab7e17d6fefbcbc193de209451cd" +checksum = "7564b5ea75237c83b6b7e39d9177fcf13f34f035bf8bd5f659198ac8f6ee78b9" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", "cairo-lang-diagnostics", "cairo-lang-filesystem", "cairo-lang-parser", - "cairo-lang-plugins", "cairo-lang-proc-macros", "cairo-lang-syntax", "cairo-lang-utils", "id-arena", "itertools 0.11.0", - "log", "num-bigint", "num-traits 0.2.16", "once_cell", @@ -828,10 +808,11 @@ dependencies = [ [[package]] name = "cairo-lang-sierra" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5e136b79e95a14ef38a2be91a67ceb85317407d336a5b0d418c33b23c78596a" +checksum = "ada598c1f7a7c343cf5d604c0f028000fcc17d67c036d797d5cd3b7fd8777e1a" dependencies = [ + "anyhow", "cairo-lang-utils", "const-fnv1a-hash", "convert_case 0.6.0", @@ -851,9 +832,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "511ca7708faa7ba8d14ae26e1d60ead2d02028c8f664baf5ecb0fd6a0d1e20f6" +checksum = "00cf99976ca90ceeb11895521feb34b1be8e0f98b6ca79e9a4018148d7ff7888" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -865,9 +846,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "351a25bc010b910919c01d5c57e937b0c3d330fc30d92702c0cb4061819df8df" +checksum = "0f64f8d381ef4f97ecdbfae7f9f77fe6aa18191696e52b112e53c75a84af7e84" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -879,9 +860,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "114091bb971c06fd072aca816af1c3f62566cd8a4b1453c786155161a36c7bce" +checksum = "dfee5967e7967c71cee15f545faf5288a9c6046c60ecff89748c65d9654a7be4" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -889,14 +870,10 @@ dependencies = [ "cairo-lang-filesystem", "cairo-lang-lowering", "cairo-lang-parser", - "cairo-lang-plugins", - "cairo-lang-proc-macros", "cairo-lang-semantic", "cairo-lang-sierra", "cairo-lang-syntax", "cairo-lang-utils", - "id-arena", - "indexmap 2.0.0", "itertools 0.11.0", "num-bigint", "once_cell", @@ -906,9 +883,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa1c799de62972dfd7112d563000695be94305b6f7d9bedd29f347799bf03e1c" +checksum = "4af7d2812d283b63f074a1ab4135fe0db586bf1b5edaa7ef2129f3067c9e894a" dependencies = [ "assert_matches", "cairo-felt", @@ -920,7 +897,6 @@ dependencies = [ "cairo-lang-utils", "indoc", "itertools 0.11.0", - "log", "num-bigint", "num-traits 0.2.16", "thiserror", @@ -928,9 +904,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-type-size" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fe73d9d58aaf9088f6ba802bcf43ce9ca4bd198190cf5bf91caa7d408dd11a" +checksum = "8b753a6569f903c3637dda7ef944455a91b2b004f5294262ab1e823914ea65e5" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -938,9 +914,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75df624e71e33a31a924e799dd2a9a8284204b41d8db9c51803317bd9edff81f" +checksum = "6866e7599234986acb221cbc5a9720731e4b6d068e87ce07d6437e51f8fc8a24" dependencies = [ "anyhow", "cairo-felt", @@ -950,22 +926,17 @@ dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", "cairo-lang-lowering", - "cairo-lang-parser", - "cairo-lang-plugins", "cairo-lang-semantic", "cairo-lang-sierra", - "cairo-lang-sierra-ap-change", - "cairo-lang-sierra-gas", "cairo-lang-sierra-generator", "cairo-lang-sierra-to-casm", "cairo-lang-syntax", "cairo-lang-utils", + "const_format", "convert_case 0.6.0", - "genco", "indent", "indoc", "itertools 0.11.0", - "log", "num-bigint", "num-integer", "num-traits 0.2.16", @@ -979,9 +950,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b1af0ae21f9e539f97cfdf56f5ce0934dae5d87f568fd778c3d624a102f8dbb" +checksum = "b91c81cd720549131e80598172d6a9db3d62795ab6be1060b7efed463c793bd1" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -990,15 +961,14 @@ dependencies = [ "num-traits 0.2.16", "salsa", "smol_str", - "thiserror", "unescaper", ] [[package]] name = "cairo-lang-syntax-codegen" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "822ffabf24f6a5506262edcece315260a82d9dfba3abe6548791a6d654563ad0" +checksum = "04f2e93b768bf5fff62bcd445fda45c98cdb4e58a81b2095bda01cdbf00e2e6a" dependencies = [ "genco", "xshell", @@ -1006,14 +976,13 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f974b6e859f0b09c0f13ec8188c96e9e8bbb5da04214f911dbb5bcda67cb812b" +checksum = "3a676a06f80da115e9ef2669e708ee3d2a495224ebc6e5464e8d6132d0e8266b" dependencies = [ "indexmap 2.0.0", "itertools 0.11.0", "num-bigint", - "num-integer", "num-traits 0.2.16", "parity-scale-codec", "schemars", @@ -1260,6 +1229,26 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32b13ea120a812beba79e34316b3942a857c86ec1593cb34f27bb28272ce2cca" +[[package]] +name = "const_format" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a214c7af3d04997541b18d432afaff4c455e79e2029079647e72fc2bd27673" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f6ff08fd20f4f299298a28e2dfa8a8ba1036e6cd2460ac1de7b425d76f2500" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + [[package]] name = "conversions" version = "1.0.0" diff --git a/Cargo.toml b/Cargo.toml index a9836c23f9..890a268553 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,25 +18,25 @@ license-file = "LICENSE" [workspace.dependencies] blockifier = { git = "https://github.com/starkware-libs/blockifier.git", rev = "ea6a3f7" } starknet_api = "0.4.1" -cairo-lang-casm = "2.2.0" -cairo-lang-runner = "2.2.0" -cairo-lang-sierra-to-casm = "2.2.0" -cairo-lang-sierra = "2.2.0" -cairo-lang-utils = "2.2.0" -cairo-lang-starknet = "2.2.0" -cairo-lang-compiler = "2.2.0" -cairo-lang-filesystem = "2.2.0" -cairo-lang-debug = "2.2.0" -cairo-lang-defs = "2.2.0" -cairo-lang-diagnostics = "2.2.0" -cairo-lang-lowering = "2.2.0" -cairo-lang-plugins = "2.2.0" -cairo-lang-project = "2.2.0" -cairo-lang-semantic = "2.2.0" -cairo-lang-sierra-ap-change = "2.2.0" -cairo-lang-sierra-gas = "2.2.0" -cairo-lang-sierra-generator = "2.2.0" -cairo-lang-syntax = "2.2.0" +cairo-lang-casm = "2.3.0" +cairo-lang-runner = "2.3.0" +cairo-lang-sierra-to-casm = "2.3.0" +cairo-lang-sierra = "2.3.0" +cairo-lang-utils = "2.3.0" +cairo-lang-starknet = "2.3.0" +cairo-lang-compiler = "2.3.0" +cairo-lang-filesystem = "2.3.0" +cairo-lang-debug = "2.3.0" +cairo-lang-defs = "2.3.0" +cairo-lang-diagnostics = "2.3.0" +cairo-lang-lowering = "2.3.0" +cairo-lang-plugins = "2.3.0" +cairo-lang-project = "2.3.0" +cairo-lang-semantic = "2.3.0" +cairo-lang-sierra-ap-change = "2.3.0" +cairo-lang-sierra-gas = "2.3.0" +cairo-lang-sierra-generator = "2.3.0" +cairo-lang-syntax = "2.3.0" cairo-vm = "0.8.2" cairo-felt = "0.8.2" anyhow = "1.0.75" diff --git a/benchmarks/data/project/Scarb.toml b/benchmarks/data/project/Scarb.toml index 0c0441faab..0710b467f7 100644 --- a/benchmarks/data/project/Scarb.toml +++ b/benchmarks/data/project/Scarb.toml @@ -5,7 +5,7 @@ version = "0.1.0" # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html [dependencies] -starknet = "2.2.0" +starknet = "2.3.0" [[target.starknet-contract]] sierra = true diff --git a/crates/cheatnet/tests/cheatcodes/declare.rs b/crates/cheatnet/tests/cheatcodes/declare.rs index fba18a75d0..6703cf9c2f 100644 --- a/crates/cheatnet/tests/cheatcodes/declare.rs +++ b/crates/cheatnet/tests/cheatcodes/declare.rs @@ -7,9 +7,9 @@ use starknet_api::hash::StarkFelt; use starknet_api::stark_felt; static HELLO_STARKNET_CLASS_HASH: &str = - "0x298f80e468953d1e65314b6bc63347c7a3fe454a89c2b15387dd52ee281d103"; + "0x05ecd2c5f5ca68a4dc1b945582c69434adfc8bedbd188f0146a35875a4791936"; static CONSTRUCTOR_SIMPLE_CLASS_HASH: &str = - "0x02dbeae7583f3dd4af0bc2da4d58611433165fec7e31245bfa2f1378fbff6a4c"; + "0x05f5abdb98a7ec93a20ac4b2ed284979613bc71f2dec3df10e589ebe40c562b4"; #[test] fn declare_simple() { diff --git a/crates/cheatnet/tests/contracts/Scarb.lock b/crates/cheatnet/tests/contracts/Scarb.lock new file mode 100644 index 0000000000..a6eeffb79b --- /dev/null +++ b/crates/cheatnet/tests/contracts/Scarb.lock @@ -0,0 +1,6 @@ +# Code generated by scarb DO NOT EDIT. +version = 1 + +[[package]] +name = "cheatnet_testing_contracts" +version = "0.1.0" diff --git a/crates/cheatnet/tests/contracts/Scarb.toml b/crates/cheatnet/tests/contracts/Scarb.toml index f77c92e5f3..c32bc3e0f3 100644 --- a/crates/cheatnet/tests/contracts/Scarb.toml +++ b/crates/cheatnet/tests/contracts/Scarb.toml @@ -9,7 +9,7 @@ sierra = true casm = true [dependencies] -starknet = "2.2.0" +starknet = "2.3.0" [tool.snforge] # exit_first = true diff --git a/crates/forge/src/scarb.rs b/crates/forge/src/scarb.rs index 11e335d5f7..88a8213322 100644 --- a/crates/forge/src/scarb.rs +++ b/crates/forge/src/scarb.rs @@ -307,7 +307,7 @@ mod tests { casm = true [dependencies] - starknet = "2.2.0" + starknet = "2.3.0" snforge_std = {{ path = "{}" }} [[tool.snforge.fork]] @@ -376,7 +376,7 @@ mod tests { version = "0.1.0" [dependencies] - starknet = "2.2.0" + starknet = "2.3.0" snforge_std = {{ path = "{}" }} [[target.starknet-contract]] @@ -505,19 +505,24 @@ mod tests { assert!(contracts.contains_key("HelloStarknet")); let sierra_contents_erc20 = - fs::read_to_string(temp.join("target/dev/simple_package_ERC20.sierra.json")).unwrap(); - let casm_contents_erc20 = - fs::read_to_string(temp.join("target/dev/simple_package_ERC20.casm.json")).unwrap(); + fs::read_to_string(temp.join("target/dev/simple_package_ERC20.contract_class.json")) + .unwrap(); + let casm_contents_erc20 = fs::read_to_string( + temp.join("target/dev/simple_package_ERC20.compiled_contract_class.json"), + ) + .unwrap(); let contract = contracts.get("ERC20").unwrap(); assert_eq!(&sierra_contents_erc20, &contract.sierra); assert_eq!(&casm_contents_erc20, &contract.casm); - let sierra_contents_erc20 = - fs::read_to_string(temp.join("target/dev/simple_package_HelloStarknet.sierra.json")) - .unwrap(); - let casm_contents_erc20 = - fs::read_to_string(temp.join("target/dev/simple_package_HelloStarknet.casm.json")) - .unwrap(); + let sierra_contents_erc20 = fs::read_to_string( + temp.join("target/dev/simple_package_HelloStarknet.contract_class.json"), + ) + .unwrap(); + let casm_contents_erc20 = fs::read_to_string( + temp.join("target/dev/simple_package_HelloStarknet.compiled_contract_class.json"), + ) + .unwrap(); let contract = contracts.get("HelloStarknet").unwrap(); assert_eq!(&sierra_contents_erc20, &contract.sierra); assert_eq!(&casm_contents_erc20, &contract.casm); diff --git a/crates/forge/tests/data/collection_with_lib/src/fab.cairo b/crates/forge/tests/data/collection_with_lib/src/fab.cairo index 29f0ad4c48..cf1bf2f104 100644 --- a/crates/forge/tests/data/collection_with_lib/src/fab.cairo +++ b/crates/forge/tests/data/collection_with_lib/src/fab.cairo @@ -4,7 +4,10 @@ fn fn_from_above() -> felt252 { 1 } -#[test] -fn test_simple() { - assert(1 == 1, 1); +#[cfg(test)] +mod tests { + #[test] + fn test_simple() { + assert(1 == 1, 1); + } } diff --git a/crates/forge/tests/data/collection_with_lib/src/fab/fab_impl.cairo b/crates/forge/tests/data/collection_with_lib/src/fab/fab_impl.cairo index f3c23206f2..288f95bf5d 100644 --- a/crates/forge/tests/data/collection_with_lib/src/fab/fab_impl.cairo +++ b/crates/forge/tests/data/collection_with_lib/src/fab/fab_impl.cairo @@ -8,18 +8,23 @@ fn fab_fn(a: felt252, b: felt252, n: felt252) -> felt252 { } } -#[test] -fn test_fab() { - assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); -} +#[cfg(test)] +mod tests { + use super::{fab_fn, fib_fn, fn_from_above}; -#[test] -fn test_how_does_this_work() { - assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); -} + #[test] + fn test_fab() { + assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); + } -#[test] -fn test_super() { - let one: felt252 = 1; - assert(fn_from_above() == one, 1); + #[test] + fn test_how_does_this_work() { + assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); + } + + #[test] + fn test_super() { + let one: felt252 = 1; + assert(fn_from_above() == one, 1); + } } diff --git a/crates/forge/tests/data/collection_with_lib/src/fab/fibfabfob.cairo b/crates/forge/tests/data/collection_with_lib/src/fab/fibfabfob.cairo index 5a2087c02c..c7b3655b7a 100644 --- a/crates/forge/tests/data/collection_with_lib/src/fab/fibfabfob.cairo +++ b/crates/forge/tests/data/collection_with_lib/src/fab/fibfabfob.cairo @@ -4,17 +4,22 @@ use collection_with_lib::fob::fob_impl::fob_fn; use collection_with_lib::fab::fab_impl::fab_fn; use collection_with_lib::fib::fib_fn; -#[test] -fn test_fib() { - assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); -} +#[cfg(test)] +mod tests { + use super::{fib_fn, fob_fb, fab_fn}; -#[test] -fn test_fob() { - assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); -} + #[test] + fn test_fib() { + assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); + } -#[test] -fn test_fab() { - assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); -} + #[test] + fn test_fob() { + assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); + } + + #[test] + fn test_fab() { + assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); + } +} \ No newline at end of file diff --git a/crates/forge/tests/data/collection_with_lib/src/fib.cairo b/crates/forge/tests/data/collection_with_lib/src/fib.cairo index 06486b5b20..9bc48da65e 100644 --- a/crates/forge/tests/data/collection_with_lib/src/fib.cairo +++ b/crates/forge/tests/data/collection_with_lib/src/fib.cairo @@ -8,17 +8,22 @@ fn fib_fn(a: felt252, b: felt252, n: felt252) -> felt252 { } } -#[test] -fn test_fib() { - assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); -} +#[cfg(test)] +mod tests { + use super::{fib_fn, fob_fn, fab_fn}; -#[test] -fn test_fob_in_fib() { - assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); -} + #[test] + fn test_fib() { + assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); + } -#[test] -fn test_fab_in_fib() { - assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); -} + #[test] + fn test_fob_in_fib() { + assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); + } + + #[test] + fn test_fab_in_fib() { + assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); + } +} \ No newline at end of file diff --git a/crates/forge/tests/data/collection_with_lib/src/fob.cairo b/crates/forge/tests/data/collection_with_lib/src/fob.cairo index 5194d6cc68..6adb547ccb 100644 --- a/crates/forge/tests/data/collection_with_lib/src/fob.cairo +++ b/crates/forge/tests/data/collection_with_lib/src/fob.cairo @@ -1,6 +1,9 @@ mod fob_impl; -#[test] -fn test_simple() { - assert(1 == 1, 1); +#[cfg(test)] +mod tests { + #[test] + fn test_simple() { + assert(1 == 1, 1); + } } diff --git a/crates/forge/tests/data/collection_with_lib/src/fob/fibfabfob.cairo b/crates/forge/tests/data/collection_with_lib/src/fob/fibfabfob.cairo index 5a2087c02c..0b1e57e603 100644 --- a/crates/forge/tests/data/collection_with_lib/src/fob/fibfabfob.cairo +++ b/crates/forge/tests/data/collection_with_lib/src/fob/fibfabfob.cairo @@ -4,17 +4,23 @@ use collection_with_lib::fob::fob_impl::fob_fn; use collection_with_lib::fab::fab_impl::fab_fn; use collection_with_lib::fib::fib_fn; -#[test] -fn test_fib() { - assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); -} -#[test] -fn test_fob() { - assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); -} +#[cfg(test)] +mod tests { + use super::{fib_fn, fob_fn, fab_fn}; + + #[test] + fn test_fib() { + assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); + } + + #[test] + fn test_fob() { + assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); + } -#[test] -fn test_fab() { - assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); + #[test] + fn test_fab() { + assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); + } } diff --git a/crates/forge/tests/data/collection_with_lib/src/fob/fob_impl.cairo b/crates/forge/tests/data/collection_with_lib/src/fob/fob_impl.cairo index 918811c944..4b213a7d1e 100644 --- a/crates/forge/tests/data/collection_with_lib/src/fob/fob_impl.cairo +++ b/crates/forge/tests/data/collection_with_lib/src/fob/fob_impl.cairo @@ -5,7 +5,12 @@ fn fob_fn(a: felt252, b: felt252, n: felt252) -> felt252 { } } -#[test] -fn test_fob() { - assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); +#[cfg(test)] +mod tests { + use super::fob_fn; + + #[test] + fn test_fob() { + assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); + } } diff --git a/crates/forge/tests/data/collection_with_lib/src/lib.cairo b/crates/forge/tests/data/collection_with_lib/src/lib.cairo index c3d41a5c3b..6c3744bc7c 100644 --- a/crates/forge/tests/data/collection_with_lib/src/lib.cairo +++ b/crates/forge/tests/data/collection_with_lib/src/lib.cairo @@ -5,17 +5,21 @@ mod fab; use fob::fob_impl::fob_fn; use fib::fib_fn; -#[test] -fn test_simple() { - assert(1 == 1, 1); -} +#[cfg(test)] +mod tests { + use super::{fob_fn, fib_fn}; + #[test] + fn test_simple() { + assert(1 == 1, 1); + } -#[test] -fn test_fob_in_lib() { - assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); -} + #[test] + fn test_fob_in_lib() { + assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); + } -#[test] -fn test_fib_in_lib() { - assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); + #[test] + fn test_fib_in_lib() { + assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); + } } diff --git a/crates/forge/tests/data/collection_without_lib/src/fab.cairo b/crates/forge/tests/data/collection_without_lib/src/fab.cairo index 29f0ad4c48..cf1bf2f104 100644 --- a/crates/forge/tests/data/collection_without_lib/src/fab.cairo +++ b/crates/forge/tests/data/collection_without_lib/src/fab.cairo @@ -4,7 +4,10 @@ fn fn_from_above() -> felt252 { 1 } -#[test] -fn test_simple() { - assert(1 == 1, 1); +#[cfg(test)] +mod tests { + #[test] + fn test_simple() { + assert(1 == 1, 1); + } } diff --git a/crates/forge/tests/data/collection_without_lib/src/fab/fab_impl.cairo b/crates/forge/tests/data/collection_without_lib/src/fab/fab_impl.cairo index aa7e3884f2..434890bef5 100644 --- a/crates/forge/tests/data/collection_without_lib/src/fab/fab_impl.cairo +++ b/crates/forge/tests/data/collection_without_lib/src/fab/fab_impl.cairo @@ -8,18 +8,23 @@ fn fab_fn(a: felt252, b: felt252, n: felt252) -> felt252 { } } -#[test] -fn test_fab() { - assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); -} +#[cfg(test)] +mod tests { + use super::{fab_fn, fib_fn, fn_from_above}; -#[test] -fn test_how_does_this_work() { - assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); -} + #[test] + fn test_fab() { + assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); + } -#[test] -fn test_super() { - let one: felt252 = 1; - assert(fn_from_above() == one, 1); + #[test] + fn test_how_does_this_work() { + assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); + } + + #[test] + fn test_super() { + let one: felt252 = 1; + assert(fn_from_above() == one, 1); + } } diff --git a/crates/forge/tests/data/collection_without_lib/src/fab/fibfabfob.cairo b/crates/forge/tests/data/collection_without_lib/src/fab/fibfabfob.cairo index 6559f0e728..eb8f37a32c 100644 --- a/crates/forge/tests/data/collection_without_lib/src/fab/fibfabfob.cairo +++ b/crates/forge/tests/data/collection_without_lib/src/fab/fibfabfob.cairo @@ -4,17 +4,22 @@ use collection_without_lib::fob::fob_impl::fob_fn; use collection_without_lib::fab::fab_impl::fab_fn; use collection_without_lib::fib::fib_fn; -#[test] -fn test_fib() { - assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); -} +#[cfg(test)] +mod tests { + use super::{fib_fn, fob_fb, fab_fn}; -#[test] -fn test_fob() { - assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); -} + #[test] + fn test_fib() { + assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); + } + + #[test] + fn test_fob() { + assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); + } -#[test] -fn test_fab() { - assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); + #[test] + fn test_fab() { + assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); + } } diff --git a/crates/forge/tests/data/collection_without_lib/src/fib.cairo b/crates/forge/tests/data/collection_without_lib/src/fib.cairo index 96e86541c0..87ba09e55a 100644 --- a/crates/forge/tests/data/collection_without_lib/src/fib.cairo +++ b/crates/forge/tests/data/collection_without_lib/src/fib.cairo @@ -8,17 +8,22 @@ fn fib_fn(a: felt252, b: felt252, n: felt252) -> felt252 { } } -#[test] -fn test_fib() { - assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); -} +#[cfg(test)] +mod tests { + use super::{fib_fn, fob_fn, fab_fn}; -#[test] -fn test_fob_in_fib() { - assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); -} + #[test] + fn test_fib() { + assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); + } -#[test] -fn test_fab_in_fib() { - assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); + #[test] + fn test_fob_in_fib() { + assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); + } + + #[test] + fn test_fab_in_fib() { + assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); + } } diff --git a/crates/forge/tests/data/collection_without_lib/src/fob.cairo b/crates/forge/tests/data/collection_without_lib/src/fob.cairo index 5194d6cc68..6adb547ccb 100644 --- a/crates/forge/tests/data/collection_without_lib/src/fob.cairo +++ b/crates/forge/tests/data/collection_without_lib/src/fob.cairo @@ -1,6 +1,9 @@ mod fob_impl; -#[test] -fn test_simple() { - assert(1 == 1, 1); +#[cfg(test)] +mod tests { + #[test] + fn test_simple() { + assert(1 == 1, 1); + } } diff --git a/crates/forge/tests/data/collection_without_lib/src/fob/fibfabfob.cairo b/crates/forge/tests/data/collection_without_lib/src/fob/fibfabfob.cairo index 6559f0e728..01d3b744c1 100644 --- a/crates/forge/tests/data/collection_without_lib/src/fob/fibfabfob.cairo +++ b/crates/forge/tests/data/collection_without_lib/src/fob/fibfabfob.cairo @@ -4,17 +4,23 @@ use collection_without_lib::fob::fob_impl::fob_fn; use collection_without_lib::fab::fab_impl::fab_fn; use collection_without_lib::fib::fib_fn; -#[test] -fn test_fib() { - assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); -} -#[test] -fn test_fob() { - assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); -} +#[cfg(test)] +mod tests { + use super::{fib_fn, fob_fn, fab_fn}; + + #[test] + fn test_fib() { + assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); + } + + #[test] + fn test_fob() { + assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); + } -#[test] -fn test_fab() { - assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); + #[test] + fn test_fab() { + assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); + } } diff --git a/crates/forge/tests/data/collection_without_lib/src/fob/fob_impl.cairo b/crates/forge/tests/data/collection_without_lib/src/fob/fob_impl.cairo index 918811c944..4b213a7d1e 100644 --- a/crates/forge/tests/data/collection_without_lib/src/fob/fob_impl.cairo +++ b/crates/forge/tests/data/collection_without_lib/src/fob/fob_impl.cairo @@ -5,7 +5,12 @@ fn fob_fn(a: felt252, b: felt252, n: felt252) -> felt252 { } } -#[test] -fn test_fob() { - assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); +#[cfg(test)] +mod tests { + use super::fob_fn; + + #[test] + fn test_fob() { + assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); + } } diff --git a/crates/forge/tests/data/collection_without_lib/src/lib.cairo b/crates/forge/tests/data/collection_without_lib/src/lib.cairo index c3d41a5c3b..6c3744bc7c 100644 --- a/crates/forge/tests/data/collection_without_lib/src/lib.cairo +++ b/crates/forge/tests/data/collection_without_lib/src/lib.cairo @@ -5,17 +5,21 @@ mod fab; use fob::fob_impl::fob_fn; use fib::fib_fn; -#[test] -fn test_simple() { - assert(1 == 1, 1); -} +#[cfg(test)] +mod tests { + use super::{fob_fn, fib_fn}; + #[test] + fn test_simple() { + assert(1 == 1, 1); + } -#[test] -fn test_fob_in_lib() { - assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); -} + #[test] + fn test_fob_in_lib() { + assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); + } -#[test] -fn test_fib_in_lib() { - assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); + #[test] + fn test_fib_in_lib() { + assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); + } } diff --git a/crates/forge/tests/data/contract_printing/Scarb.toml b/crates/forge/tests/data/contract_printing/Scarb.toml index a1383e3ee5..80de193392 100644 --- a/crates/forge/tests/data/contract_printing/Scarb.toml +++ b/crates/forge/tests/data/contract_printing/Scarb.toml @@ -10,7 +10,7 @@ casm = true allowed-libfuncs-deny = false [dependencies] -starknet = "2.2.0" +starknet = "2.3.0" snforge_std = { path = "../../../../../snforge_std" } [tool.snforge] diff --git a/crates/forge/tests/data/diagnostics_and_plugins/src/lib.cairo b/crates/forge/tests/data/diagnostics_and_plugins/src/lib.cairo index b20ebaed88..9f254926ac 100644 --- a/crates/forge/tests/data/diagnostics_and_plugins/src/lib.cairo +++ b/crates/forge/tests/data/diagnostics_and_plugins/src/lib.cairo @@ -1,5 +1,8 @@ -#[test] -#[fork(url: "https://lib.com")] -fn incorrect_fork_attributes() { - assert(1 == 1, 'ok') +#[cfg(test)] + mod tests { + #[test] + #[fork(url: "https://lib.com")] + fn incorrect_fork_attributes() { + assert(1 == 1, 'ok') + } } diff --git a/crates/forge/tests/data/env/src/lib.cairo b/crates/forge/tests/data/env/src/lib.cairo index c94dece5f7..d9503a4fc7 100644 --- a/crates/forge/tests/data/env/src/lib.cairo +++ b/crates/forge/tests/data/env/src/lib.cairo @@ -1,10 +1,13 @@ -use snforge_std::env::var; +#[cfg(test)] +mod tests { + use snforge_std::env::var; -#[test] -fn reading_env_vars() { - let felt252_value = var('FELT_ENV_VAR'); - let short_string_value = var('STRING_ENV_VAR'); + #[test] + fn reading_env_vars() { + let felt252_value = var('FELT_ENV_VAR'); + let short_string_value = var('STRING_ENV_VAR'); - assert(felt252_value == 987654321, 'invalid felt value'); - assert(short_string_value == 'abcde', 'invalid short string value'); + assert(felt252_value == 987654321, 'invalid felt value'); + assert(short_string_value == 'abcde', 'invalid short string value'); + } } diff --git a/crates/forge/tests/data/exit_first/Scarb.toml b/crates/forge/tests/data/exit_first/Scarb.toml index 90d96a2cfc..a858940b1b 100644 --- a/crates/forge/tests/data/exit_first/Scarb.toml +++ b/crates/forge/tests/data/exit_first/Scarb.toml @@ -3,7 +3,7 @@ name = "exit_first" version = "0.1.0" [dependencies] -starknet = "2.2.0" +starknet = "2.3.0" snforge_std = { path = "../../../../../snforge_std" } [[target.starknet-contract]] diff --git a/crates/forge/tests/data/file_reading/Scarb.toml b/crates/forge/tests/data/file_reading/Scarb.toml index 6c18c53745..5d3baf2858 100644 --- a/crates/forge/tests/data/file_reading/Scarb.toml +++ b/crates/forge/tests/data/file_reading/Scarb.toml @@ -7,5 +7,5 @@ sierra = true casm = true [dependencies] -starknet = "2.2.0" +starknet = "2.3.0" snforge_std = { path = "../../../../../snforge_std" } diff --git a/crates/forge/tests/data/file_reading/src/lib.cairo b/crates/forge/tests/data/file_reading/src/lib.cairo index 2a7edb9d18..24e20bd703 100644 --- a/crates/forge/tests/data/file_reading/src/lib.cairo +++ b/crates/forge/tests/data/file_reading/src/lib.cairo @@ -1,135 +1,138 @@ -use snforge_std::fs::{FileTrait, read_txt, FileParser}; -use array::ArrayTrait; -use option::OptionTrait; -use serde::Serde; - -fn compare_with_expected_content(content: Array) { - let expected = array![ - 1, - 'hello', - 3, - 'world', - 0, - 3618502788666131213697322783095070105623107215331596699973092056135872020480 - ]; - - assert(content.len() == expected.len(), 'lengths not equal'); - let mut i = 0; - loop { - if i == content.len() { - break; - } - assert(*content[i] == *expected[i], 'unexpected content'); - i += 1; - }; -} - -#[derive(Serde, Drop, PartialEq)] -struct A { - a: u32, - nested_b: B, - nested_d: D, - f: felt252 -} - -#[derive(Serde, Drop, PartialEq)] -struct B { - nested_c: C, -} - -#[derive(Serde, Drop, PartialEq)] -struct C { - c: u256 -} - -#[derive(Serde, Drop, PartialEq)] -struct D { - d: u64, - e: u8 -} - -#[test] -fn valid_content_and_same_content_no_matter_whitespaces() { - let file = FileTrait::new('data/valid.txt'); - let content = FileParser::::parse_txt(@file).unwrap(); - let expected = A { - a: 1, nested_b: B { - nested_c: C { c: u256 { low: 'hello', high: 3 } } - }, nested_d: D { - d: 'world', e: 0 - }, f: 3618502788666131213697322783095070105623107215331596699973092056135872020480, - }; - assert(content.f == expected.f, '') -} - -#[test] -fn serialization() { - let file = FileTrait::new('data/valid.txt'); - let content = read_txt(@file); - compare_with_expected_content(content); - - let file = FileTrait::new('data/valid_diff_spaces.txt'); - let content = read_txt(@file); - compare_with_expected_content(content); -} - -#[test] -fn valid_content_different_folder() { - let file = FileTrait::new('valid_file.txt'); - let content = read_txt(@file); - let expected = array!['123', '12dsfwe', 124]; - - assert(content.len() == expected.len(), 'lengths not equal'); - let mut i = 0; - loop { - if i == content.len() { - break; - } - assert(*content[i] == *expected[i], 'unexpected content'); - i += 1; - }; - - assert(1 == 1, ''); -} - -#[test] -fn non_existent() { - let file = FileTrait::new('data/non_existent.txt'); - let content = read_txt(@file); - assert(1 == 1, ''); -} - -#[test] -fn invalid_quotes() { - let file = FileTrait::new('data/invalid_quotes.txt'); - let content = read_txt(@file); - assert(1 == 1, ''); -} - -#[test] -fn negative_number() { - let file = FileTrait::new('data/negative_number.txt'); - let content = read_txt(@file); - assert(1 == 1, ''); -} - -#[test] -fn non_ascii() { - let file = FileTrait::new('data/non_ascii.txt'); - let content = read_txt(@file); - assert(1 == 1, ''); -} - -#[test] -fn not_number_without_quotes() { - let file = FileTrait::new('data/nan_without_quotes.txt'); - let content = read_txt(@file); - assert(1 == 1, ''); -} - -#[test] -fn too_large_number() { - let file = FileTrait::new('data/too_large_number.txt'); - let content = read_txt(@file); - assert(1 == 1, ''); +#[cfg(test)] +mod tests { + use snforge_std::fs::{FileTrait, read_txt, FileParser}; + use array::ArrayTrait; + use option::OptionTrait; + use serde::Serde; + + fn compare_with_expected_content(content: Array) { + let expected = array![ + 1, + 'hello', + 3, + 'world', + 0, + 3618502788666131213697322783095070105623107215331596699973092056135872020480 + ]; + + assert(content.len() == expected.len(), 'lengths not equal'); + let mut i = 0; + loop { + if i == content.len() { + break; + } + assert(*content[i] == *expected[i], 'unexpected content'); + i += 1; + }; + } + + #[derive(Serde, Drop, PartialEq)] + struct A { + a: u32, + nested_b: B, + nested_d: D, + f: felt252 + } + + #[derive(Serde, Drop, PartialEq)] + struct B { + nested_c: C, + } + + #[derive(Serde, Drop, PartialEq)] + struct C { + c: u256 + } + + #[derive(Serde, Drop, PartialEq)] + struct D { + d: u64, + e: u8 + } + + #[test] + fn valid_content_and_same_content_no_matter_whitespaces() { + let file = FileTrait::new('data/valid.txt'); + let content = FileParser::::parse_txt(@file).unwrap(); + let expected = A { + a: 1, nested_b: B { + nested_c: C { c: u256 { low: 'hello', high: 3 } } + }, nested_d: D { + d: 'world', e: 0 + }, f: 3618502788666131213697322783095070105623107215331596699973092056135872020480, + }; + assert(content.f == expected.f, '') + } + + #[test] + fn serialization() { + let file = FileTrait::new('data/valid.txt'); + let content = read_txt(@file); + compare_with_expected_content(content); + + let file = FileTrait::new('data/valid_diff_spaces.txt'); + let content = read_txt(@file); + compare_with_expected_content(content); + } + + #[test] + fn valid_content_different_folder() { + let file = FileTrait::new('valid_file.txt'); + let content = read_txt(@file); + let expected = array!['123', '12dsfwe', 124]; + + assert(content.len() == expected.len(), 'lengths not equal'); + let mut i = 0; + loop { + if i == content.len() { + break; + } + assert(*content[i] == *expected[i], 'unexpected content'); + i += 1; + }; + + assert(1 == 1, ''); + } + + #[test] + fn non_existent() { + let file = FileTrait::new('data/non_existent.txt'); + let content = read_txt(@file); + assert(1 == 1, ''); + } + + #[test] + fn invalid_quotes() { + let file = FileTrait::new('data/invalid_quotes.txt'); + let content = read_txt(@file); + assert(1 == 1, ''); + } + + #[test] + fn negative_number() { + let file = FileTrait::new('data/negative_number.txt'); + let content = read_txt(@file); + assert(1 == 1, ''); + } + + #[test] + fn non_ascii() { + let file = FileTrait::new('data/non_ascii.txt'); + let content = read_txt(@file); + assert(1 == 1, ''); + } + + #[test] + fn not_number_without_quotes() { + let file = FileTrait::new('data/nan_without_quotes.txt'); + let content = read_txt(@file); + assert(1 == 1, ''); + } + + #[test] + fn too_large_number() { + let file = FileTrait::new('data/too_large_number.txt'); + let content = read_txt(@file); + assert(1 == 1, ''); + } } diff --git a/crates/forge/tests/data/forking/Scarb.toml b/crates/forge/tests/data/forking/Scarb.toml index 9e674965da..86ecd6444c 100644 --- a/crates/forge/tests/data/forking/Scarb.toml +++ b/crates/forge/tests/data/forking/Scarb.toml @@ -5,7 +5,7 @@ version = "0.1.0" # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html [dependencies] -starknet = "2.2.0" +starknet = "2.3.0" snforge_std = { path = "../../../../../snforge_std" } [[target.starknet-contract]] diff --git a/crates/forge/tests/data/forking/src/lib.cairo b/crates/forge/tests/data/forking/src/lib.cairo index 12f882d4cc..401d9d122e 100644 --- a/crates/forge/tests/data/forking/src/lib.cairo +++ b/crates/forge/tests/data/forking/src/lib.cairo @@ -1,30 +1,28 @@ -use result::ResultTrait; -use array::ArrayTrait; -use option::OptionTrait; -use traits::TryInto; -use starknet::ContractAddress; -use starknet::Felt252TryIntoContractAddress; -use starknet::contract_address_const; -use snforge_std::{ BlockTag, BlockId }; +#[cfg(test)] +mod tests { + use starknet::ContractAddress; + use starknet::contract_address_const; + use snforge_std::{ BlockTag, BlockId }; -#[starknet::interface] -trait IHelloStarknet { - fn increase_balance(ref self: TContractState, amount: felt252); - fn get_balance(self: @TContractState) -> felt252; -} + #[starknet::interface] + trait IHelloStarknet { + fn increase_balance(ref self: TContractState, amount: felt252); + fn get_balance(self: @TContractState) -> felt252; + } -#[test] -#[fork(url: "http://188.34.188.184:9545/rpc/v0.4", block_id: BlockId::Number(313388))] -fn test_fork_simple() { - let dispatcher = IHelloStarknetDispatcher { - contract_address: contract_address_const::<3216637956526895219277698311134811322769343974163380838558193911733621219342>() - }; + #[test] + #[fork(url: "http://188.34.188.184:9545/rpc/v0.4", block_id: BlockId::Number(313388))] + fn test_fork_simple() { + let dispatcher = IHelloStarknetDispatcher { + contract_address: contract_address_const::<3216637956526895219277698311134811322769343974163380838558193911733621219342>() + }; - let balance = dispatcher.get_balance(); - assert(balance == 2, 'Balance should be 2'); + let balance = dispatcher.get_balance(); + assert(balance == 2, 'Balance should be 2'); - dispatcher.increase_balance(100); + dispatcher.increase_balance(100); - let balance = dispatcher.get_balance(); - assert(balance == 102, 'Balance should be 102'); + let balance = dispatcher.get_balance(); + assert(balance == 102, 'Balance should be 102'); + } } diff --git a/crates/forge/tests/data/fuzzing/Scarb.toml b/crates/forge/tests/data/fuzzing/Scarb.toml index 02068d8199..b8d3e95747 100644 --- a/crates/forge/tests/data/fuzzing/Scarb.toml +++ b/crates/forge/tests/data/fuzzing/Scarb.toml @@ -5,5 +5,5 @@ version = "0.1.0" # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html [dependencies] -starknet = "2.2.0" +starknet = "2.3.0" snforge_std = { path = "../../../../../snforge_std" } diff --git a/crates/forge/tests/data/hello_workspaces/Scarb.toml b/crates/forge/tests/data/hello_workspaces/Scarb.toml index 0e4fca1bdf..29e6a67aab 100644 --- a/crates/forge/tests/data/hello_workspaces/Scarb.toml +++ b/crates/forge/tests/data/hello_workspaces/Scarb.toml @@ -9,7 +9,7 @@ test = "snforge" [workspace.tool.snforge] [workspace.dependencies] -starknet = "2.2.0" +starknet = "2.3.0" snforge_std = { path = "../../../../../snforge_std" } [workspace.package] diff --git a/crates/forge/tests/data/hello_workspaces/src/lib.cairo b/crates/forge/tests/data/hello_workspaces/src/lib.cairo index 4be9a638ac..7194a20601 100644 --- a/crates/forge/tests/data/hello_workspaces/src/lib.cairo +++ b/crates/forge/tests/data/hello_workspaces/src/lib.cairo @@ -12,7 +12,10 @@ mod FibContract { } } -#[test] -fn test_simple() { - assert(1 == 1, 1); +#[cfg(test)] +mod tests { + #[test] + fn test_simple() { + assert(1 == 1, 1); + } } diff --git a/crates/forge/tests/data/simple_package/Scarb.toml b/crates/forge/tests/data/simple_package/Scarb.toml index ef206aa309..a453dc28e4 100644 --- a/crates/forge/tests/data/simple_package/Scarb.toml +++ b/crates/forge/tests/data/simple_package/Scarb.toml @@ -3,7 +3,7 @@ name = "simple_package" version = "0.1.0" [dependencies] -starknet = "2.2.0" +starknet = "2.3.0" snforge_std = { path = "../../../../../snforge_std" } [[target.starknet-contract]] diff --git a/crates/forge/tests/data/simple_package/src/lib.cairo b/crates/forge/tests/data/simple_package/src/lib.cairo index 185e42d293..8aa597fdca 100644 --- a/crates/forge/tests/data/simple_package/src/lib.cairo +++ b/crates/forge/tests/data/simple_package/src/lib.cairo @@ -8,13 +8,18 @@ fn fib(a: felt252, b: felt252, n: felt252) -> felt252 { } } -#[test] -fn test_fib() { - assert(fib(0, 1, 10) == 55, fib(0, 1, 10)); -} +#[cfg(test)] +mod tests { + use super::fib; + + #[test] + fn test_fib() { + assert(fib(0, 1, 10) == 55, fib(0, 1, 10)); + } -#[test] -#[ignore] -fn ignored_test() { - assert(1 == 1, 'passing'); + #[test] + #[ignore] + fn ignored_test() { + assert(1 == 1, 'passing'); + } } diff --git a/crates/forge/tests/data/virtual_workspace/Scarb.toml b/crates/forge/tests/data/virtual_workspace/Scarb.toml index 3ec7ab42ef..017ee06309 100644 --- a/crates/forge/tests/data/virtual_workspace/Scarb.toml +++ b/crates/forge/tests/data/virtual_workspace/Scarb.toml @@ -10,7 +10,7 @@ test = "snforge" exit_first = true [workspace.dependencies] -starknet = "2.2.0" +starknet = "2.3.0" snforge_std = { path = "../../../../../snforge_std" } [workspace.package] diff --git a/crates/forge/tests/e2e/collection.rs b/crates/forge/tests/e2e/collection.rs index 049c6c06e9..e4e8d0ef0f 100644 --- a/crates/forge/tests/e2e/collection.rs +++ b/crates/forge/tests/e2e/collection.rs @@ -26,24 +26,24 @@ fn collection_with_lib() { Collected 17 test(s) from collection_with_lib package Running 12 test(s) from src/ - [PASS] collection_with_lib::test_simple - [PASS] collection_with_lib::test_fob_in_lib - [PASS] collection_with_lib::test_fib_in_lib - [PASS] collection_with_lib::fib::test_fib - [PASS] collection_with_lib::fib::test_fob_in_fib - [PASS] collection_with_lib::fib::test_fab_in_fib - [PASS] collection_with_lib::fob::test_simple - [PASS] collection_with_lib::fob::fob_impl::test_fob - [PASS] collection_with_lib::fab::test_simple - [PASS] collection_with_lib::fab::fab_impl::test_fab - [PASS] collection_with_lib::fab::fab_impl::test_how_does_this_work - [PASS] collection_with_lib::fab::fab_impl::test_super + [PASS] collection_with_lib::fab::tests::test_simple + [PASS] collection_with_lib::fob::tests::test_simple + [PASS] collection_with_lib::tests::test_fib_in_lib + [PASS] collection_with_lib::tests::test_simple + [PASS] collection_with_lib::fib::tests::test_fab_in_fib + [PASS] collection_with_lib::fib::tests::test_fib + [PASS] collection_with_lib::fab::fab_impl::tests::test_fab + [PASS] collection_with_lib::fib::tests::test_fob_in_fib + [PASS] collection_with_lib::tests::test_fob_in_lib + [PASS] collection_with_lib::fab::fab_impl::tests::test_super + [PASS] collection_with_lib::fob::fob_impl::tests::test_fob + [PASS] collection_with_lib::fab::fab_impl::tests::test_how_does_this_work Running 5 test(s) from tests/ - [PASS] tests::fibfabfob::test_fib + [PASS] tests::fab::fab_mod::test_fab [PASS] tests::fibfabfob::test_fob - [PASS] tests::fibfabfob::test_fab [PASS] tests::fab::test_fab - [PASS] tests::fab::fab_mod::test_fab + [PASS] tests::fibfabfob::test_fib + [PASS] tests::fibfabfob::test_fab Tests: 17 passed, 0 failed, 0 skipped "#} ); @@ -70,24 +70,24 @@ fn collection_without_lib() { Collected 17 test(s) from collection_without_lib package Running 12 test(s) from src/ - [PASS] collection_without_lib::test_simple - [PASS] collection_without_lib::test_fob_in_lib - [PASS] collection_without_lib::test_fib_in_lib - [PASS] collection_without_lib::fib::test_fib - [PASS] collection_without_lib::fib::test_fob_in_fib - [PASS] collection_without_lib::fib::test_fab_in_fib - [PASS] collection_without_lib::fob::test_simple - [PASS] collection_without_lib::fob::fob_impl::test_fob - [PASS] collection_without_lib::fab::test_simple - [PASS] collection_without_lib::fab::fab_impl::test_fab - [PASS] collection_without_lib::fab::fab_impl::test_how_does_this_work - [PASS] collection_without_lib::fab::fab_impl::test_super + [PASS] collection_without_lib::fab::tests::test_simple + [PASS] collection_without_lib::fab::fab_impl::tests::test_super + [PASS] collection_without_lib::tests::test_simple + [PASS] collection_without_lib::fab::fab_impl::tests::test_fab + [PASS] collection_without_lib::fob::tests::test_simple + [PASS] collection_without_lib::fib::tests::test_fob_in_fib + [PASS] collection_without_lib::tests::test_fib_in_lib + [PASS] collection_without_lib::fib::tests::test_fab_in_fib + [PASS] collection_without_lib::tests::test_fob_in_lib + [PASS] collection_without_lib::fab::fab_impl::tests::test_how_does_this_work + [PASS] collection_without_lib::fob::fob_impl::tests::test_fob + [PASS] collection_without_lib::fib::tests::test_fib Running 5 test(s) from tests/ - [PASS] tests::fab::test_fab + [PASS] tests::fibfabfob::test_fab [PASS] tests::fab::fab_mod::test_fab - [PASS] tests::fibfabfob::test_fib + [PASS] tests::fab::test_fab [PASS] tests::fibfabfob::test_fob - [PASS] tests::fibfabfob::test_fab + [PASS] tests::fibfabfob::test_fib Tests: 17 passed, 0 failed, 0 skipped "#} ); diff --git a/crates/forge/tests/e2e/common/runner.rs b/crates/forge/tests/e2e/common/runner.rs index 3010f038dd..8712c384f4 100644 --- a/crates/forge/tests/e2e/common/runner.rs +++ b/crates/forge/tests/e2e/common/runner.rs @@ -42,7 +42,7 @@ pub(crate) fn setup_package_with_file_patterns( .parse::() .unwrap(); scarb_toml["dependencies"]["snforge_std"]["path"] = value(snforge_std_path); - scarb_toml["dependencies"]["starknet"] = value("2.2.0"); + scarb_toml["dependencies"]["starknet"] = value("2.3.0"); scarb_toml["target.starknet-contract"]["sierra"] = value(true); scarb_toml["target.starknet-contract"]["casm"] = value(true); @@ -83,7 +83,7 @@ pub(crate) fn setup_hello_workspace() -> TempDir { [workspace.dependencies] - starknet = "2.2.0" + starknet = "2.3.0" snforge_std = {{ path = "{}" }} [workspace.package] @@ -142,7 +142,7 @@ pub(crate) fn setup_virtual_workspace() -> TempDir { [workspace.tool.snforge] [workspace.dependencies] - starknet = "2.2.0" + starknet = "2.3.0" snforge_std = {{ path = "{}" }} [workspace.package] diff --git a/crates/forge/tests/e2e/diagnostics_and_plugins.rs b/crates/forge/tests/e2e/diagnostics_and_plugins.rs index c2ddcbfb83..32f33ddf10 100644 --- a/crates/forge/tests/e2e/diagnostics_and_plugins.rs +++ b/crates/forge/tests/e2e/diagnostics_and_plugins.rs @@ -13,32 +13,32 @@ fn print_error_if_attributes_incorrect() { output, indoc! {r#" error: Plugin diagnostic: Expected fork config must be of the form `url: , block_id: `. - --> lib.cairo:2:7 - #[fork(url: "https://lib.com")] - ^**********************^ + --> [..]/src/lib.cairo:4:11 + #[fork(url: "https://lib.com")] + ^**********************^ error: Plugin diagnostic: Expected fork config must be of the form `url: , block_id: `. - --> lib.cairo:2:7 - #[fork(url: "https://lib.com")] - ^**********************^ + --> [..]/src/lib.cairo:4:11 + #[fork(url: "https://lib.com")] + ^**********************^ error: Plugin diagnostic: Expected fork config must be of the form `url: , block_id: `. - --> test_fork.cairo:2:7 + --> [..]/tests/test_fork.cairo:2:7 #[fork(url: "https://test.com")] ^***********************^ error: Plugin diagnostic: Expected fuzzer config must be of the form `runs: , seed: ` - --> test_fuzzer.cairo:2:9 + --> [..]/tests/test_fuzzer.cairo:2:9 #[fuzzer(test: 10)] ^********^ error: Plugin diagnostic: Expected fuzzer config must be of the form `runs: , seed: ` - --> test_fuzzer.cairo:8:9 + --> [..]/tests/test_fuzzer.cairo:8:9 #[fuzzer()] ^^ error: Plugin diagnostic: Expected panic must be of the form `expected = `. - --> test_should_panic.cairo:2:15 + --> [..]/tests/test_should_panic.cairo:2:15 #[should_panic(url: "https://test.com")] ^***********************^ diff --git a/crates/forge/tests/e2e/env.rs b/crates/forge/tests/e2e/env.rs index 9ca894122d..4e50fef28a 100644 --- a/crates/forge/tests/e2e/env.rs +++ b/crates/forge/tests/e2e/env.rs @@ -22,7 +22,7 @@ fn env_var_reading() { Collected 1 test(s) from env package Running 1 test(s) from src/ - [PASS] env::reading_env_vars + [PASS] env::tests::reading_env_vars Tests: 1 passed, 0 failed, 0 skipped "#} ); diff --git a/crates/forge/tests/e2e/forking.rs b/crates/forge/tests/e2e/forking.rs index 503c983a76..4979f5326b 100644 --- a/crates/forge/tests/e2e/forking.rs +++ b/crates/forge/tests/e2e/forking.rs @@ -12,7 +12,7 @@ fn without_cache() { let output = snapbox .current_dir(&temp) - .args(["--exact", "forking::test_fork_simple"]) + .args(["--exact", "forking::tests::test_fork_simple"]) .assert() .code(0); assert_stdout_contains!( @@ -24,7 +24,7 @@ fn without_cache() { Collected 1 test(s) from forking package Running 1 test(s) from src/ - [PASS] forking::test_fork_simple + [PASS] forking::tests::test_fork_simple Tests: 1 passed, 0 failed, 0 skipped "#} ); @@ -52,7 +52,7 @@ fn with_cache() { Collected 1 test(s) from forking package Running 1 test(s) from src/ - [FAIL] forking::test_fork_simple + [FAIL] forking::tests::test_fork_simple Failure data: original value: [1480335954842313548834020101284630397133856818], converted to a string: [Balance should be 2] @@ -60,7 +60,7 @@ fn with_cache() { Tests: 0 passed, 1 failed, 0 skipped Failures: - forking::test_fork_simple + forking::tests::test_fork_simple "#} ); } @@ -88,7 +88,7 @@ fn with_clean_cache() { Collected 1 test(s) from forking package Running 1 test(s) from src/ - [PASS] forking::test_fork_simple + [PASS] forking::tests::test_fork_simple Tests: 1 passed, 0 failed, 0 skipped "#} ); diff --git a/crates/forge/tests/e2e/fuzzing.rs b/crates/forge/tests/e2e/fuzzing.rs index 6341d582a4..889cd43881 100644 --- a/crates/forge/tests/e2e/fuzzing.rs +++ b/crates/forge/tests/e2e/fuzzing.rs @@ -111,7 +111,7 @@ fn fuzzing_set_seed() { [PASS] fuzzing::tests::fuzzed_argument (fuzzer runs = 256) [PASS] fuzzing::tests::fuzzed_both_arguments (fuzzer runs = 256) [PASS] fuzzing::tests::passing - [FAIL] fuzzing::tests::failing_fuzz (fuzzer runs = 1, arguments = [..]) + [FAIL] fuzzing::tests::failing_fuzz (fuzzer runs = 1, arguments = [[..], [..]]) Failure data: original value: [..], converted to a string: [result == a + b] diff --git a/crates/forge/tests/e2e/io_operations.rs b/crates/forge/tests/e2e/io_operations.rs index ed4a87b7ea..d4959caccb 100644 --- a/crates/forge/tests/e2e/io_operations.rs +++ b/crates/forge/tests/e2e/io_operations.rs @@ -21,40 +21,40 @@ fn file_reading() { Collected 23 test(s) from file_reading package Running 9 test(s) from src/ - [PASS] file_reading::valid_content_and_same_content_no_matter_whitespaces - [PASS] file_reading::serialization - [PASS] file_reading::valid_content_different_folder - [FAIL] file_reading::non_existent + [PASS] file_reading::tests::valid_content_and_same_content_no_matter_whitespaces + [PASS] file_reading::tests::serialization + [PASS] file_reading::tests::valid_content_different_folder + [FAIL] file_reading::tests::non_existent Failure data: Got an exception while executing a hint: No such file or directory (os error 2) - [FAIL] file_reading::invalid_quotes + [FAIL] file_reading::tests::invalid_quotes Failure data: Got an exception while executing a hint: Failed to parse data/invalid_quotes.txt file - [FAIL] file_reading::negative_number + [FAIL] file_reading::tests::negative_number Failure data: Got an exception while executing a hint: Failed to parse data/negative_number.txt file - [FAIL] file_reading::non_ascii + [FAIL] file_reading::tests::non_ascii Failure data: Got an exception while executing a hint: Failed to parse data/non_ascii.txt file - [FAIL] file_reading::not_number_without_quotes + [FAIL] file_reading::tests::not_number_without_quotes Failure data: Got an exception while executing a hint: Failed to parse data/nan_without_quotes.txt file - [FAIL] file_reading::too_large_number + [FAIL] file_reading::tests::too_large_number Failure data: Got an exception while executing a hint: @@ -118,12 +118,12 @@ fn file_reading() { Tests: 9 passed, 14 failed, 0 skipped Failures: - file_reading::non_existent - file_reading::invalid_quotes - file_reading::negative_number - file_reading::non_ascii - file_reading::not_number_without_quotes - file_reading::too_large_number + file_reading::tests::non_existent + file_reading::tests::invalid_quotes + file_reading::tests::negative_number + file_reading::tests::non_ascii + file_reading::tests::not_number_without_quotes + file_reading::tests::too_large_number tests::test::invalid_json tests::test::non_existent tests::test::json_non_existent diff --git a/crates/forge/tests/e2e/running.rs b/crates/forge/tests/e2e/running.rs index ded1e51c2b..e0652d17a0 100644 --- a/crates/forge/tests/e2e/running.rs +++ b/crates/forge/tests/e2e/running.rs @@ -24,8 +24,8 @@ fn simple_package() { Collected 13 test(s) from simple_package package Running 2 test(s) from src/ - [PASS] simple_package::test_fib - [IGNORE] simple_package::ignored_test + [PASS] simple_package::tests::test_fib + [IGNORE] simple_package::tests::ignored_test Running 11 test(s) from tests/ [PASS] tests::contract::call_and_invoke [PASS] tests::ext_function_test::test_my_test @@ -77,7 +77,7 @@ fn simple_package_with_git_dependency() { casm = true [dependencies] - starknet = "2.2.0" + starknet = "2.3.0" snforge_std = {{ git = "https://github.com/{}", branch = "{}" }} "#, remote_url, @@ -95,15 +95,14 @@ fn simple_package_with_git_dependency() { assert_stdout_contains!( output, indoc! {r#" - [..]Updating git repository[..] [..]Compiling[..] [..]Finished[..] Collected 13 test(s) from simple_package package Running 2 test(s) from src/ - [PASS] simple_package::test_fib - [IGNORE] simple_package::ignored_test + [PASS] simple_package::tests::test_fib + [IGNORE] simple_package::tests::ignored_test Running 11 test(s) from tests/ [PASS] tests::contract::call_and_invoke [PASS] tests::ext_function_test::test_my_test @@ -273,7 +272,7 @@ fn with_ignored_flag() { Collected 2 test(s) from simple_package package Running 1 test(s) from src/ - [PASS] simple_package::ignored_test + [PASS] simple_package::tests::ignored_test Running 1 test(s) from tests/ [FAIL] tests::ext_function_test::ignored_test @@ -308,8 +307,8 @@ fn with_include_ignored_flag() { Collected 13 test(s) from simple_package package Running 2 test(s) from src/ - [PASS] simple_package::test_fib - [PASS] simple_package::ignored_test + [PASS] simple_package::tests::test_fib + [PASS] simple_package::tests::ignored_test Running 11 test(s) from tests/ [PASS] tests::contract::call_and_invoke [PASS] tests::ext_function_test::test_my_test @@ -400,7 +399,7 @@ fn with_include_ignored_flag_and_filter() { Collected 2 test(s) from simple_package package Running 1 test(s) from src/ - [PASS] simple_package::ignored_test + [PASS] simple_package::tests::ignored_test Running 1 test(s) from tests/ [FAIL] tests::ext_function_test::ignored_test @@ -520,7 +519,7 @@ fn with_exit_first() { version = "0.1.0" [dependencies] - starknet = "2.2.0" + starknet = "2.3.0" snforge_std = {{ path = "{}" }} [[target.starknet-contract]] @@ -622,11 +621,10 @@ fn init_new_project_test() { [dependencies] snforge_std = {{ git = "https://github.com/foundry-rs/starknet-foundry", tag = "v{}" }} - starknet = "2.2.0" + starknet = "2.3.0" [[target.starknet-contract]] casm = true - # foo = {{ path = "vendor/foo" }} "#, version ); @@ -647,7 +645,7 @@ fn init_new_project_test() { casm = true [dependencies] - starknet = "2.2.0" + starknet = "2.3.0" snforge_std = {{ git = "https://github.com/{}", branch = "{}" }} "#, remote_url, @@ -664,7 +662,6 @@ fn init_new_project_test() { assert_stdout_contains!( output, indoc! {r#" - [..]Updating git repository[..] [..]Compiling test_name v0.1.0[..] [..]Finished[..] diff --git a/crates/forge/tests/e2e/workspaces.rs b/crates/forge/tests/e2e/workspaces.rs index e699cee9dc..303132467c 100644 --- a/crates/forge/tests/e2e/workspaces.rs +++ b/crates/forge/tests/e2e/workspaces.rs @@ -20,7 +20,7 @@ fn root_workspace_without_arguments() { Collected 3 test(s) from hello_workspaces package Running 1 test(s) from src/ - [PASS] hello_workspaces::test_simple + [PASS] hello_workspaces::tests::test_simple Running 2 test(s) from tests/ [FAIL] tests::test_failing::test_failing @@ -141,7 +141,7 @@ fn root_workspace_specify_root_package() { Collected 3 test(s) from hello_workspaces package Running 1 test(s) from src/ - [PASS] hello_workspaces::test_simple + [PASS] hello_workspaces::tests::test_simple Running 2 test(s) from tests/ [FAIL] tests::test_failing::test_failing @@ -200,7 +200,7 @@ fn root_workspace_for_entire_workspace() { assert_stdout_contains!( output, indoc! {r#" - [..]Compiling[..] + [..]Compiling[..] [..]Compiling[..] [..]Finished[..] @@ -239,7 +239,7 @@ fn root_workspace_for_entire_workspace() { Collected 3 test(s) from hello_workspaces package Running 1 test(s) from src/ - [PASS] hello_workspaces::test_simple + [PASS] hello_workspaces::tests::test_simple Running 2 test(s) from tests/ [FAIL] tests::test_failing::test_failing @@ -310,7 +310,7 @@ fn root_workspace_for_entire_workspace_inside_package() { Collected 3 test(s) from hello_workspaces package Running 1 test(s) from src/ - [PASS] hello_workspaces::test_simple + [PASS] hello_workspaces::tests::test_simple Running 2 test(s) from tests/ [FAIL] tests::test_failing::test_failing diff --git a/crates/forge/tests/integration/dispatchers.rs b/crates/forge/tests/integration/dispatchers.rs index 8682f1e900..f0215abd0a 100644 --- a/crates/forge/tests/integration/dispatchers.rs +++ b/crates/forge/tests/integration/dispatchers.rs @@ -577,7 +577,7 @@ fn nonexistent_method_call() { assert_case_output_contains!( result, "test_nonexistent_method_call", - "Entry point selector 0x01fdb214e1495025fa4baf660d34f03c0d8b5037cf10311d2a3202a806aa9485 not found in contract 0x02a81cd55558b39a8cac1261a24711b5c6ef787cda6b24997157bbf50ddfbdb0" + "Entry point selector 0x01fdb214e1495025fa4baf660d34f03c0d8b5037cf10311d2a3202a806aa9485 not found in contract 0x01779e0d4a362d853a9b30a6d6a912ad8a08854d2faff2b0a04e985653d0fb57" ); } diff --git a/crates/forge/tests/integration/spy_events.rs b/crates/forge/tests/integration/spy_events.rs index 2802580849..23e4f78f23 100644 --- a/crates/forge/tests/integration/spy_events.rs +++ b/crates/forge/tests/integration/spy_events.rs @@ -428,7 +428,7 @@ fn event_emitted_wrong_data_asserted() { assert_case_output_contains!( result, "test_assert_wrong_data", - "2608192145348782260666070009368817886796383732053954498156320322296039742689" + "1071059591818692687693501857417723820819626707667477619231912076312778489185" ); } diff --git a/crates/forge/tests/integration/syscalls.rs b/crates/forge/tests/integration/syscalls.rs index 68414c6b46..331a6d72fb 100644 --- a/crates/forge/tests/integration/syscalls.rs +++ b/crates/forge/tests/integration/syscalls.rs @@ -10,12 +10,7 @@ fn library_call_syscall() { let test = test_case!( indoc!( r#" - use array::ArrayTrait; - use result::ResultTrait; - use option::OptionTrait; - use traits::TryInto; use starknet::ContractAddress; - use starknet::Felt252TryIntoContractAddress; use starknet::ClassHash; use snforge_std::{ declare, ContractClassTrait }; @@ -75,7 +70,7 @@ fn library_call_syscall() { #[starknet::interface] trait IExecutor { - fn add_two(ref self: ContractState, number: felt252) -> felt252; + fn add_two(ref self: TContractState, number: felt252) -> felt252; } #[storage] diff --git a/crates/test-collector/src/plugin.rs b/crates/test-collector/src/plugin.rs index 5d6d0296fa..9554445a8a 100644 --- a/crates/test-collector/src/plugin.rs +++ b/crates/test-collector/src/plugin.rs @@ -24,4 +24,15 @@ impl MacroPlugin for TestPlugin { remove_original_item: false, } } + + fn declared_attributes(&self) -> Vec { + vec![ + "test".to_string(), + "ignore".to_string(), + "available_gas".to_string(), + "should_panic".to_string(), + "fork".to_string(), + "fuzzer".to_string(), + ] + } } diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 364d0c0c01..df1662c47e 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -72,8 +72,8 @@ * [parse_json](appendix/forge-library/fs/parse_json.md) * [env](appendix/forge-library/env.md) * [var](appendix/forge-library/env/var.md) - * [signature](appendix/forge-library/signature) - * [interface](appendix/forge-library/signature/interface.md) + * [signature](appendix/forge-library/signature.md) + * [Interface](appendix/forge-library/signature/interface.md) * [StarkCurveKeyPair](appendix/forge-library/signature/stark_curve_key_pair.md) * [Cast Commands](appendix/cast.md) * [common flags](appendix/cast/common.md) diff --git a/docs/src/appendix/forge/test.md b/docs/src/appendix/forge/test.md index c901bcbc9e..cbddb0375d 100644 --- a/docs/src/appendix/forge/test.md +++ b/docs/src/appendix/forge/test.md @@ -5,7 +5,7 @@ Run tests for a project in the current directory. ## `[TEST_FILTER]` Passing a test filter will only run tests with -an [absolute module tree path](https://book.cairo-lang.org/ch06-03-paths-for-referring-to-an-item-in-the-module-tree.html?highlight=path#paths-for-referring-to-an-item-in-the-module-tree) +an [absolute module tree path](https://book.cairo-lang.org/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html#paths-for-referring-to-an-item-in-the-module-tree) containing this filter. ## `-e`, `--exact` diff --git a/docs/src/testing/contracts.md b/docs/src/testing/contracts.md index 8a24b98378..7f2ace293f 100644 --- a/docs/src/testing/contracts.md +++ b/docs/src/testing/contracts.md @@ -82,8 +82,9 @@ fn call_and_invoke() { ```shell $ snforge test Collected 1 test(s) from using_dispatchers package -Running 1 test(s) from src/ -[PASS] using_dispatchers::call_and_invoke +Running 0 test(s) from src/ +Running 1 test(s) from tests/ +[PASS] tests::call_and_invoke Tests: 1 passed, 0 failed, 0 skipped ``` @@ -140,8 +141,9 @@ fn failing() { ```shell $ snforge test Collected 1 test(s) from package_name package -Running 1 test(s) from src/ -[FAIL] package_name::failing +Running 0 test(s) from src/ +Running 1 test(s) from tests/ +[FAIL] tests::failing Failure data: original value: [344693033283], converted to a string: [PANIC] @@ -150,7 +152,7 @@ Failure data: Tests: 0 passed, 1 failed, 0 skipped Failures: - package_name::failing + tests::failing ``` ### `SafeDispatcher` @@ -180,8 +182,9 @@ Now the test passes as expected. ```shell $ snforge test Collected 1 test(s) from package_name package -Running 1 test(s) from src/ -[PASS] package_name::handling_errors +Running 0 test(s) from src/ +Running 1 test(s) from tests/ +[PASS] tests::handling_errors Tests: 1 passed, 0 failed, 0 skipped ``` diff --git a/docs/src/testing/debugging.md b/docs/src/testing/debugging.md index ed85c8f7f9..cb69de08c1 100644 --- a/docs/src/testing/debugging.md +++ b/docs/src/testing/debugging.md @@ -58,7 +58,7 @@ original value: [2] original value: [3] original value: [379899844591278365831020], converted to a string: [Print bool:] original value: [439721161573], converted to a string: [false] -[PASS] tests::test_print::test_print +[PASS] tests::test_print Tests: 1 passed, 0 failed, 0 skipped ``` @@ -71,8 +71,9 @@ If the parsed value contains ASCII control characters (e.g. 27: `ESC`), it will #[test] fn test_print() { // ... - + 27.print(); +} ``` ```shell @@ -81,6 +82,8 @@ Collected 1 test(s) from package_name package Running 0 test(s) from src/ Running 1 test(s) from tests/ original value: [27] +[PASS] tests::test_print +Tests: 1 passed, 0 failed, 0 skipped ``` ## In contracts @@ -131,7 +134,7 @@ fn test_increase_balance() { We get the following output: ```shell $ snforge test -Collected 2 test(s) from package_name package +Collected 1 test(s) from package_name package Running 0 test(s) from src/ Running 1 test(s) from tests/ original value: [1882356686041040905424961122938381530884043578], converted to a string: [The new balance is:] diff --git a/docs/src/testing/fuzz-testing.md b/docs/src/testing/fuzz-testing.md index 16bd5b2e30..9ea9f2cc24 100644 --- a/docs/src/testing/fuzz-testing.md +++ b/docs/src/testing/fuzz-testing.md @@ -32,8 +32,9 @@ Then run `snforge test` like usual. ```shell $ snforge test Collected 1 test(s) from package_name package -Running 1 test(s) from src/ -[PASS] package_name::test_sum (fuzzer runs = 256) +Running 0 test(s) from src/ +Running 1 test(s) from tests/ +[PASS] tests::test_sum (fuzzer runs = 256) Tests: 1 passed, 0 failed, 0 skipped Fuzzer seed: [..] ``` diff --git a/docs/src/testing/running-tests.md b/docs/src/testing/running-tests.md index cc52f91b74..37c1a95e55 100644 --- a/docs/src/testing/running-tests.md +++ b/docs/src/testing/running-tests.md @@ -6,24 +6,24 @@ To run tests with Forge, simply run the `snforge test` command from the package $ snforge test Collected 3 test(s) from package_name package Running 3 test(s) from src/ -[PASS] package_name::executing -[PASS] package_name::calling -[PASS] package_name::calling_another +[PASS] package_name::tests::executing +[PASS] package_name::tests::calling +[PASS] package_name::tests::calling_another Tests: 3 passed, 0 failed, 0 skipped ``` ## Filtering Tests You can pass a filter string after the `snforge test` command to filter tests. -By default, any test with an [absolute module tree path](https://book.cairo-lang.org/ch06-03-paths-for-referring-to-an-item-in-the-module-tree.html?highlight=path#paths-for-referring-to-an-item-in-the-module-tree) +By default, any test with an [absolute module tree path](https://book.cairo-lang.org/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html#paths-for-referring-to-an-item-in-the-module-tree) matching the filter will be run. ```shell $ snforge test calling Collected 2 test(s) from package_name package Running 2 test(s) from src/ -[PASS] package_name::calling -[PASS] package_name::calling_another +[PASS] package_name::tests::calling +[PASS] package_name::tests::calling_another Tests: 2 passed, 0 failed, 0 skipped ``` @@ -33,10 +33,10 @@ To run a specific test, you can pass a filter string along with an `--exact` fla Note, you have to use a fully qualified test name, including a module name. ```shell -$ snforge test package_name::calling --exact +$ snforge test package_name::tests::calling --exact Collected 1 test(s) from package_name package Running 1 test(s) from src/ -[PASS] package_name::calling +[PASS] package_name::tests::calling Tests: 1 passed, 0 failed, 0 skipped ``` @@ -48,20 +48,20 @@ To stop the test execution after first failed test, you can pass an `--exit-firs $ snforge test --exit-first Collected 6 test(s) from package_name package Running 6 test(s) from src/ -[PASS] package_name::executing -[PASS] package_name::calling -[PASS] package_name::calling_another -[FAIL] package_name::failing +[PASS] package_name::tests::executing +[PASS] package_name::tests::calling +[PASS] package_name::tests::calling_another +[FAIL] package_name::tests::failing Failure data: original value: [8111420071579136082810415440747], converted to a string: [failing check] -[SKIP] package_name::other_test -[SKIP] package_name::yet_another_test +[SKIP] package_name::tests::other_test +[SKIP] package_name::tests::yet_another_test Tests: 3 passed, 1 failed, 2 skipped Failures: - package_name::failing + package_name::tests::failing ``` ## Scarb workspaces support @@ -102,7 +102,7 @@ only the tests in `./src` and `./tests` folders will be executed. $ snforge test Collected 1 test(s) from hello_workspaces package Running 1 test(s) from src/ -[PASS] hello_workspaces::test_simple +[PASS] hello_workspaces::tests::test_simple Tests: 1 passed, 0 failed, 0 skipped ``` @@ -139,7 +139,7 @@ Tests: 1 passed, 0 failed, 0 skipped Collected 1 test(s) from hello_workspaces package Running 1 test(s) from src/ -[PASS] hello_workspaces::test_simple +[PASS] hello_workspaces::tests::test_simple Tests: 1 passed, 0 failed, 0 skipped ``` diff --git a/docs/src/testing/test-collection.md b/docs/src/testing/test-collection.md index 116e1954c5..d5561dca1b 100644 --- a/docs/src/testing/test-collection.md +++ b/docs/src/testing/test-collection.md @@ -7,7 +7,8 @@ test case. Starknet Forge will collect tests only from these places: -- any files reachable from the package root (declared as `mod` in `lib.cairo` or its children) +- any files reachable from the package root (declared as `mod` in `lib.cairo` or its children) - +these have to be in a module annotated with `#[cfg(test)]` - files inside the [`tests`](#the-tests-directory) directory ## The *tests* Directory diff --git a/docs/src/testing/testing.md b/docs/src/testing/testing.md index fff96aae90..965deaf7c3 100644 --- a/docs/src/testing/testing.md +++ b/docs/src/testing/testing.md @@ -12,13 +12,17 @@ fn sum(a: felt252, b: felt252) -> felt252 { return a + b; } -#[test] -fn test_sum() { - assert(sum(2, 3) == 5, 'sum incorrect'); +#[cfg(test)] +mod tests { + #[test] + fn test_sum() { + assert(sum(2, 3) == 5, 'sum incorrect'); + } } ``` It is a common practice to keep your unit tests in the same file as the tested code. +Keep in mind that all tests in `src` folder have to be in a module annotated with `#[cfg(test)]`. When it comes to integration tests, you can keep them in separate files in the `tests` directory. You can find a detailed explanation of how Forge collects tests [here](test-collection.md). @@ -28,7 +32,7 @@ Now run forge using a command: $ snforge test Collected 1 test(s) from package_name package Running 1 test(s) from src/ -[PASS] package_name::test_sum +[PASS] package_name::tests::test_sum Tests: 1 passed, 0 failed, 0 skipped ``` @@ -37,18 +41,19 @@ Tests: 1 passed, 0 failed, 0 skipped If your code panics, the test is considered failed. Here's an example of a failing test. ```rust -use array::ArrayTrait; - fn panicking_function() { - let mut data = ArrayTrait::new(); + let mut data = array![]; data.append('aaa'); panic(data) } -#[test] -fn failing() { - panicking_function(); - assert(2 == 2, '2 == 2'); +#[cfg(test)] +mod tests { + #[test] + fn failing() { + panicking_function(); + assert(2 == 2, '2 == 2'); + } } ``` @@ -56,7 +61,7 @@ fn failing() { $ snforge test Collected 1 test(s) from package_name package Running 1 test(s) from src/ -[FAIL] package_name::failing +[FAIL] package_name::tests::failing Failure data: [6381921], converted to a string: [aaa] @@ -64,7 +69,7 @@ Failure data: Tests: 0 passed, 1 failed, 0 skipped Failures: - package_name::failing + package_name::tests::failing ``` ## Expected failures @@ -87,8 +92,9 @@ fn should_panic_check_data() { ```shell $ snforge test Collected 1 test(s) from package_name package -Running 1 test(s) from src/ -[PASS] src::should_panic_check_data +Running 0 test(s) from src/ +Running 1 test(s) from tests/ +[PASS] tests::should_panic_check_data Tests: 1 passed, 0 failed, 0 skipped ``` @@ -106,10 +112,11 @@ fn ignored_test() { ``` ```shell -$ snforge +$ snforge test Collected 1 test(s) from package_name package -Running 1 test(s) from src/ -[IGNORE] src::ignored_test +Running 0 test(s) from src/ +Running 1 test(s) from tests/ +[IGNORE] tests::ignored_test Tests: 1 passed, 0 failed, 0 skipped ``` diff --git a/docs/src/testing/using-cheatcodes.md b/docs/src/testing/using-cheatcodes.md index 77f9a05b95..efea312aa3 100644 --- a/docs/src/testing/using-cheatcodes.md +++ b/docs/src/testing/using-cheatcodes.md @@ -79,8 +79,9 @@ However, when running this test, we will get a failure with a message ```shell $ snforge test Collected 1 test(s) from package_name package -Running 1 test(s) from src/ -[FAIL] package_name::call_and_invoke +Running 0 test(s) from src/ +Running 1 test(s) from tests/ +[FAIL] tests::call_and_invoke Failure data: original value: [2619239621329578143946475627394146418642347364], converted to a string: [user is not allowed] @@ -88,7 +89,7 @@ Failure data: Tests: 0 passed, 1 failed, 0 skipped Failures: - package_name::call_and_invoke + tests::call_and_invoke ``` Our user validation is not letting us call the contract, because the default caller address is not `123`. @@ -129,8 +130,9 @@ The test will now pass without an error ```shell $ snforge test Collected 1 test(s) from package_name package -Running 1 test(s) from src/ -[PASS] package_name::call_and_invoke +Running 0 test(s) from src/ +Running 1 test(s) from tests/ +[PASS] tests::call_and_invoke Tests: 1 passed, 0 failed, 0 skipped ``` @@ -162,8 +164,9 @@ fn call_and_invoke() { ```shell $ snforge test Collected 1 test(s) from package_name package -Running 1 test(s) from src/ -[FAIL] package_name::call_and_invoke +Running 0 test(s) from src/ +Running 1 test(s) from tests/ +[FAIL] tests::call_and_invoke Failure data: original value: [2619239621329578143946475627394146418642347364], converted to a string: [user is not allowed] @@ -171,7 +174,7 @@ Failure data: Tests: 0 passed, 1 failed, 0 skipped Failures: - package_name::call_and_invoke + tests::call_and_invoke ``` ### Pranking the constructor diff --git a/snforge_std/Scarb.lock b/snforge_std/Scarb.lock new file mode 100644 index 0000000000..29385513a0 --- /dev/null +++ b/snforge_std/Scarb.lock @@ -0,0 +1,6 @@ +# Code generated by scarb DO NOT EDIT. +version = 1 + +[[package]] +name = "snforge_std" +version = "0.1.0" diff --git a/snforge_std/Scarb.toml b/snforge_std/Scarb.toml index 0a0d7308a5..f265e2362f 100644 --- a/snforge_std/Scarb.toml +++ b/snforge_std/Scarb.toml @@ -3,4 +3,4 @@ name = "snforge_std" version = "0.1.0" [dependencies] -starknet = "2.2.0" +starknet = "2.3.0"