diff --git a/test/forge/BlueBase.t.sol b/test/forge/BlueBase.t.sol index cec424d30..6d53c4881 100644 --- a/test/forge/BlueBase.t.sol +++ b/test/forge/BlueBase.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.20; +pragma solidity 0.8.21; import "forge-std/Test.sol"; import "forge-std/console.sol"; @@ -12,17 +12,17 @@ import {IrmMock as Irm} from "src/mocks/IrmMock.sol"; contract BlueBaseTest is Test { using FixedPointMathLib for uint256; - address private constant BORROWER = address(1234); - address private constant LIQUIDATOR = address(5678); - uint256 private constant LLTV = 0.8 ether; - address private constant OWNER = address(0xdead); - - Blue private blue; - ERC20 private borrowableAsset; - ERC20 private collateralAsset; - Oracle private borrowableOracle; - Oracle private collateralOracle; - Irm private irm; + address internal constant BORROWER = address(1234); + address internal constant LIQUIDATOR = address(5678); + uint256 internal constant LLTV = 0.8 ether; + address internal constant OWNER = address(0xdead); + + Blue internal blue; + ERC20 internal borrowableAsset; + ERC20 internal collateralAsset; + Oracle internal borrowableOracle; + Oracle internal collateralOracle; + Irm internal irm; Market public market; Id public id; @@ -93,4 +93,10 @@ contract BlueBaseTest is Test { uint256 totalBorrow = blue.totalBorrow(id); return borrowerShares.divWadUp(totalShares).mulWadUp(totalBorrow); } + + function neq(Market memory a, Market memory b) internal pure returns (bool) { + return a.borrowableAsset != b.borrowableAsset || a.collateralAsset != b.collateralAsset + || a.borrowableOracle != b.borrowableOracle || a.collateralOracle != b.collateralOracle || a.lltv != b.lltv + || a.irm != b.irm; + } } diff --git a/test/forge/integration/TestIntegrationCreateMarket.sol b/test/forge/integration/TestIntegrationCreateMarket.sol new file mode 100644 index 000000000..6dc05b514 --- /dev/null +++ b/test/forge/integration/TestIntegrationCreateMarket.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.21; + +import "test/forge/BlueBase.t.sol"; + +contract IntegrationCreateMarketTest is BlueBaseTest { + function testCreateMarketWithNotEnabledIrm(Market memory marketFuzz) public { + vm.assume(marketFuzz.irm != irm); + + vm.prank(OWNER); + vm.expectRevert(bytes(Errors.IRM_NOT_ENABLED)); + blue.createMarket(marketFuzz); + } +} \ No newline at end of file diff --git a/test/forge/integration/TestIntegrationSupply.sol b/test/forge/integration/TestIntegrationSupply.sol index 6f91f3274..2bb1278ba 100644 --- a/test/forge/integration/TestIntegrationSupply.sol +++ b/test/forge/integration/TestIntegrationSupply.sol @@ -1,9 +1,11 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.20; +pragma solidity 0.8.21; import "test/forge/BlueBase.t.sol"; -contract BlueBaseTest is BlueBaseTest { +contract IntegrationSupplyTest is BlueBaseTest { + + function testSupplyUnknownMarket(Market memory marketFuzz) public { vm.assume(neq(marketFuzz, market)); @@ -11,12 +13,31 @@ contract BlueBaseTest is BlueBaseTest { blue.supply(marketFuzz, 1, address(this)); } - function testSupplyUnknownMarket() public { + function testSupplyZeroAmount() public { vm.expectRevert("zero amount"); blue.supply(market, 0, address(this)); } - function testSupply(uint256 amount) {} + function testSupply(uint256 amount) public { + amount = bound(amount, 1, 2 ** 64); + + borrowableAsset.setBalance(address(this), amount); + blue.supply(market, amount, address(this)); + + assertEq(blue.supplyShare(id, address(this)), amount * SharesMath.VIRTUAL_SHARES, "supply share"); + assertEq(borrowableAsset.balanceOf(address(this)), 0, "lender balance"); + assertEq(borrowableAsset.balanceOf(address(blue)), amount, "blue balance"); + } + + function testSupplyOnBehalf(uint256 amount, address onBehalf) public { + vm.assume(onBehalf != address(blue)); + amount = bound(amount, 1, 2 ** 64); - function testSupplyOnBehalf(uint256 amount, address onBehalf) {} + borrowableAsset.setBalance(address(this), amount); + blue.supply(market, amount, onBehalf); + + assertEq(blue.supplyShare(id, onBehalf), amount * SharesMath.VIRTUAL_SHARES, "supply share"); + assertEq(borrowableAsset.balanceOf(onBehalf), 0, "lender balance"); + assertEq(borrowableAsset.balanceOf(address(blue)), amount, "blue balance"); + } }