forked from balancer/balancer-core
-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: add btt for isValidSignature #161
Merged
Merged
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
5321bbf
test: btt tests for bpool.swapExactAmountIn
0xteddybear 432f63a
chore: delete preexisting unit tests
0xteddybear e66ed9f
test: small renames from feedback
0xteddybear 1acff62
test: be explicit about untestable code
0xteddybear 86f1950
chore: merge dev
0xteddybear d111e8b
test: adding skipped test for unreachable condition
0xteddybear 9f074dc
test: code wasnt so unreachable after all
0xteddybear 3f85e43
refactor: get rid of _setRecord
0xteddybear 63b6058
test: btt tests for bcowpool.verify
0xteddybear 1d3a30f
chore: delete preexisting unit tests
0xteddybear c9d196b
chore: testcase renaming from review
0xteddybear 69f49e7
chore: get rid of _setTokens altogether
0xteddybear 23c5a1b
test: fuzz all possible valid order.sellAmount values
0xteddybear a134e2c
chore: rename correctOrder -> validOrder
0xteddybear 2668552
chore: merge dev
0xteddybear b5e712c
chore: merge dev
0xteddybear 948feaf
test: btt tests for bcowpool.isValidSignature
0xteddybear 88c9734
chore: remove preexisting unit tests replaced by ones in this pr
0xteddybear d80191e
chore: merge dev
0xteddybear e4d7108
fix: more descriptive tree
0xteddybear 7810b28
chore: merge dev
0xteddybear 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
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,56 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.25; | ||
|
||
import {IERC20} from '@cowprotocol/interfaces/IERC20.sol'; | ||
|
||
import {GPv2Order} from '@cowprotocol/libraries/GPv2Order.sol'; | ||
import {IERC1271} from '@openzeppelin/contracts/interfaces/IERC1271.sol'; | ||
|
||
import {BCoWPoolBase} from './BCoWPoolBase.sol'; | ||
import {IBCoWPool} from 'interfaces/IBCoWPool.sol'; | ||
|
||
contract BCoWPoolIsValidSignature is BCoWPoolBase { | ||
GPv2Order.Data validOrder; | ||
bytes32 validHash; | ||
|
||
function setUp() public virtual override { | ||
super.setUp(); | ||
// only set up the values that are checked in this method | ||
validOrder.appData = appData; | ||
validHash = GPv2Order.hash(validOrder, domainSeparator); | ||
|
||
bCoWPool.mock_call_verify(validOrder); | ||
} | ||
|
||
function test_RevertWhen_OrdersAppdataIsDifferent(bytes32 appData_) external { | ||
vm.assume(appData != appData_); | ||
validOrder.appData = appData_; | ||
// it should revert | ||
vm.expectRevert(IBCoWPool.AppDataDoesNotMatch.selector); | ||
bCoWPool.isValidSignature(validHash, abi.encode(validOrder)); | ||
} | ||
|
||
function test_RevertWhen_OrderHashDoesNotMatchHashedOrder(bytes32 orderHash) external { | ||
vm.assume(orderHash != validHash); | ||
// it should revert | ||
vm.expectRevert(IBCoWPool.OrderDoesNotMatchMessageHash.selector); | ||
bCoWPool.isValidSignature(orderHash, abi.encode(validOrder)); | ||
} | ||
|
||
function test_RevertWhen_HashedOrderDoesNotMatchCommitment(bytes32 commitment) external { | ||
vm.assume(validHash != commitment); | ||
bCoWPool.call__setLock(commitment); | ||
// it should revert | ||
vm.expectRevert(IBCoWPool.OrderDoesNotMatchCommitmentHash.selector); | ||
bCoWPool.isValidSignature(validHash, abi.encode(validOrder)); | ||
} | ||
|
||
function test_WhenPreconditionsAreMet() external { | ||
// can't do it in setUp because transient storage is wiped in between | ||
bCoWPool.call__setLock(validHash); | ||
// it calls verify | ||
bCoWPool.expectCall_verify(validOrder); | ||
// it returns EIP-1271 magic value | ||
assertEq(bCoWPool.isValidSignature(validHash, abi.encode(validOrder)), IERC1271.isValidSignature.selector); | ||
} | ||
} |
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,10 @@ | ||
BCoWPool::IsValidSignature | ||
├── when orders appdata is different | ||
│ └── it should revert | ||
├── when orderHash does not match hashed order | ||
│ └── it should revert | ||
├── when hashed order does not match commitment | ||
│ └── it should revert | ||
└── when preconditions are met | ||
├── it calls verify | ||
└── it returns EIP-1271 magic value |
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.
than allowed? 👀