Is this related to a problem?
The validateAndFixCode() function in apps/web/src/lib/tools/generateStylusCode.ts applies 6 phases of code fixes but has zero test coverage. This function is critical — it runs on every code generation request on the hosted service.
Describe the feature
Create a test file with cases for each of the 6 fix phases:
- Structural — fix
#![cfg_attr] attributes, add missing extern crate alloc
- Imports — add missing
use alloc::string::String, use alloy_sol_types::sol
- Storage accessors — fix
.get(k).get_string(), .setter(k).set_str()
- API migration —
msg::sender() → self.vm().msg_sender()
- Types —
B32 → B256, .as_u64() → .to::<u64>()
- Output sanitizer — remove garbled LLM output, fix duplicate functions
Which module does this relate to?
Example usage
test("Fix 40: removes Debug from SolidityError derive", () => {
const input = '#[derive(SolidityError, Debug)]';
const result = validateAndFixCode(input);
expect(result).toContain('#[derive(SolidityError)]');
expect(result).not.toContain('Debug');
});
Additional context
- Python equivalent tests are in
tests/mcp_tools/test_generate_stylus_code.py
- Check
package.json for test framework (vitest or jest)
Is this related to a problem?
The
validateAndFixCode()function inapps/web/src/lib/tools/generateStylusCode.tsapplies 6 phases of code fixes but has zero test coverage. This function is critical — it runs on every code generation request on the hosted service.Describe the feature
Create a test file with cases for each of the 6 fix phases:
#![cfg_attr]attributes, add missingextern crate allocuse alloc::string::String,use alloy_sol_types::sol.get(k).get_string(),.setter(k).set_str()msg::sender()→self.vm().msg_sender()B32→B256,.as_u64()→.to::<u64>()Which module does this relate to?
Example usage
Additional context
tests/mcp_tools/test_generate_stylus_code.pypackage.jsonfor test framework (vitest or jest)