-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add k code for mockFunction cheatcode * Fix k code * Add test * Set Version: 0.1.346 * Add tests for mock functions with args, provided and not. Fix K rule so it handles these cases * Set Version: 0.1.348 * enable tests and update contract and foundry files * Update expected files to show new cheatcode cell * Set Version: 0.1.349 * Update kontrol cheatcodes ref * Update kontrol-cheatcodes ref in workflow file * Set Version: 0.1.350 * Update bytecode in circularity lemma * Update expected output * Set Version: 0.1.351 * Set Version: 0.1.353 * Improve formatting * Update src/kontrol/kdist/cheatcodes.md * Set Version: 0.1.356 * Set Version: 0.1.357 * Set Version: 0.1.358 --------- Co-authored-by: devops <devops@runtimeverification.com> Co-authored-by: Palina Tolmach <polina.tolmach@gmail.com>
- Loading branch information
1 parent
3cc4186
commit 302d446
Showing
59 changed files
with
973 additions
and
6 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 +1 @@ | ||
0.1.357 | ||
0.1.358 |
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 |
---|---|---|
|
@@ -5,4 +5,4 @@ | |
if TYPE_CHECKING: | ||
from typing import Final | ||
|
||
VERSION: Final = '0.1.357' | ||
VERSION: Final = '0.1.358' |
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
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
75 changes: 75 additions & 0 deletions
75
src/tests/integration/test-data/foundry/test/MockFunction.t.sol
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,75 @@ | ||
pragma solidity =0.8.13; | ||
|
||
import "forge-std/Test.sol"; | ||
|
||
import "kontrol-cheatcodes/KontrolCheats.sol"; | ||
|
||
contract MockFunctionContract { | ||
uint256 public a; | ||
|
||
function mocked_function() public { | ||
a = 321; | ||
} | ||
|
||
function mocked_args_function(uint256 x) public { | ||
a = 321 + x; | ||
} | ||
} | ||
|
||
contract ModelMockFunctionContract { | ||
uint256 public a; | ||
|
||
function mocked_function() public { | ||
a = 123; | ||
} | ||
|
||
function mocked_args_function(uint256 x) public { | ||
a = 123 + x; | ||
} | ||
} | ||
|
||
contract MockFunctionTest is Test, KontrolCheats { | ||
MockFunctionContract my_contract; | ||
ModelMockFunctionContract model_contract; | ||
|
||
function setUp() public { | ||
my_contract = new MockFunctionContract(); | ||
model_contract = new ModelMockFunctionContract(); | ||
} | ||
|
||
function test_mock_function() public { | ||
kevm.mockFunction( | ||
address(my_contract), | ||
address(model_contract), | ||
abi.encodeWithSelector(MockFunctionContract.mocked_function.selector) | ||
); | ||
my_contract.mocked_function(); | ||
assertEq(my_contract.a(), 123); | ||
} | ||
|
||
function test_mock_function_concrete_args() public { | ||
kevm.mockFunction( | ||
address(my_contract), | ||
address(model_contract), | ||
abi.encodeWithSelector(MockFunctionContract.mocked_args_function.selector, 456) | ||
); | ||
my_contract.mocked_args_function(456); | ||
assertEq(my_contract.a(), 123 + 456); | ||
|
||
my_contract.mocked_args_function(567); | ||
assertEq(my_contract.a(), 321 + 567); | ||
} | ||
|
||
function test_mock_function_all_args() public { | ||
kevm.mockFunction( | ||
address(my_contract), | ||
address(model_contract), | ||
abi.encodeWithSelector(MockFunctionContract.mocked_args_function.selector) | ||
); | ||
my_contract.mocked_args_function(678); | ||
assertEq(my_contract.a(), 123 + 678); | ||
|
||
my_contract.mocked_args_function(789); | ||
assertEq(my_contract.a(), 123 + 789); | ||
} | ||
} |
Oops, something went wrong.