-
Notifications
You must be signed in to change notification settings - Fork 9
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
Fix run-constructor option #404
Conversation
Thanks for fixing this. I would suggest the second option. Right now the |
Would this PR address the issue of initialising non-constant variables with default values? |
@PetarMax I think it's supported and checked in ContructorTest: // SPDX-License-Identifier: UNLICENSED
pragma solidity =0.8.13;
import "forge-std/Test.sol";
contract ConstructorTest is Test {
bool flag = true;
function test_constructor() public {
assert(flag);
}
function testFail_constructor() public {
assert(!flag);
}
} Or do you mean something else? |
Yes, that's what I meant - does it also work for analysing non-tests (i.e., functions in isolation)? |
I think it should, but not sure. @qian-hu could you please check if this works when running a proof for a function that doesn't start with |
@PetarMax, yes, it works for analyzing non-tests. The |
Thanks @PetarMax and @qian-hu! It all looks good to me now; my only remaining request is to a non-test, now that it won't crash on
and assert that — as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approved this PR to unblock, but left several suggestions on tests.
src/tests/integration/test-data/foundry/test/ConstructorTest.t.sol
Outdated
Show resolved
Hide resolved
@qian-hu the PR looks great, many thanks for addressing all the comments! |
Closes #335.
Addresses #66.
The current implementation requires using the end of the constructor's proof as the initial state for the test proof when the '--run-constructor' option is activated. However, an issue arises when this option is enabled while running a proof on a contract without a constructor - the initialization code fails to execute. In such cases, it disrupts the execution continuity as it lacks the end of the constructor's initial proof.
This PR proposes two potential solutions to address the abovementioned issue. The initial solution involves raising an error message to guide the user in providing a contract constructor. A more practical alternative suggests treating a contract without an explicit constructor as one with an empty constructor. This modification would also enable initializing the value assignments outside of functions in such cases, as in:
The second approach is adopted to address issues of initializing variables.