Skip to content

Allow changing prefix from prove via --prefix in test mode #745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 19, 2025

Conversation

msooseth
Copy link
Collaborator

Description

Currently, default prefix is "prove" as per documentation. Actually, we also accept "check". This PR allows us to change this from "prove" to any other value. We also drop "check" as a prefix that's accepted. The "check" was never advertised, so I think it's valid to remove? It makes the code simpler, and I think it's OK this way, as --prefix check can always be used to be backwards-compatible. This change is highlighted in the changelog.

Checklist

  • tested locally
  • added automated tests
  • updated the docs
  • updated the changelog

@msooseth msooseth changed the title Allow changing prefix from prove Allow changing prefix from prove via --prefix in test mode May 14, 2025
@@ -27,7 +27,6 @@ data DappInfo = DappInfo
, solcByHash :: Map W256 (CodeType, SolcContract)
, solcByCode :: [(Code, SolcContract)] -- for contracts with `immutable` vars.
, sources :: SourceCache
, unitTests :: [(Text, [Sig])]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was actually unused

@@ -57,7 +56,6 @@ dappInfo root (BuildOutput (Contracts cs) sources) =

in DappInfo
{ root = root
, unitTests = findAllUnitTests solcs
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was actually unused, and so findAllUnitTests was also unused.

Comment on lines -95 to -97
findAllUnitTests :: [SolcContract] -> [(Text, [Sig])]
findAllUnitTests = findUnitTests ".*:.*\\.(check|prove).*"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This function was unused.

@msooseth msooseth marked this pull request as ready for review May 14, 2025 17:06
@blishko
Copy link
Collaborator

blishko commented May 15, 2025

I don't think we need to pass the prefix through all the methods.
For example, unitTestMethodsFiltered already takes a filter, Text -> Bool. I think we should just include the check for the prefix in this filter.
mkSig does not need to do any filtering, it can return Sig instead of MaybeSig.

Though I am not sure if I understand correctly the match option. From the code, I inferred that it is a regex, but does it match against contract name or again method names?

@msooseth
Copy link
Collaborator Author

I don't think we need to pass the prefix through all the methods. For example, unitTestMethodsFiltered already takes a filter, Text -> Bool. I think we should just include the check for the prefix in this filter. mkSig does not need to do any filtering, it can return Sig instead of MaybeSig.

Though I am not sure if I understand correctly the match option. From the code, I inferred that it is a regex, but does it match against contract name or again method names?

It allows to match against both contract and method names via contractname.methodname:

  let testName (Sig n _) = c.contractName <> "." <> n

Which matcher is ran against. However, prefix is matched only against the method name. What do you think we should do?

@msooseth msooseth force-pushed the allow-change-prove-prefix branch from 11f2ab2 to 33b5001 Compare May 16, 2025 13:50
@msooseth msooseth added the enhancement New feature or request label May 16, 2025
Copy link
Collaborator

@blishko blishko left a comment

Choose a reason for hiding this comment

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

I was hoping there is nice way to unify matching against contract and method name and against method prefix.

But I don't see one right now. So if you also don't see a nice way to simplify this, then let's merge it and move on!

@msooseth msooseth merged commit 8c36e83 into main May 19, 2025
9 checks passed
@blishko blishko deleted the allow-change-prove-prefix branch May 20, 2025 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants