Skip to content

Commit

Permalink
test: reorganize commit tree
Browse files Browse the repository at this point in the history
  • Loading branch information
0xteddybear committed Jul 22, 2024
1 parent 404f738 commit 4865e04
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
24 changes: 10 additions & 14 deletions test/unit/BCoWPool/BCoWPool.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,24 @@ contract BCoWPool is BCoWPoolBase {
bCoWPool.call__afterFinalize();
}

function test_CommitRevertWhen_SenderIsNotSolutionSettler(address caller) external {
vm.assume(caller != cowSolutionSettler);
vm.prank(caller);
function test_CommitRevertWhen_ReentrancyLockIsSet(bytes32 lockValue) external {
vm.assume(lockValue != _MUTEX_FREE);
bCoWPool.call__setLock(lockValue);
// it should revert
vm.expectRevert(abi.encodeWithSelector(IBCoWPool.CommitOutsideOfSettlement.selector));
vm.expectRevert(IBPool.BPool_Reentrancy.selector);
bCoWPool.commit(commitmentValue);
}

modifier whenSenderIsSolutionSettler() {
vm.startPrank(cowSolutionSettler);
_;
}

function test_CommitRevertWhen_ReentrancyLockIsSet(bytes32 lockValue) external whenSenderIsSolutionSettler {
vm.assume(lockValue != _MUTEX_FREE);
bCoWPool.call__setLock(lockValue);
function test_CommitRevertWhen_SenderIsNotSolutionSettler(address caller) external {
vm.assume(caller != cowSolutionSettler);
vm.prank(caller);
// it should revert
vm.expectRevert(IBPool.BPool_Reentrancy.selector);
vm.expectRevert(abi.encodeWithSelector(IBCoWPool.CommitOutsideOfSettlement.selector));
bCoWPool.commit(commitmentValue);
}

function test_CommitWhenCalled(bytes32 commitmentValue_) external whenSenderIsSolutionSettler {
function test_CommitWhenPreconditionsAreMet(bytes32 commitmentValue_) external {
vm.prank(cowSolutionSettler);
bCoWPool.commit(commitmentValue_);
// it should set the transient reentrancy lock
assertEq(bCoWPool.call__getLock(), commitmentValue_);
Expand Down
9 changes: 4 additions & 5 deletions test/unit/BCoWPool/BCoWPool.tree
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ BCoWPool::_afterFinalize
└── it emits a COWAMMPoolCreated event

BCoWPool::Commit
├── when reentrancy lock is set
│ └──it should revert
├── when sender is not solution settler
│ └──it should revert
└── when sender is solution settler
├── when reentrancy lock is set
│ └──it should revert
└── when called
└── it should set the transient reentrancy lock
└── when preconditions are met
└── it should set the transient reentrancy lock

0 comments on commit 4865e04

Please sign in to comment.