@@ -32,6 +32,83 @@ Single pallet test: `cargo test -p pallet-omnipool --locked`
3232
3333All cargo commands use ` --config net.git-fetch-with-cli=true ` (see Makefile).
3434
35+ ## Test Naming Convention
36+
37+ Use BDD-style "should-when" naming for all tests. The test name should read as a specification of behavior.
38+
39+ ** Format:** ` <subject>_should_<expected_outcome>_when_<condition> `
40+
41+ ** Examples:**
42+ - ` transfer_should_fail_when_balance_is_insufficient `
43+ - ` route_suggester_should_return_shortest_path_when_multiple_routes_exist `
44+ - ` sell_should_succeed_when_slippage_within_limit `
45+ - ` add_liquidity_should_fail_when_pool_is_frozen `
46+
47+ ** Rules:**
48+ - Use ` snake_case ` (Rust convention).
49+ - For success cases, use ` should_<outcome>_when_<condition> ` (omit "succeed" if the outcome is descriptive enough).
50+ - For failure cases, prefer ` should_fail_when_<condition> ` and assert on the specific error.
51+ - The ` <subject> ` is typically the function/extrinsic under test.
52+ - Avoid generic names like ` test_1 ` , ` it_works ` , or ` basic_test ` .
53+ - One behavior per test — if you need "and" in the name, split it into two tests.
54+
55+ ## Extrinsic documentation
56+
57+ Every public extrinsic in ` #[pallet::call] ` blocks must have a rustdoc comment that follows
58+ this standard structure. See ` pallets/omnipool/src/lib.rs ` and ` pallets/stableswap/src/lib.rs `
59+ for canonical examples.
60+
61+ ** Required sections (in order):**
62+
63+ 1 . ** Description** — one-line summary, then any longer explanation as additional paragraphs.
64+ Cover what the extrinsic does, important preconditions, and notable side effects (NFT
65+ minting, hooks, tradability flags, error conditions worth highlighting).
66+ 2 . ** Parameters** — a ` Parameters: ` block listing every argument as `` - `name`: description `` .
67+ Include ` origin ` when its required type is non-trivial (e.g. ` T::AuthorityOrigin ` ).
68+ 3 . ** Emitted events** — a final line of the form `` Emits `EventName` event when successful. ``
69+ If multiple events are emitted, list each on its own line.
70+
71+ ** Format:**
72+
73+ ``` rust
74+ /// <One-line summary of what the extrinsic does.>
75+ ///
76+ /// <Optional longer explanation: preconditions, side effects, error conditions,
77+ /// hook invocations, tradability flags, etc. Use multiple paragraphs as needed.>
78+ ///
79+ /// Parameters:
80+ /// - `origin`: <only if origin type is non-trivial, e.g. Must be T::AuthorityOrigin>
81+ /// - `param_a`: <what it represents and any constraints>
82+ /// - `param_b`: <what it represents and any constraints>
83+ ///
84+ /// Emits `SomethingHappened` event when successful.
85+ ///
86+ #[pallet:: call_index(N )]
87+ #[pallet:: weight(... )]
88+ #[transactional]
89+ pub fn my_extrinsic (... ) -> DispatchResult { ... }
90+ ```
91+
92+ ** Rules:**
93+ - Use ` /// ` doc comments (rustdoc), not ` // ` line comments.
94+ - Blank ` /// ` lines separate paragraphs and the three sections.
95+ - Wrap identifiers, types, and values in backticks (e.g. `` `asset_id` `` , `` `T::AuthorityOrigin` `` ).
96+ - Phrase the emitted-events line consistently: `` Emits `X` event when successful. ``
97+ - If the extrinsic delegates to another (e.g. ` add_liquidity ` → ` add_liquidity_with_limit ` ),
98+ still document it in full — do not rely on the reader following the delegation.
99+ - Keep parameter names in the doc identical to the function signature.
100+
101+ ## Running tests
102+
103+ Dont't run tests with --release flag!
104+
105+ Do NOT prefix ` cargo ` commands with inline environment variables like
106+ ` RUST_LOG=... cargo test ` . Instead, export them first:
107+
108+ export RUST_LOG=evm=error
109+ cargo test --locked -p runtime-integration-tests ...
110+
111+
35112## Code style
36113
37114- ** Tabs for indentation** (hard_tabs = true), max line width 120
0 commit comments