diff --git a/.forge-snapshots/newBFactory.snap b/.forge-snapshots/newBFactory.snap index 95e984ca..c54b6046 100644 --- a/.forge-snapshots/newBFactory.snap +++ b/.forge-snapshots/newBFactory.snap @@ -1 +1 @@ -4130621 \ No newline at end of file +4130633 \ No newline at end of file diff --git a/test/manual-smock/MockBCoWFactory.sol b/test/manual-smock/MockBCoWFactory.sol index bf887e7d..c4b2e427 100644 --- a/test/manual-smock/MockBCoWFactory.sol +++ b/test/manual-smock/MockBCoWFactory.sol @@ -5,8 +5,7 @@ import {BCoWFactory, BCoWPool, BFactory, IBCoWFactory, IBPool} from '../../src/c import {Test} from 'forge-std/Test.sol'; contract MockBCoWFactory is BCoWFactory, Test { - constructor(address solutionSettler, bytes32 appData) BCoWFactory(solutionSettler, appData) {} - + // NOTE: manually added methods (immutable overrides not supported in smock) function mock_call_APP_DATA(bytes32 _appData) public { vm.mockCall(address(this), abi.encodeWithSignature('APP_DATA()'), abi.encode(_appData)); } @@ -15,10 +14,32 @@ contract MockBCoWFactory is BCoWFactory, Test { vm.expectCall(address(this), abi.encodeWithSignature('APP_DATA()')); } + // BCoWFactory methods + constructor(address solutionSettler, bytes32 appData) BCoWFactory(solutionSettler, appData) {} + function mock_call_logBCoWPool() public { vm.mockCall(address(this), abi.encodeWithSignature('logBCoWPool()'), abi.encode()); } + function mock_call__newBPool(IBPool bCoWPool) public { + vm.mockCall(address(this), abi.encodeWithSignature('_newBPool()'), abi.encode(bCoWPool)); + } + + function _newBPool() internal override returns (IBPool bCoWPool) { + (bool _success, bytes memory _data) = address(this).call(abi.encodeWithSignature('_newBPool()')); + + if (_success) return abi.decode(_data, (IBPool)); + else return super._newBPool(); + } + + function call__newBPool() public returns (IBPool bCoWPool) { + return _newBPool(); + } + + function expectCall__newBPool() public { + vm.expectCall(address(this), abi.encodeWithSignature('_newBPool()')); + } + // MockBFactory methods function set__isBPool(address _key0, bool _value) public { _isBPool[_key0] = _value; @@ -28,20 +49,20 @@ contract MockBCoWFactory is BCoWFactory, Test { return _isBPool[_key0]; } - function set__bLabs(address __bLabs) public { - _bLabs = __bLabs; + function set__bDao(address __bDao) public { + _bDao = __bDao; } - function call__bLabs() public view returns (address) { - return _bLabs; + function call__bDao() public view returns (address) { + return _bDao; } function mock_call_newBPool(IBPool bPool) public { vm.mockCall(address(this), abi.encodeWithSignature('newBPool()'), abi.encode(bPool)); } - function mock_call_setBLabs(address bLabs) public { - vm.mockCall(address(this), abi.encodeWithSignature('setBLabs(address)', bLabs), abi.encode()); + function mock_call_setBDao(address bDao) public { + vm.mockCall(address(this), abi.encodeWithSignature('setBDao(address)', bDao), abi.encode()); } function mock_call_collect(IBPool bPool) public { @@ -52,26 +73,7 @@ contract MockBCoWFactory is BCoWFactory, Test { vm.mockCall(address(this), abi.encodeWithSignature('isBPool(address)', bPool), abi.encode(_returnParam0)); } - function mock_call_getBLabs(address _returnParam0) public { - vm.mockCall(address(this), abi.encodeWithSignature('getBLabs()'), abi.encode(_returnParam0)); - } - - function mock_call__newBPool(IBPool bPool) public { - vm.mockCall(address(this), abi.encodeWithSignature('_newBPool()'), abi.encode(bPool)); - } - - function _newBPool() internal override returns (IBPool bPool) { - (bool _success, bytes memory _data) = address(this).call(abi.encodeWithSignature('_newBPool()')); - - if (_success) return abi.decode(_data, (IBPool)); - else return super._newBPool(); - } - - function call__newBPool() public returns (IBPool bPool) { - return _newBPool(); - } - - function expectCall__newBPool() public { - vm.expectCall(address(this), abi.encodeWithSignature('_newBPool()')); + function mock_call_getBDao(address _returnParam0) public { + vm.mockCall(address(this), abi.encodeWithSignature('getBDao()'), abi.encode(_returnParam0)); } } diff --git a/test/manual-smock/MockBCoWPool.sol b/test/manual-smock/MockBCoWPool.sol index 11eaba95..1b9e7703 100644 --- a/test/manual-smock/MockBCoWPool.sol +++ b/test/manual-smock/MockBCoWPool.sol @@ -33,7 +33,6 @@ contract MockBCoWPool is BCoWPool, Test { } /// MockBCoWPool mock methods - constructor(address cowSolutionSettler, bytes32 appData) BCoWPool(cowSolutionSettler, appData) {} function mock_call_commit(bytes32 orderHash) public { @@ -376,6 +375,84 @@ contract MockBCoWPool is BCoWPool, Test { vm.expectCall(address(this), abi.encodeWithSignature('_afterFinalize()')); } + function mock_call__pullPoolShare(address from, uint256 amount) public { + vm.mockCall(address(this), abi.encodeWithSignature('_pullPoolShare(address,uint256)', from, amount), abi.encode()); + } + + function _pullPoolShare(address from, uint256 amount) internal override { + (bool _success, bytes memory _data) = + address(this).call(abi.encodeWithSignature('_pullPoolShare(address,uint256)', from, amount)); + + if (_success) return abi.decode(_data, ()); + else return super._pullPoolShare(from, amount); + } + + function call__pullPoolShare(address from, uint256 amount) public { + return _pullPoolShare(from, amount); + } + + function expectCall__pullPoolShare(address from, uint256 amount) public { + vm.expectCall(address(this), abi.encodeWithSignature('_pullPoolShare(address,uint256)', from, 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 mock_call__burnPoolShare(uint256 amount) public { + vm.mockCall(address(this), abi.encodeWithSignature('_burnPoolShare(uint256)', amount), abi.encode()); + } + + function _burnPoolShare(uint256 amount) internal override { + (bool _success, bytes memory _data) = address(this).call(abi.encodeWithSignature('_burnPoolShare(uint256)', amount)); + + if (_success) return abi.decode(_data, ()); + else return super._burnPoolShare(amount); + } + + function call__burnPoolShare(uint256 amount) public { + return _burnPoolShare(amount); + } + + function expectCall__burnPoolShare(uint256 amount) public { + vm.expectCall(address(this), abi.encodeWithSignature('_burnPoolShare(uint256)', amount)); + } + function mock_call__getLock(bytes32 value) public { vm.mockCall(address(this), abi.encodeWithSignature('_getLock()'), abi.encode(value)); } @@ -387,7 +464,7 @@ contract MockBCoWPool is BCoWPool, Test { else return super._getLock(); } - function call__getLock() public returns (bytes32 value) { + function call__getLock() public view returns (bytes32 value) { return _getLock(); }