Skip to content

Commit

Permalink
chore: pass name and symbol to ForTest contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
0xteddybear committed Aug 1, 2024
1 parent 5459229 commit e632226
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion test/invariants/fuzz/BToken.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ contract FuzzBToken is CryticERC20ExternalBasicProperties, EchidnaTest {
}
}

contract CryticTokenMock is BToken, PropertiesConstants {
contract CryticTokenMock is BToken('Balancer Pool Token', 'BPT'), PropertiesConstants {
bool public isMintableOrBurnable;
uint256 public initialSupply;

Expand Down
9 changes: 6 additions & 3 deletions test/invariants/fuzz/Protocol.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ contract FuzzProtocol is EchidnaTest {
uint256 ghost_bptBurned;
mapping(FuzzERC20 => uint256) ghost_amountDirectlyTransfered;

string constant ERC20_SYMBOL = 'BPT';
string constant ERC20_NAME = 'Balancer Pool Token';

constructor() {
solutionSettler = address(new MockSettler());

Expand All @@ -40,7 +43,7 @@ contract FuzzProtocol is EchidnaTest {
bmath = new BMath();
bnum = new BNum();

pool = IBCoWPool(address(factory.newBPool()));
pool = IBCoWPool(address(factory.newBPool(ERC20_NAME, ERC20_SYMBOL)));

// first 4 tokens bound to the finalized pool
for (uint256 i; i < 4; i++) {
Expand Down Expand Up @@ -119,7 +122,7 @@ contract FuzzProtocol is EchidnaTest {
hevm.prank(currentCaller);

// Action
try factory.newBPool() returns (IBPool _newPool) {
try factory.newBPool(ERC20_NAME, ERC20_SYMBOL) returns (IBPool _newPool) {
// Postcondition
assert(address(_newPool).code.length > 0);
assert(factory.isBPool(address(_newPool)));
Expand Down Expand Up @@ -339,7 +342,7 @@ contract FuzzProtocol is EchidnaTest {
/// @custom:property total weight can be up to 50e18
function fuzz_totalWeightMax(uint256 _numberTokens, uint256[8] calldata _weights) public {
// Precondition
IBPool _pool = IBPool(address(factory.newBPool()));
IBPool _pool = IBPool(address(factory.newBPool(ERC20_NAME, ERC20_SYMBOL)));

_numberTokens = clamp(_numberTokens, bconst.MIN_BOUND_TOKENS(), bconst.MAX_BOUND_TOKENS());

Expand Down
4 changes: 2 additions & 2 deletions test/invariants/helpers/BCoWFactoryForTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {IBPool} from 'interfaces/IBPool.sol';
contract BCoWFactoryForTest is BCoWFactory {
constructor(address cowSolutionSettler, bytes32 appData) BCoWFactory(cowSolutionSettler, appData) {}

function _newBPool() internal virtual override returns (IBPool bCoWPool) {
bCoWPool = new BCoWPoolForTest(SOLUTION_SETTLER, APP_DATA);
function _newBPool(string memory, string memory) internal virtual override returns (IBPool bCoWPool) {
bCoWPool = new BCoWPoolForTest(SOLUTION_SETTLER, APP_DATA, 'name', 'symbol');
}
}
7 changes: 6 additions & 1 deletion test/invariants/helpers/BCoWPoolForTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import {BCoWPool} from 'contracts/BCoWPool.sol';

contract BCoWPoolForTest is BCoWPool {
constructor(address cowSolutionSettler, bytes32 appData) BCoWPool(cowSolutionSettler, appData) {}
constructor(
address cowSolutionSettler,
bytes32 appData,
string memory name,
string memory symbol
) BCoWPool(cowSolutionSettler, appData, name, symbol) {}

bytes32 private _reenteringMutex;

Expand Down
21 changes: 11 additions & 10 deletions test/invariants/symbolic/Protocol.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,34 @@ pragma solidity 0.8.25;

import {FuzzERC20, HalmosTest} from '../helpers/AdvancedTestsUtils.sol';

import {BCoWFactoryForTest as BCoWFactory} from '../helpers/BCoWFactoryForTest.sol';
import {MockSettler} from '../helpers/MockSettler.sol';
import {BCoWFactory, BCoWPool, IBPool} from 'contracts/BCoWFactory.sol';
import {IBCoWPool} from 'interfaces/IBCoWPool.sol';
import {IBPool} from 'interfaces/IBPool.sol';

import {BConst} from 'contracts/BConst.sol';
import {BMath} from 'contracts/BMath.sol';
import {BToken} from 'contracts/BToken.sol';

contract HalmosBalancer is HalmosTest {
// System under test
BCoWFactory factory;
BConst bconst;
BMath bmath;

address solutionSettler;
bytes32 appData;

FuzzERC20[] tokens;
BCoWPool pool;
IBCoWPool pool;
string constant ERC20_NAME = 'Balancer Pool Token';
string constant ERC20_SYMBOL = 'BPT';

address currentCaller = svm.createAddress('currentCaller');

constructor() {
solutionSettler = address(new MockSettler());
factory = new BCoWFactory(solutionSettler, appData);
bconst = new BConst();
bmath = new BMath();
pool = BCoWPool(address(factory.newBPool()));
pool = IBCoWPool(address(factory.newBPool(ERC20_NAME, ERC20_SYMBOL)));

// max bound token is 8
for (uint256 i; i < 5; i++) {
Expand Down Expand Up @@ -63,7 +64,7 @@ contract HalmosBalancer is HalmosTest {
vm.prank(_caller);

// Action
try factory.newBPool() returns (IBPool _newPool) {
try factory.newBPool(ERC20_NAME, ERC20_SYMBOL) returns (IBPool _newPool) {
// Postcondition
assert(address(_newPool).code.length > 0);
assert(factory.isBPool(address(_newPool)));
Expand Down Expand Up @@ -112,7 +113,7 @@ contract HalmosBalancer is HalmosTest {
/// @dev Only 2 tokens are used, to avoid hitting the limit in loop unrolling
function check_totalWeightMax(uint256[2] calldata _weights) public {
// Precondition
BCoWPool _pool = BCoWPool(address(factory.newBPool()));
IBCoWPool _pool = IBCoWPool(address(factory.newBPool(ERC20_NAME, ERC20_SYMBOL)));

uint256 _totalWeight = 0;

Expand Down Expand Up @@ -179,7 +180,7 @@ contract HalmosBalancer is HalmosTest {
/// @custom:property a non-finalized pool can only be finalized when the controller calls finalize()
function check_poolFinalizedByController() public {
// Precondition
IBPool _nonFinalizedPool = factory.newBPool();
IBPool _nonFinalizedPool = factory.newBPool(ERC20_NAME, ERC20_SYMBOL);

vm.prank(_nonFinalizedPool.getController());

Expand Down Expand Up @@ -209,7 +210,7 @@ contract HalmosBalancer is HalmosTest {
/// @custom:property bounding and unbounding token can only be done on a non-finalized pool, by the controller
function check_boundOnlyNotFinalized() public {
// Precondition
IBPool _nonFinalizedPool = factory.newBPool();
IBPool _nonFinalizedPool = factory.newBPool(ERC20_NAME, ERC20_SYMBOL);

address _callerBind = svm.createAddress('callerBind');
address _callerUnbind = svm.createAddress('callerUnbind');
Expand Down

0 comments on commit e632226

Please sign in to comment.