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
test: btt tests for bcowpool constructor #163
Merged
Merged
Changes from 23 commits
Commits
Show all changes
29 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 62d9d3a
test: btt tests for bpool.finalize
0xteddybear 284322a
test: btt tests for bcowpool.finalize
0xteddybear 31e634a
chore: remove preexisting unit tests replaced by ones in this pr
0xteddybear 3bf22e8
fix: feedback from review
0xteddybear bd2342b
refactor: make caller==controller default scenario
0xteddybear 57fb9ca
test: btt tests for bcowpool constructor
0xteddybear ac4399e
chore: remove preexisting unit tests replaced by ones in this pr
0xteddybear 15eac0e
chore: merge dev
0xteddybear c4e89a2
fix: feedback from review
0xteddybear 88037dc
fix: make bulloak happy
0xteddybear 45054df
chore: merge dev
0xteddybear 4967b34
fix: mergeback mistake
0xteddybear 32f249c
chore: merge dev
wei3erHase 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
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,69 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.25; | ||
|
||
import {IERC20} from '@cowprotocol/interfaces/IERC20.sol'; | ||
|
||
import {BCoWPoolBase} from './BCoWPoolBase.sol'; | ||
|
||
import {IBCoWFactory} from 'interfaces/IBCoWFactory.sol'; | ||
import {IBPool} from 'interfaces/IBPool.sol'; | ||
import {ISettlement} from 'interfaces/ISettlement.sol'; | ||
import {MockBCoWPool} from 'test/manual-smock/MockBCoWPool.sol'; | ||
|
||
contract BCoWPool is BCoWPoolBase { | ||
function test_ConstructorWhenCalled( | ||
address _settler, | ||
bytes32 _separator, | ||
address _relayer, | ||
bytes32 _appData | ||
) external { | ||
assumeNotForgeAddress(_settler); | ||
vm.mockCall(_settler, abi.encodePacked(ISettlement.domainSeparator.selector), abi.encode(_separator)); | ||
vm.mockCall(_settler, abi.encodePacked(ISettlement.vaultRelayer.selector), abi.encode(_relayer)); | ||
MockBCoWPool pool = new MockBCoWPool(_settler, _appData); | ||
// it should set the solution settler | ||
assertEq(address(pool.SOLUTION_SETTLER()), _settler); | ||
// it should set the domain separator | ||
assertEq(pool.SOLUTION_SETTLER_DOMAIN_SEPARATOR(), _separator); | ||
// it should set the vault relayer | ||
assertEq(pool.VAULT_RELAYER(), _relayer); | ||
// it should set the app data | ||
assertEq(pool.APP_DATA(), _appData); | ||
} | ||
|
||
modifier whenPreconditionsAreMet() { | ||
bCoWPool.set__tokens(tokens); | ||
bCoWPool.set__records(tokens[0], IBPool.Record({bound: true, index: 0, denorm: tokenWeight})); | ||
bCoWPool.set__records(tokens[1], IBPool.Record({bound: true, index: 1, denorm: tokenWeight})); | ||
bCoWPool.mock_call__mintPoolShare(INIT_POOL_SUPPLY); | ||
bCoWPool.mock_call__pushPoolShare(address(this), INIT_POOL_SUPPLY); | ||
|
||
vm.mockCall(address(this), abi.encodeCall(IBCoWFactory.logBCoWPool, ()), abi.encode()); | ||
|
||
vm.mockCall(tokens[0], abi.encodeCall(IERC20.approve, (vaultRelayer, type(uint256).max)), abi.encode(true)); | ||
vm.mockCall(tokens[1], abi.encodeCall(IERC20.approve, (vaultRelayer, type(uint256).max)), abi.encode(true)); | ||
_; | ||
} | ||
|
||
function test_FinalizeWhenPreconditionsAreMet() external whenPreconditionsAreMet { | ||
// it calls approve on every bound token | ||
vm.expectCall(tokens[0], abi.encodeCall(IERC20.approve, (vaultRelayer, type(uint256).max))); | ||
vm.expectCall(tokens[1], abi.encodeCall(IERC20.approve, (vaultRelayer, type(uint256).max))); | ||
// it calls logBCoWPool on the factory | ||
vm.expectCall(address(this), abi.encodeCall(IBCoWFactory.logBCoWPool, ())); | ||
bCoWPool.finalize(); | ||
} | ||
|
||
function test_FinalizeWhenFactorysLogBCoWPoolDoesNotRevert() external whenPreconditionsAreMet { | ||
// it returns | ||
bCoWPool.finalize(); | ||
} | ||
|
||
function test_FinalizeWhenFactorysLogBCoWPoolReverts(bytes memory revertData) external whenPreconditionsAreMet { | ||
vm.mockCallRevert(address(this), abi.encodeCall(IBCoWFactory.logBCoWPool, ()), revertData); | ||
// it emits a COWAMMPoolCreated event | ||
vm.expectEmit(address(bCoWPool)); | ||
emit IBCoWFactory.COWAMMPoolCreated(address(bCoWPool)); | ||
bCoWPool.finalize(); | ||
} | ||
} |
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 @@ | ||
BCoWPool::Constructor | ||
└── when called | ||
├── it should set the solution settler | ||
├── it should set the domain separator | ||
├── it should set the vault relayer | ||
└── it should set the app data | ||
|
||
BCoWPool::Finalize | ||
└── when preconditions are met | ||
├── it calls approve on every bound token | ||
├── it calls logBCoWPool on the factory | ||
├── when factorys logBCoWPool does not revert | ||
│ └── it returns | ||
└── when factorys logBCoWPool reverts | ||
└── it emits a COWAMMPoolCreated event |
Oops, something went wrong.
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.
missing the external call?
should query solution settler for vault relayer
+should query solution settler for app data
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.
"ask" doesn't sound good