Skip to content

Extract class FuzzSpec#65

Open
tothtamas28 wants to merge 9 commits intomasterfrom
contract-metadata-format
Open

Extract class FuzzSpec#65
tothtamas28 wants to merge 9 commits intomasterfrom
contract-metadata-format

Conversation

@tothtamas28
Copy link
Copy Markdown
Contributor

@tothtamas28 tothtamas28 commented May 4, 2026

Refactors the contract fuzzing pipeline around two new named tuple types, Signature and FuzzSpec.

Signature (in contract.py)

Replaces direct use of Method objects throughout the fuzzing pipeline. A Signature captures only the information needed to fuzz a method (its contract name, function name, and argument types) and owns the logic that was previously spread across free functions:

  • get_arg_types becomes the private Signature._extract_arg_types
  • argument_strategy becomes Signature.argument_strategy()
  • A new qualified_name property replaces repeated f'{...contract_name}.{...name}' formatting

FuzzSpec (in skribe.py)

Groups the KORE template pattern and the tuple of Signatures produced from a contract into a single value. A new create_spec method on Skribe produces it, and create_template_pattern is extracted as a helper. The dict property on FuzzSpec serializes the data structure.

Other cleanup

  • KORE template setup is pulled out of run_test into create_template_pattern, so run_test now takes a ready Pattern instead of a KAST config + substitution pair
  • Imports are converted to relative throughout
  • src/tests/ is excluded from the source distribution

@tothtamas28 tothtamas28 self-assigned this May 4, 2026
@tothtamas28 tothtamas28 force-pushed the contract-metadata-format branch from c0ebaeb to e4fddb3 Compare May 4, 2026 15:09
@tothtamas28 tothtamas28 force-pushed the contract-metadata-format branch 2 times, most recently from 83bcad4 to f1d6027 Compare May 4, 2026 15:20
@tothtamas28 tothtamas28 marked this pull request as ready for review May 4, 2026 16:01
@tothtamas28 tothtamas28 force-pushed the contract-metadata-format branch 2 times, most recently from 19e6f11 to eb3dd51 Compare May 5, 2026 09:45
@tothtamas28 tothtamas28 changed the title Extract class SkribeMetadata Extract class FuzzSpec May 5, 2026
@tothtamas28 tothtamas28 force-pushed the contract-metadata-format branch from 44f3bb1 to 7e3523b Compare May 5, 2026 12:35
Comment thread src/skribe/skribe.py
else:
res = [sig for sig in signatures if sig.name == id]
if res:
raise KeyError(f'Test function {id!r} not found.')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to drop this exception. When this was introduced, we only supported a single test contract per project, so it was reasonable. With multiple test contracts, contracts that don’t have a function with the given name end up causing an exception. Instead, they should be skipped rather than failing the run. Since you are already touching this code, I think it’s a good opportunity to include this small change.

Copy link
Copy Markdown
Member

@bbyalcinkaya bbyalcinkaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants