Skip to content

Commit dbaed85

Browse files
committed
NostalgicFactory tests
1 parent ee4b32f commit dbaed85

4 files changed

Lines changed: 23 additions & 22 deletions

File tree

foundry.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
src = "src"
33
out = "out"
44
libs = ["lib"]
5-
5+
no_match_coverage = "test/"
66

77
[lint]
88
exclude_lints=["mixed-case-function", "asm-keccak256"]
9-
ignore = ["test/*"]
9+
ignore = ["test/*"]

src/NostalgicController.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,3 @@ contract NostalgicController is AccessControl, INostalgicController {
185185
);
186186
}
187187
}
188-

src/NostalgicFactory.sol

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,7 @@ contract NostalgicFactory is INostalgicFactory {
7070
uint256 _protocolFeesFactor
7171
) external returns (address) {
7272
bytes32 salt = keccak256(
73-
abi.encodePacked(
74-
_underlyingAsset,
75-
_name,
76-
_symbol,
77-
block.timestamp,
78-
allPools.length
79-
)
73+
abi.encodePacked(_underlyingAsset, _name, _symbol, allPools.length)
8074
);
8175

8276
address clone = POOL_IMPLEMENTATION.cloneDeterministic(salt);
@@ -92,6 +86,7 @@ contract NostalgicFactory is INostalgicFactory {
9286
pauser,
9387
_protocolFeesFactor
9488
);
89+
poolsByCreator[msg.sender].push(clone);
9590

9691
allPools.push(clone);
9792

@@ -108,7 +103,10 @@ contract NostalgicFactory is INostalgicFactory {
108103
abi.encodePacked(_underlyingAsset, _name, _symbol, index)
109104
);
110105
return
111-
POOL_IMPLEMENTATION.predictDeterministicAddress(salt, address(this));
106+
POOL_IMPLEMENTATION.predictDeterministicAddress(
107+
salt,
108+
address(this)
109+
);
112110
}
113111

114112
function getPoolsByCreator(
@@ -120,13 +118,4 @@ contract NostalgicFactory is INostalgicFactory {
120118
function allPoolsCount() external view returns (uint256) {
121119
return allPools.length;
122120
}
123-
124-
function _isContract(address addr) internal view returns (bool) {
125-
uint256 size;
126-
// solhint-disable-next-line no-inline-assembly
127-
assembly {
128-
size := extcodesize(addr)
129-
}
130-
return size > 0;
131-
}
132121
}

test/NostalgicFactory.t.sol

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {NostalgicFactory} from "../src/NostalgicFactory.sol";
66
import {NostalgicPool} from "../src/NostalgicPool.sol";
77
import {IAggregatorV3} from "../src/interfaces/IAggregatorV3.sol";
88
import {INostalgicRateModel} from "../src/interfaces/INostalgicRateModel.sol";
9-
9+
import {INostalgicFactoryErrors} from "../src/interfaces/INostalgicFactory.sol";
1010
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
1111
import {MockERC20} from "./mocks/MockERC20.t.sol";
1212
contract NostalgicFactoryTest is Test {
@@ -25,7 +25,17 @@ contract NostalgicFactoryTest is Test {
2525
);
2626
}
2727

28-
function testCreatePool() public {
28+
function testRevertInit() public {
29+
vm.expectRevert(INostalgicFactoryErrors.ZeroAddress.selector);
30+
NostalgicFactory factory2 = new NostalgicFactory(
31+
address(0),
32+
address(0),
33+
admin,
34+
pauser
35+
);
36+
}
37+
38+
function testCreateBasicPool() public {
2939
address pool = factory.createPool(
3040
asset,
3141
"MOCK",
@@ -34,5 +44,8 @@ contract NostalgicFactoryTest is Test {
3444
INostalgicRateModel(address(3)),
3545
500
3646
);
47+
assertEq(factory.allPoolsCount(), 1);
48+
assertEq(factory.getPoolsByCreator(address(this))[0], pool);
49+
assertEq(factory.predictPoolAddress(asset, "MOCK", "MOCK", 0), pool);
3750
}
3851
}

0 commit comments

Comments
 (0)