-
Notifications
You must be signed in to change notification settings - Fork 497
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
test SafeCallback #220
Merged
Merged
test SafeCallback #220
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0381305
test SafeCallback
saucepoint d2edc68
Merge branch 'main' into safecallback-test-2
saucepoint 13db20e
Merge branch 'main' into safecallback-test-2
saucepoint 20b7a25
Merge branch 'main' into safecallback-test-2
saucepoint 33d6349
assert PM address
saucepoint File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.24; | ||
|
||
import "forge-std/Test.sol"; | ||
import {Deployers} from "@uniswap/v4-core/test/utils/Deployers.sol"; | ||
|
||
import {SafeCallback} from "../src/base/SafeCallback.sol"; | ||
import {MockSafeCallback} from "./mocks/MockSafeCallback.sol"; | ||
|
||
contract SafeCallbackTest is Test, Deployers { | ||
MockSafeCallback safeCallback; | ||
|
||
function setUp() public { | ||
deployFreshManager(); | ||
safeCallback = new MockSafeCallback(manager); | ||
} | ||
|
||
function test_poolManagerAddress() public view { | ||
assertEq(address(safeCallback.poolManager()), address(manager)); | ||
} | ||
|
||
function test_unlock(uint256 num) public { | ||
bytes memory result = safeCallback.unlockManager(num); | ||
assertEq(num, abi.decode(result, (uint256))); | ||
} | ||
|
||
function test_unlockRevert(address caller, bytes calldata data) public { | ||
vm.startPrank(caller); | ||
if (caller != address(manager)) vm.expectRevert(SafeCallback.NotPoolManager.selector); | ||
safeCallback.unlockCallback(data); | ||
vm.stopPrank(); | ||
Comment on lines
+28
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is pretty neat from foundry, when fuzzing for addresses the fuzzer includes deployed contracts from setup! 😲 |
||
} | ||
} |
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: GPL-2.0-or-later | ||
pragma solidity ^0.8.20; | ||
|
||
import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol"; | ||
|
||
import "../../src/base/SafeCallback.sol"; | ||
|
||
contract MockSafeCallback is SafeCallback { | ||
constructor(IPoolManager _poolManager) SafeCallback(_poolManager) {} | ||
|
||
function unlockManager(uint256 num) external returns (bytes memory) { | ||
return poolManager.unlock(abi.encode(num)); | ||
} | ||
|
||
function _unlockCallback(bytes calldata data) internal pure override returns (bytes memory) { | ||
return data; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
can we also just add an assert that the pool manager in SafeCallback is the address we expect/the pool manager address we initialized it with