Skip to content
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 29 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5321bbf
test: btt tests for bpool.swapExactAmountIn
0xteddybear Jul 9, 2024
432f63a
chore: delete preexisting unit tests
0xteddybear Jul 9, 2024
e66ed9f
test: small renames from feedback
0xteddybear Jul 10, 2024
1acff62
test: be explicit about untestable code
0xteddybear Jul 10, 2024
86f1950
chore: merge dev
0xteddybear Jul 11, 2024
d111e8b
test: adding skipped test for unreachable condition
0xteddybear Jul 11, 2024
9f074dc
test: code wasnt so unreachable after all
0xteddybear Jul 11, 2024
3f85e43
refactor: get rid of _setRecord
0xteddybear Jul 11, 2024
63b6058
test: btt tests for bcowpool.verify
0xteddybear Jul 11, 2024
1d3a30f
chore: delete preexisting unit tests
0xteddybear Jul 11, 2024
c9d196b
chore: testcase renaming from review
0xteddybear Jul 15, 2024
69f49e7
chore: get rid of _setTokens altogether
0xteddybear Jul 15, 2024
23c5a1b
test: fuzz all possible valid order.sellAmount values
0xteddybear Jul 15, 2024
a134e2c
chore: rename correctOrder -> validOrder
0xteddybear Jul 15, 2024
2668552
chore: merge dev
0xteddybear Jul 15, 2024
b5e712c
chore: merge dev
0xteddybear Jul 16, 2024
62d9d3a
test: btt tests for bpool.finalize
0xteddybear Jul 16, 2024
284322a
test: btt tests for bcowpool.finalize
0xteddybear Jul 16, 2024
31e634a
chore: remove preexisting unit tests replaced by ones in this pr
0xteddybear Jul 16, 2024
3bf22e8
fix: feedback from review
0xteddybear Jul 16, 2024
bd2342b
refactor: make caller==controller default scenario
0xteddybear Jul 16, 2024
57fb9ca
test: btt tests for bcowpool constructor
0xteddybear Jul 16, 2024
ac4399e
chore: remove preexisting unit tests replaced by ones in this pr
0xteddybear Jul 16, 2024
15eac0e
chore: merge dev
0xteddybear Jul 22, 2024
c4e89a2
fix: feedback from review
0xteddybear Jul 22, 2024
88037dc
fix: make bulloak happy
0xteddybear Jul 22, 2024
45054df
chore: merge dev
0xteddybear Jul 22, 2024
4967b34
fix: mergeback mistake
0xteddybear Jul 22, 2024
32f249c
chore: merge dev
wei3erHase Jul 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions test/unit/BCoWPool.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,37 +47,6 @@ 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);
}
}

contract BCoWPool_Unit_IsValidSignature is BaseCoWPoolTest {
function setUp() public virtual override {
super.setUp();
Expand Down
26 changes: 26 additions & 0 deletions test/unit/BCoWPool/BCoWPool.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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)));
Expand Down
9 changes: 9 additions & 0 deletions test/unit/BCoWPool/BCoWPool.tree
Original file line number Diff line number Diff line change
@@ -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
Copy link
Member

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

Copy link
Member

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

└── it should set the app data

BCoWPool::_afterFinalize
├── when called
│ ├── it calls approve on every bound token
Expand Down
Loading