Skip to content

Commit 861e543

Browse files
authored
Add docs for new flag (#3609)
commit-id:04335540 --- **Stack**: - #3612 - #3609⚠️ *Part of a stack created by [spr](https://github.com/ejoffe/spr). Do not merge manually using the UI - doing so may have unexpected results.*
1 parent 0f628e5 commit 861e543

File tree

3 files changed

+85
-6
lines changed

3 files changed

+85
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919

2020
- If using a Scarb version before `2.10.0` or not using `allow-prebuild-plugins`, the minimal required rust version to run `snforge` is now `1.87.0`
2121

22+
#### Added
23+
24+
- `--trace-components` flag to allow selecting which components of the trace to do display. Read more [here](https://foundry-rs.github.io/starknet-foundry/snforge-advanced-features/debugging.html#trace-components)
25+
2226
### Cast
2327

2428
#### Added

docs/src/appendix/snforge/test.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,30 @@ Passing a test filter will only run tests with
88
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)
99
containing this filter.
1010

11+
## `--trace-verbosity <TRACE_VERBOSITY>`
12+
13+
Sets the level of detail shown in execution traces.
14+
15+
Valid values:
16+
17+
- `minimal`: Only test name, contract name, and selector
18+
- `standard`: Includes calldata and call result
19+
- `detailed`: Full trace, including nested calls, caller address, and panic reasons
20+
21+
## `--trace-components <TRACE_COMPONENTS>...`
22+
23+
Selects specific trace elements to include in the execution flow output.
24+
25+
Available components:
26+
27+
- `contract-name`
28+
- `entry-point-type`
29+
- `calldata`
30+
- `contract-address`
31+
- `caller-address`
32+
- `call-type`
33+
- `call-result`
34+
1135
## `-e`, `--exact`
1236

1337
Will only run a test with a name exactly matching the test filter.

docs/src/snforge-advanced-features/debugging.md

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,68 @@ of the issue. To aid in debugging, `snforge` offers following features:
1414
> Currently, the flow of execution trace is only available at the contract level. In future versions, it will also be
1515
> available at the function level.
1616
17-
You can inspect the flow of execution for your tests using the `--trace-verbosity` flag when running the `snforge test`
18-
command. This is useful for understanding how contracts are interacting with each other during your tests, especially in
19-
complex nested scenarios.
17+
You can inspect the flow of execution for your tests using the `--trace-verbosity` or `--trace-components` flags when
18+
running the `snforge test` command. This is useful for understanding how contracts are interacting with each other
19+
during your tests, especially in complex nested scenarios.
20+
21+
### Trace Components
22+
23+
The `--trace-components` flag allows you to specify which components of the trace you want to see. You can choose from:
24+
25+
- `contract-name`: the name of the contract being called
26+
- `entry-point-type`: the type of the entry point being called (e.g., `External`, `L1Handler`, etc.)
27+
- `calldata`: the calldata of the call, transformed for display
28+
- `contract-address`: the address of the contract being called
29+
- `caller-address`: the address of the caller contract
30+
- `call-type`: the type of the call (e.g., `Call`, `Delegate`, etc.)
31+
- `call-result`: the result of the call, transformed for display
32+
33+
Example usage:
34+
35+
<!-- { "package_name": "debugging" } -->
36+
```shell
37+
$ snforge test --trace-components contract-name call-result call-type
38+
```
39+
<details>
40+
<summary>Output:</summary>
41+
42+
```shell
43+
[test name] trace_info_integrationtest::test_trace::test_debugging_trace_success
44+
├─ [selector] execute_calls
45+
│ ├─ [contract name] SimpleContract
46+
│ ├─ [call type] Call
47+
│ ├─ [call result] success: array![RecursiveCall { contract_address: ContractAddress([..]), payload: array![RecursiveCall { contract_address: ContractAddress([..]), payload: array![] }, RecursiveCall { contract_address: ContractAddress([..]), payload: array![] }] }, RecursiveCall { contract_address: ContractAddress([..]), payload: array![] }]
48+
│ ├─ [selector] execute_calls
49+
│ │ ├─ [contract name] SimpleContract
50+
│ │ ├─ [call type] Call
51+
│ │ ├─ [call result] success: array![RecursiveCall { contract_address: ContractAddress([..]), payload: array![] }, RecursiveCall { contract_address: ContractAddress([..]), payload: array![] }]
52+
│ │ ├─ [selector] execute_calls
53+
│ │ │ ├─ [contract name] SimpleContract
54+
│ │ │ ├─ [call type] Call
55+
│ │ │ └─ [call result] success: array![]
56+
│ │ └─ [selector] execute_calls
57+
│ │ ├─ [contract name] SimpleContract
58+
│ │ ├─ [call type] Call
59+
│ │ └─ [call result] success: array![]
60+
│ └─ [selector] execute_calls
61+
│ ├─ [contract name] SimpleContract
62+
│ ├─ [call type] Call
63+
│ └─ [call result] success: array![]
64+
└─ [selector] fail
65+
├─ [contract name] SimpleContract
66+
├─ [call type] Call
67+
└─ [call result] panic: (0x1, 0x2, 0x3, 0x4, 0x5)
68+
```
69+
</details>
70+
<br>
2071
2172
### Verbosity Levels
2273
2374
The `--trace-verbosity` flag accepts the following values:
2475
25-
- **minimal**: Shows test name, contract name, and selector.
26-
- **standard**: Includes test name, contract name, selector, calldata, and call result.
27-
- **detailed**: Displays the entire trace, including internal calls, caller addresses, and panic reasons.
76+
- `minimal`: shows test name, contract name, and selector
77+
- `standard`: includes test name, contract name, selector, calldata, and call result
78+
- `detailed`: displays the entire trace, including internal calls, caller addresses, and panic reasons
2879
2980
Example usage:
3081

0 commit comments

Comments
 (0)