From 5eda322d6eb48a6d9d70dfe941134cb241e988f0 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Fri, 27 Sep 2024 14:13:39 +0200 Subject: [PATCH 1/8] Explain assert_macros in the guide --- docs/src/getting-started/scarb.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/src/getting-started/scarb.md b/docs/src/getting-started/scarb.md index 39170b8156..1f3417267e 100644 --- a/docs/src/getting-started/scarb.md +++ b/docs/src/getting-started/scarb.md @@ -21,3 +21,27 @@ described [here](https://docs.swmansion.com/scarb/docs/extensions/testing.html#u Last but not least, remember that in order to use Starknet Foundry, you must have Scarb [installed](https://docs.swmansion.com/scarb/download.html) and added to the `PATH` environment variable. + + +### `assert_macros` +> ⚠️ **Recommended only for development** ️⚠️ +> +>Assert macros package provides a set of macros that can be used to write assertions. +In order to use it, your project must have the `assert_macros` dependency added to the `Scarb.toml` file. +These macros are very expensive to run on Starknet, they generate huge amount of steps and are not recommended for production use. +They are only meant to be used in tests. +For snforge `v0.31.0` and later, this dependency is added by default. But for earlier versions, you need to add it manually. + +```toml +[dev-dependencies] +snforge_std = ... +assert_macros = "" +``` + +Available assert macros are +- `assert_eq!` +- `assert_ne!` +- `assert_lt!` +- `assert_le!` +- `assert_gt!` +- `assert_ge!` \ No newline at end of file From f07aa8a0ca3eef7d83418366145e0be204d8e1f5 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Fri, 27 Sep 2024 14:44:23 +0200 Subject: [PATCH 2/8] Fix typo --- docs/src/getting-started/scarb.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/getting-started/scarb.md b/docs/src/getting-started/scarb.md index 1f3417267e..40ca2e9180 100644 --- a/docs/src/getting-started/scarb.md +++ b/docs/src/getting-started/scarb.md @@ -28,7 +28,7 @@ Last but not least, remember that in order to use Starknet Foundry, you must hav > >Assert macros package provides a set of macros that can be used to write assertions. In order to use it, your project must have the `assert_macros` dependency added to the `Scarb.toml` file. -These macros are very expensive to run on Starknet, they generate huge amount of steps and are not recommended for production use. +These macros are very expensive to run on Starknet, they generate a huge amount of steps and are not recommended for production use. They are only meant to be used in tests. For snforge `v0.31.0` and later, this dependency is added by default. But for earlier versions, you need to add it manually. From 8cfc7e9ab7feac15ef02a5d70753d54a7a91cb5e Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Mon, 30 Sep 2024 08:37:17 +0200 Subject: [PATCH 3/8] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Artur Michałek <52135326+cptartur@users.noreply.github.com> --- docs/src/getting-started/scarb.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/getting-started/scarb.md b/docs/src/getting-started/scarb.md index 40ca2e9180..7f75073180 100644 --- a/docs/src/getting-started/scarb.md +++ b/docs/src/getting-started/scarb.md @@ -26,9 +26,9 @@ Last but not least, remember that in order to use Starknet Foundry, you must hav ### `assert_macros` > ⚠️ **Recommended only for development** ️⚠️ > ->Assert macros package provides a set of macros that can be used to write assertions. +>Assert macros package provides a set of macros that can be used to write assertions such as `assert_eq!`. In order to use it, your project must have the `assert_macros` dependency added to the `Scarb.toml` file. -These macros are very expensive to run on Starknet, they generate a huge amount of steps and are not recommended for production use. +These macros are very expensive to run on Starknet, as they result a huge amount of steps and are not recommended for production use. They are only meant to be used in tests. For snforge `v0.31.0` and later, this dependency is added by default. But for earlier versions, you need to add it manually. From e269d0803006636d7fda3bbd1e91d9c5f9ce9435 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Mon, 30 Sep 2024 10:11:34 +0200 Subject: [PATCH 4/8] Make text bold --- docs/src/getting-started/scarb.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/getting-started/scarb.md b/docs/src/getting-started/scarb.md index 7f75073180..6e3e3538a0 100644 --- a/docs/src/getting-started/scarb.md +++ b/docs/src/getting-started/scarb.md @@ -26,11 +26,11 @@ Last but not least, remember that in order to use Starknet Foundry, you must hav ### `assert_macros` > ⚠️ **Recommended only for development** ️⚠️ > ->Assert macros package provides a set of macros that can be used to write assertions such as `assert_eq!`. +>***Assert macros package provides a set of macros that can be used to write assertions such as `assert_eq!`. In order to use it, your project must have the `assert_macros` dependency added to the `Scarb.toml` file. These macros are very expensive to run on Starknet, as they result a huge amount of steps and are not recommended for production use. They are only meant to be used in tests. -For snforge `v0.31.0` and later, this dependency is added by default. But for earlier versions, you need to add it manually. +For snforge `v0.31.0` and later, this dependency is added by default. But for earlier versions, you need to add it manually.*** ```toml [dev-dependencies] From fcaefb7b60551d783321c00e443f4f68b19b8fc6 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Mon, 30 Sep 2024 10:19:28 +0200 Subject: [PATCH 5/8] Move 'assert_macros' section to 'testing_md' --- docs/src/getting-started/scarb.md | 24 ------------------------ docs/src/testing/testing.md | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/docs/src/getting-started/scarb.md b/docs/src/getting-started/scarb.md index 6e3e3538a0..39170b8156 100644 --- a/docs/src/getting-started/scarb.md +++ b/docs/src/getting-started/scarb.md @@ -21,27 +21,3 @@ described [here](https://docs.swmansion.com/scarb/docs/extensions/testing.html#u Last but not least, remember that in order to use Starknet Foundry, you must have Scarb [installed](https://docs.swmansion.com/scarb/download.html) and added to the `PATH` environment variable. - - -### `assert_macros` -> ⚠️ **Recommended only for development** ️⚠️ -> ->***Assert macros package provides a set of macros that can be used to write assertions such as `assert_eq!`. -In order to use it, your project must have the `assert_macros` dependency added to the `Scarb.toml` file. -These macros are very expensive to run on Starknet, as they result a huge amount of steps and are not recommended for production use. -They are only meant to be used in tests. -For snforge `v0.31.0` and later, this dependency is added by default. But for earlier versions, you need to add it manually.*** - -```toml -[dev-dependencies] -snforge_std = ... -assert_macros = "" -``` - -Available assert macros are -- `assert_eq!` -- `assert_ne!` -- `assert_lt!` -- `assert_le!` -- `assert_gt!` -- `assert_ge!` \ No newline at end of file diff --git a/docs/src/testing/testing.md b/docs/src/testing/testing.md index ac6f581581..3b7050d850 100644 --- a/docs/src/testing/testing.md +++ b/docs/src/testing/testing.md @@ -105,3 +105,26 @@ Tests: 0 passed, 0 failed, 0 skipped, 1 ignored, 0 filtered out To run only tests marked with the `#[ignore]` attribute use `snforge test --ignored`. To run all tests regardless of the `#[ignore]` attribute use `snforge test --include-ignored`. + +## `assert_macros` +> ⚠️ **Recommended only for development** ️⚠️ +> +>***Assert macros package provides a set of macros that can be used to write assertions such as `assert_eq!`. +In order to use it, your project must have the `assert_macros` dependency added to the `Scarb.toml` file. +These macros are very expensive to run on Starknet, as they result a huge amount of steps and are not recommended for production use. +They are only meant to be used in tests. +For snforge `v0.31.0` and later, this dependency is added by default. But for earlier versions, you need to add it manually.*** + +```toml +[dev-dependencies] +snforge_std = ... +assert_macros = "" +``` + +Available assert macros are +- `assert_eq!` +- `assert_ne!` +- `assert_lt!` +- `assert_le!` +- `assert_gt!` +- `assert_ge!` From e3ff44095e525ff2e6f85fb5d43d1cf5bf2d6dc9 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Mon, 30 Sep 2024 15:38:00 +0200 Subject: [PATCH 6/8] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Artur Michałek <52135326+cptartur@users.noreply.github.com> --- docs/src/testing/testing.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/testing/testing.md b/docs/src/testing/testing.md index 3b7050d850..9d712e00f4 100644 --- a/docs/src/testing/testing.md +++ b/docs/src/testing/testing.md @@ -106,14 +106,14 @@ Tests: 0 passed, 0 failed, 0 skipped, 1 ignored, 0 filtered out To run only tests marked with the `#[ignore]` attribute use `snforge test --ignored`. To run all tests regardless of the `#[ignore]` attribute use `snforge test --include-ignored`. -## `assert_macros` +## Writing Assertions and `assert_macros` Package > ⚠️ **Recommended only for development** ️⚠️ > >***Assert macros package provides a set of macros that can be used to write assertions such as `assert_eq!`. In order to use it, your project must have the `assert_macros` dependency added to the `Scarb.toml` file. These macros are very expensive to run on Starknet, as they result a huge amount of steps and are not recommended for production use. They are only meant to be used in tests. -For snforge `v0.31.0` and later, this dependency is added by default. But for earlier versions, you need to add it manually.*** +For snforge `v0.31.0` and later, this dependency is added automatically when creating a project using `snforge init`. But for earlier versions, you need to add it manually.*** ```toml [dev-dependencies] From 4b2f28999f04249b035241c37c1d984d490a9746 Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Mon, 30 Sep 2024 15:53:41 +0200 Subject: [PATCH 7/8] Add link to 'Using Cheatcod' paragraph --- docs/src/testing/using-cheatcodes.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/src/testing/using-cheatcodes.md b/docs/src/testing/using-cheatcodes.md index 33a6e71d46..b4af3bdf4c 100644 --- a/docs/src/testing/using-cheatcodes.md +++ b/docs/src/testing/using-cheatcodes.md @@ -14,6 +14,10 @@ When testing smart contracts, often there are parts of code that are dependent o Instead of trying to replicate these conditions in tests, you can emulate them using [cheatcodes](../appendix/cheatcodes.md). +> ⚠️ **Warning** +> +> These examples make use of `assert_macros`, so it's recommended to get familiar with them first. [Learn more about `assert_macros`](../testing.md#writing-assertions-and-assert_macros-package) + ## The Test Contract In this tutorial, we will be using the following Starknet contract: From 7d0cd5fcf52a2f9fbf2781f6bf9584d3fc3bd1cc Mon Sep 17 00:00:00 2001 From: kkawula <57270771+kkawula@users.noreply.github.com> Date: Mon, 30 Sep 2024 16:01:28 +0200 Subject: [PATCH 8/8] Fix file link --- docs/src/testing/using-cheatcodes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/testing/using-cheatcodes.md b/docs/src/testing/using-cheatcodes.md index b4af3bdf4c..b67c555272 100644 --- a/docs/src/testing/using-cheatcodes.md +++ b/docs/src/testing/using-cheatcodes.md @@ -16,7 +16,7 @@ using [cheatcodes](../appendix/cheatcodes.md). > ⚠️ **Warning** > -> These examples make use of `assert_macros`, so it's recommended to get familiar with them first. [Learn more about `assert_macros`](../testing.md#writing-assertions-and-assert_macros-package) +> These examples make use of `assert_macros`, so it's recommended to get familiar with them first. [Learn more about `assert_macros`](testing.md#writing-assertions-and-assert_macros-package) ## The Test Contract