You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: contracts/stream_contract/README.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -104,6 +104,10 @@ Error codes from `src/errors.rs`:
104
104
| 10 |`InvalidTokenAddress`| Token address is not a token contract |
105
105
| 11 |`InvalidRate`|`amount / duration` rounds to zero |
106
106
107
+
## Test Snapshots
108
+
109
+
The Soroban test runner can generate storage snapshots under `test_snapshots/` when `SOROBAN_TEST_SNAPSHOTS=1` is set. See [`test_snapshots/README.md`](test_snapshots/README.md) for what they are, when they regenerate, and how to handle a snapshot diff in your PR.
110
+
107
111
## Typical flow
108
112
109
113
1. Admin calls `initialize` with treasury and fee rate.
This directory is auto-generated by the Soroban test runner when snapshot testing is enabled. Snapshots record the persistent storage state and event output of each `#[test]` — changes in a snapshot diff signal that a test's on-chain behavior has changed.
4
+
5
+
## When snapshots are regenerated
6
+
7
+
Snapshots are regenerated whenever you run `cargo test` (or the workspace equivalent) with the `SOROBAN_TEST_SNAPSHOTS` environment variable set:
8
+
9
+
```shell
10
+
SOROBAN_TEST_SNAPSHOTS=1 cargo test
11
+
```
12
+
13
+
Without this variable, snapshot files are not written and existing snapshots are ignored.
14
+
15
+
## What to do when a snapshot diff appears in your PR
16
+
17
+
A snapshot diff in `git status` means either:
18
+
19
+
1.**You intentionally changed contract behavior** (e.g. a new feature, a bug fix, a storage layout change) — regenerate the snapshots on your branch and commit the updated files so CI matches.
20
+
21
+
2.**You did not expect behavior to change** — investigate whether the diff reveals a real logic regression. The snapshot captures the raw storage keys and event payloads; a change in `deposited_amount`, `rate_per_second`, or a missing event may indicate a subtle bug.
22
+
23
+
**Always regenerate and commit snapshots alongside the code change that causes them.** A PR that alters contract logic without updating snapshots will fail CI and confuse reviewers.
24
+
25
+
## Out of scope
26
+
27
+
Snapshots are a Soroban framework feature, not a custom testing tool. This file explains their workflow purpose only.
0 commit comments