diff --git a/test/manual-smock/MockBCoWPool.sol b/test/manual-smock/MockBCoWPool.sol index 98b19d1f..a0f1176c 100644 --- a/test/manual-smock/MockBCoWPool.sol +++ b/test/manual-smock/MockBCoWPool.sol @@ -369,45 +369,6 @@ contract MockBCoWPool is BCoWPool, Test { vm.expectCall(address(this), abi.encodeWithSignature('_pushUnderlying(address,address,uint256)', token, to, amount)); } - function mock_call__pushPoolShare(address to, uint256 amount) public { - vm.mockCall(address(this), abi.encodeWithSignature('_pushPoolShare(address,uint256)', to, amount), abi.encode()); - } - - function _pushPoolShare(address to, uint256 amount) internal override { - (bool _success, bytes memory _data) = - address(this).call(abi.encodeWithSignature('_pushPoolShare(address,uint256)', to, amount)); - - if (_success) return abi.decode(_data, ()); - else return super._pushPoolShare(to, amount); - } - - function call__pushPoolShare(address to, uint256 amount) public { - return _pushPoolShare(to, amount); - } - - function expectCall__pushPoolShare(address to, uint256 amount) public { - vm.expectCall(address(this), abi.encodeWithSignature('_pushPoolShare(address,uint256)', to, amount)); - } - - function mock_call__mintPoolShare(uint256 amount) public { - vm.mockCall(address(this), abi.encodeWithSignature('_mintPoolShare(uint256)', amount), abi.encode()); - } - - function _mintPoolShare(uint256 amount) internal override { - (bool _success, bytes memory _data) = address(this).call(abi.encodeWithSignature('_mintPoolShare(uint256)', amount)); - - if (_success) return abi.decode(_data, ()); - else return super._mintPoolShare(amount); - } - - function call__mintPoolShare(uint256 amount) public { - return _mintPoolShare(amount); - } - - function expectCall__mintPoolShare(uint256 amount) public { - vm.expectCall(address(this), abi.encodeWithSignature('_mintPoolShare(uint256)', amount)); - } - function call__afterFinalize() public { return _afterFinalize(); } diff --git a/test/unit/BCoWPool.t.sol b/test/unit/BCoWPool.t.sol index 7d448ae6..eb8acad5 100644 --- a/test/unit/BCoWPool.t.sol +++ b/test/unit/BCoWPool.t.sol @@ -46,34 +46,3 @@ abstract contract BaseCoWPoolTest is BasePoolTest, BCoWConst { }); } } - -contract BCoWPool_Unit_Constructor is BaseCoWPoolTest { - function test_Set_SolutionSettler(address _settler) public { - assumeNotForgeAddress(_settler); - vm.mockCall(_settler, abi.encodePacked(ISettlement.domainSeparator.selector), abi.encode(domainSeparator)); - vm.mockCall(_settler, abi.encodePacked(ISettlement.vaultRelayer.selector), abi.encode(vaultRelayer)); - MockBCoWPool pool = new MockBCoWPool(_settler, appData); - assertEq(address(pool.SOLUTION_SETTLER()), _settler); - } - - function test_Set_DomainSeparator(address _settler, bytes32 _separator) public { - assumeNotForgeAddress(_settler); - vm.mockCall(_settler, abi.encodePacked(ISettlement.domainSeparator.selector), abi.encode(_separator)); - vm.mockCall(_settler, abi.encodePacked(ISettlement.vaultRelayer.selector), abi.encode(vaultRelayer)); - MockBCoWPool pool = new MockBCoWPool(_settler, appData); - assertEq(pool.SOLUTION_SETTLER_DOMAIN_SEPARATOR(), _separator); - } - - function test_Set_VaultRelayer(address _settler, address _relayer) public { - assumeNotForgeAddress(_settler); - vm.mockCall(_settler, abi.encodePacked(ISettlement.domainSeparator.selector), abi.encode(domainSeparator)); - vm.mockCall(_settler, abi.encodePacked(ISettlement.vaultRelayer.selector), abi.encode(_relayer)); - MockBCoWPool pool = new MockBCoWPool(_settler, appData); - assertEq(pool.VAULT_RELAYER(), _relayer); - } - - function test_Set_AppData(bytes32 _appData) public { - MockBCoWPool pool = new MockBCoWPool(cowSolutionSettler, _appData); - assertEq(pool.APP_DATA(), _appData); - } -} diff --git a/test/unit/BCoWPool/BCoWPool.t.sol b/test/unit/BCoWPool/BCoWPool.t.sol index 2318bd16..66d4a825 100644 --- a/test/unit/BCoWPool/BCoWPool.t.sol +++ b/test/unit/BCoWPool/BCoWPool.t.sol @@ -9,6 +9,8 @@ import {IBCoWFactory} from 'interfaces/IBCoWFactory.sol'; import {IBCoWPool} from 'interfaces/IBCoWPool.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 { bytes32 public commitmentValue = bytes32(uint256(0xf00ba5)); @@ -27,6 +29,30 @@ contract BCoWPool is BCoWPoolBase { vm.mockCall(tokens[1], abi.encodeCall(IERC20.approve, (vaultRelayer, type(uint256).max)), abi.encode(true)); } + 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)); + // it should query the solution settler for the domain separator + vm.expectCall(_settler, abi.encodePacked(ISettlement.domainSeparator.selector)); + // it should query the solution settler for the vault relayer + vm.expectCall(_settler, abi.encodePacked(ISettlement.vaultRelayer.selector)); + 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); + } + function test__afterFinalizeWhenCalled() external { // it calls approve on every bound token vm.expectCall(tokens[0], abi.encodeCall(IERC20.approve, (vaultRelayer, type(uint256).max))); diff --git a/test/unit/BCoWPool/BCoWPool.tree b/test/unit/BCoWPool/BCoWPool.tree index abf9b3bb..9331eb1f 100644 --- a/test/unit/BCoWPool/BCoWPool.tree +++ b/test/unit/BCoWPool/BCoWPool.tree @@ -1,3 +1,12 @@ +BCoWPool::Constructor +└── when called + ├── it should set the solution settler + ├── it should query the solution settler for the domain separator + ├── it should set the domain separator + ├── it should query the solution settler for the vault relayer + ├── it should set the vault relayer + └── it should set the app data + BCoWPool::_afterFinalize ├── when called │ ├── it calls approve on every bound token