-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f92068b
commit 0568531
Showing
8 changed files
with
69 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
| id | Properties | Type | | ||
| Id | Properties | Type | | ||
| --- | --------------------------------------------------- | ------------ | | ||
| 1 | Greeting should never be empty | Valid state | | ||
| 2 | Only the owner can set the greeting | State transition | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.23; | ||
|
||
import {GreeterGuidedHandlers} from './handlers/guided/Greeter.t.sol'; | ||
import {GreeterUnguidedHandlers} from './handlers/unguided/Greeter.t.sol'; | ||
import {GreeterProperties} from './properties/Greeter.t.sol'; | ||
|
||
contract FuzzTest is GreeterGuidedHandlers, GreeterUnguidedHandlers, GreeterProperties {} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.23; | ||
|
||
import {GreeterSetup} from '../../setup/Greeter.t.sol'; | ||
|
||
contract GreeterGuidedHandlers is GreeterSetup { | ||
function handler_setGreeting(string memory _newGreeting) external { | ||
// no need to prank since this contract deployed the greeter and is therefore its owner | ||
try _targetContract.setGreeting(_newGreeting) { | ||
assert(keccak256(bytes(_targetContract.greeting())) == keccak256(bytes(_newGreeting))); | ||
} catch { | ||
assert(keccak256(bytes(_newGreeting)) == keccak256('')); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.23; | ||
|
||
import {GreeterSetup} from '../../setup/Greeter.t.sol'; | ||
|
||
contract GreeterUnguidedHandlers is GreeterSetup { | ||
/// @custom:property-id 2 | ||
/// @custom:property Only the owner can set the greeting | ||
function handler_setGreeting(address _caller, string memory _newGreeting) external { | ||
vm.prank(_caller); | ||
try _targetContract.setGreeting(_newGreeting) { | ||
assert(keccak256(bytes(_targetContract.greeting())) == keccak256(bytes(_newGreeting))); | ||
assert(_caller == _targetContract.OWNER()); | ||
} catch { | ||
assert(_caller != _targetContract.OWNER() || keccak256(bytes(_newGreeting)) == keccak256('')); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.23; | ||
|
||
import {GreeterSetup} from '../setup/Greeter.t.sol'; | ||
|
||
contract GreeterProperties is GreeterSetup { | ||
/// @custom:property-id 1 | ||
/// @custom:property Greeting should never be empty | ||
function property_greetingIsNeverEmpty() external view { | ||
assert(keccak256(bytes(_targetContract.greeting())) != keccak256('')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.23; | ||
|
||
import {Greeter, IERC20} from 'contracts/Greeter.sol'; | ||
import {CommonBase} from 'forge-std/Base.sol'; | ||
|
||
contract GreeterSetup is CommonBase { | ||
Greeter internal _targetContract; | ||
|
||
constructor() { | ||
_targetContract = new Greeter('a', IERC20(address(1))); | ||
} | ||
} |