Skip to content

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented Jun 10, 2025

What I did

this makes it easier to programmatically generate vyper source code, which will make it easier to write parametrized tests in the test suite.

How I did it

How to verify it

Commit message

Commit message for the final, squashed PR. (Optional, but reviewers will appreciate it! Please see our commit message style guide for what we would ideally like to see in a commit message.)

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

this makes it easier to programmatically generate vyper source code,
which will make it easier to write parametrized tests in the test suite.
Copy link

codecov bot commented Jun 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.00%. Comparing base (812d903) to head (fc7d4ef).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4691      +/-   ##
==========================================
+ Coverage   92.99%   93.00%   +0.01%     
==========================================
  Files         131      131              
  Lines       19094    19095       +1     
  Branches     3324     3324              
==========================================
+ Hits        17757    17760       +3     
+ Misses        899      898       -1     
+ Partials      438      437       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@charles-cooper charles-cooper marked this pull request as ready for review June 26, 2025 10:35
"""Add a transient storage variable."""
name, typ = self._parse_declaration(declaration)
self._transient_vars.append(f"{name}: transient({typ})")
return VarRef(name, typ, "transient", "public")
Copy link
Collaborator

Choose a reason for hiding this comment

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

vars will be public by default?

typ = parts[1][type_start:type_end].strip()

self._constants.append(declaration)
return VarRef(name, typ, "constant", None)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why does the visibility for constants differ?

def immutable(self, declaration: str) -> VarRef:
"""Add an immutable variable."""
name, typ = self._parse_declaration(declaration)
self._immutables.append(f"{name}: immutable({typ})")
Copy link
Collaborator

Choose a reason for hiding this comment

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

for immutables we don't have to declare with "immutable" but for constants "constant" is required?

@cyberthirst
Copy link
Collaborator

the model seems to be missing features like pragmas, interfaces, module-related machinery (imports, initialization,..)

@cyberthirst
Copy link
Collaborator

cyberthirst commented Aug 13, 2025

looks reasonable overall, for parametric tests it could be an improvement over status quo

for simple tests, it's a bit hard to read

code = """
owner: address

@deploy
def __init__(initial_count: uint256):
    self.count = initial_count
    self.owner = msg.sender

@external
def increment():
    self.count += 1

@external
@view
def get_count() -> uint256:
    return self.count
 """"

vs

    model = CodeModel()

   count = model.storage_var("count: uint256")
   owner = model.storage_var("owner: address")

   code = (
       model.function("__init__(initial_count: uint256)")
       .deploy()
       .body(
           f"""
           {count} = initial_count
           {owner} = msg.sender
       """
       )
       .done()
       .function("increment()")
       .external()
       .body(f"{count} += 1")
       .done()
       .function("get_count() -> uint256")
       .external()
       .view()
       .body(f"return {count}")
       .done()
       .build()
   )

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.

2 participants