forked from balancer/balancer-core
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
20 changed files
with
502 additions
and
543 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
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,47 @@ | ||
// 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'; | ||
|
||
contract BCoWPool_afterFinalize is BCoWPoolBase { | ||
uint256 public tokenWeight = 1e18; | ||
|
||
function setUp() public virtual override { | ||
super.setUp(); | ||
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})); | ||
|
||
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_WhenCalled() external { | ||
// 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.call__afterFinalize(); | ||
} | ||
|
||
function test_WhenFactorysLogBCoWPoolDoesNotRevert() external { | ||
// it returns | ||
bCoWPool.call__afterFinalize(); | ||
} | ||
|
||
function test_WhenFactorysLogBCoWPoolReverts(bytes memory revertData) external { | ||
vm.mockCallRevert(address(this), abi.encodeCall(IBCoWFactory.logBCoWPool, ()), revertData); | ||
// it emits a COWAMMPoolCreated event | ||
vm.expectEmit(address(bCoWPool)); | ||
emit IBCoWFactory.COWAMMPoolCreated(address(bCoWPool)); | ||
bCoWPool.call__afterFinalize(); | ||
} | ||
} |
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 @@ | ||
BCoWPool::_afterFinalize | ||
├── when called | ||
│ ├── 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 |
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,28 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.25; | ||
|
||
import {BPoolBase} from '../BPool/BPoolBase.sol'; | ||
import {BCoWConst} from 'contracts/BCoWConst.sol'; | ||
import {BNum} from 'contracts/BNum.sol'; | ||
|
||
import {ISettlement} from 'interfaces/ISettlement.sol'; | ||
import {MockBCoWPool} from 'test/manual-smock/MockBCoWPool.sol'; | ||
|
||
contract BCoWPoolBase is BPoolBase, BCoWConst, BNum { | ||
bytes32 public appData = bytes32('appData'); | ||
address public cowSolutionSettler = makeAddr('cowSolutionSettler'); | ||
bytes32 public domainSeparator = bytes32(bytes2(0xf00b)); | ||
address public vaultRelayer = makeAddr('vaultRelayer'); | ||
address public tokenIn; | ||
address public tokenOut; | ||
MockBCoWPool bCoWPool; | ||
|
||
function setUp() public virtual override { | ||
super.setUp(); | ||
tokenIn = tokens[0]; | ||
tokenOut = tokens[1]; | ||
vm.mockCall(cowSolutionSettler, abi.encodePacked(ISettlement.domainSeparator.selector), abi.encode(domainSeparator)); | ||
vm.mockCall(cowSolutionSettler, abi.encodePacked(ISettlement.vaultRelayer.selector), abi.encode(vaultRelayer)); | ||
bCoWPool = new MockBCoWPool(cowSolutionSettler, appData); | ||
} | ||
} |
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
Oops, something went wrong.