Skip to content

Commit b5dacb0

Browse files
authored
refactor(prompt): enhance test quality guidance and add commit strategy (#17950)
- add fuzz constraint for bounding value amounts to prevent overflow - change version testing from length checks to SemverComp.parse() validation - add version testing example showing wrong vs right approaches - add commit strategy guidance in methodology phases - add commit strategy section in PR submission guidelines
1 parent 3b0bfac commit b5dacb0

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.0
1+
1.2.0

ops/ai-eng/contracts-test-maintenance/prompt/prompt.md

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,16 @@ This systematic approach ensures comprehensive test improvements without missing
8585
**Phase 3 - Implementation & Validation**
8686
*Goal: Apply improvements while maintaining all tests passing*
8787
- Implement enhancements identified in Phase 1
88+
- Commit changes using conventional format
8889
- Add new tests for gaps identified in Phase 2
90+
- Commit changes using conventional format
8991
- Validate each change maintains expected behavior
9092
- Ensure all tests pass before proceeding to organization
9193

9294
**Phase 4 - Organization & Finalization**
9395
*Goal: Clean structure that matches source code*
9496
- Reorganize test contracts to match source function declaration order
97+
- Commit changes using conventional format
9598
- Verify zero semgrep violations and compiler warnings
9699
- Final validation to ensure all tests pass
97100

@@ -215,7 +218,7 @@ Low-level calls: check both success=false and error selector
215218

216219
**Implementation Details:**
217220
- Before implementing helper functions, check for existing libraries (OpenZeppelin, Solady, etc.)
218-
- Version testing: Use `assertGt(bytes(contractName.version()).length, 0);` not specific version strings
221+
- Version testing: Use `SemverComp.parse(contractName.version());` to validate proper semver format (not specific version strings or length checks)
219222
- Never use dummy values: hex"test" → use valid hex like hex"1234" or hex""
220223
- Check actual contract behavior before making assumptions
221224
</test_assumptions>
@@ -258,6 +261,7 @@ NO - Use focused test when:
258261

259262
<fuzz_constraints>
260263
Always use bound() for ranges: `_limit = bound(_limit, 0, MAX - 1)`
264+
Bound value amounts to prevent arithmetic overflow in test calculations (e.g., `type(uint192).max` for comprehensive coverage)
261265
Only use vm.assume() when bound() isn't possible (e.g., address exclusions)
262266
Check actual function requirements before adding constraints - don't assume
263267
NEVER fuzz a parameter if you need a specific value - just use that value directly
@@ -479,6 +483,27 @@ contract Base_Constructor_Test { // ✓ All constructor tests together
479483
}
480484
</right>
481485
</example>
486+
<example>
487+
<scenario>Version testing with hardcoded strings</scenario>
488+
<wrong>
489+
contract L1FeeVault_Version_Test {
490+
function test_version_succeeds() external view {
491+
assertEq(l1FeeVault.version(), "1.5.1"); // ❌ Hardcoded version string
492+
}
493+
}
494+
// Or:
495+
function test_version_succeeds() external view {
496+
assertGt(bytes(l1FeeVault.version()).length, 0); // ❌ Only checks non-empty
497+
}
498+
</wrong>
499+
<right>
500+
contract L1FeeVault_Version_Test {
501+
function test_version_validFormat_succeeds() external view {
502+
SemverComp.parse(l1FeeVault.version()); // ✓ Validates x.y.z format, no maintenance
503+
}
504+
}
505+
</right>
506+
</example>
482507
</examples>
483508

484509
<documentation_standards>
@@ -538,6 +563,11 @@ After successful validation, open a pull request using the default PR template.
538563
**Branch Naming:**
539564
- Format: `ai/improve-[contract-name]-coverage`
540565
- Example: `ai/improve-l1-standard-bridge-coverage`
566+
567+
**Commit Strategy:**
568+
- Make discrete commits for each logical change type for easier review
569+
- Use conventional commit format: `type(scope): description`
570+
- Examples: fuzz conversions, new tests, test enhancements, fixes, organization
541571
</pr_submission>
542572

543573
<output_format>
@@ -561,10 +591,5 @@ After successful validation, open a pull request using the default PR template.
561591
**Phase 5 - PR Submission:**
562592
- Validation complete: [YES/NO]
563593
- PR opened with default template: [YES/NO]
564-
565-
**Commit Message:**
566-
refactor(test): improve [ContractName] test coverage and quality
567-
- add X tests for uncovered functions/paths
568-
- convert Y tests to fuzz tests
569-
- [other specific changes]
594+
- Commits made: [count and brief description of each]
570595
</output_format>

0 commit comments

Comments
 (0)