chore: sync submodule state (parent ref update)
Made-with: Cursor
This commit is contained in:
93
test/dex/DODOPMMIntegration.t.sol
Normal file
93
test/dex/DODOPMMIntegration.t.sol
Normal file
@@ -0,0 +1,93 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import {Test, console} from "forge-std/Test.sol";
|
||||
import "../../contracts/dex/DODOPMMIntegration.sol";
|
||||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
||||
|
||||
contract MockERC20 is ERC20 {
|
||||
constructor(string memory name, string memory symbol) ERC20(name, symbol) {
|
||||
_mint(msg.sender, 1000000 ether);
|
||||
}
|
||||
}
|
||||
|
||||
contract DODOPMMIntegrationTest is Test {
|
||||
DODOPMMIntegration public integration;
|
||||
address public dvm = address(0xdEaD);
|
||||
address public dodoApprove = address(0xD0D0);
|
||||
MockERC20 public officialUSDT;
|
||||
MockERC20 public officialUSDC;
|
||||
MockERC20 public compliantUSDT;
|
||||
MockERC20 public compliantUSDC;
|
||||
address public admin = address(0xAD);
|
||||
|
||||
function setUp() public {
|
||||
officialUSDT = new MockERC20("USDT", "USDT");
|
||||
officialUSDC = new MockERC20("USDC", "USDC");
|
||||
compliantUSDT = new MockERC20("cUSDT", "cUSDT");
|
||||
compliantUSDC = new MockERC20("cUSDC", "cUSDC");
|
||||
vm.mockCall(
|
||||
dvm,
|
||||
abi.encodeWithSelector(
|
||||
DODOPMMIntegration.createPool.selector
|
||||
),
|
||||
abi.encode(address(0x1001))
|
||||
);
|
||||
integration = new DODOPMMIntegration(
|
||||
admin,
|
||||
dvm,
|
||||
dodoApprove,
|
||||
address(officialUSDT),
|
||||
address(officialUSDC),
|
||||
address(compliantUSDT),
|
||||
address(compliantUSDC)
|
||||
);
|
||||
// admin already has POOL_MANAGER_ROLE from constructor
|
||||
}
|
||||
|
||||
function testCreatePoolGeneric() public {
|
||||
address baseToken = address(0xB1);
|
||||
address quoteToken = address(0xB2);
|
||||
address mockPoolAddr = address(0xBeef);
|
||||
vm.mockCall(dvm, bytes(""), abi.encode(mockPoolAddr));
|
||||
vm.prank(admin);
|
||||
address pool = integration.createPool(
|
||||
baseToken,
|
||||
quoteToken,
|
||||
3,
|
||||
1e18,
|
||||
0.5e18,
|
||||
true
|
||||
);
|
||||
assertEq(pool, mockPoolAddr);
|
||||
assertEq(integration.pools(baseToken, quoteToken), mockPoolAddr);
|
||||
assertEq(integration.pools(quoteToken, baseToken), mockPoolAddr);
|
||||
assertTrue(integration.isRegisteredPool(mockPoolAddr));
|
||||
}
|
||||
|
||||
function testCreatePoolRevertsSameToken() public {
|
||||
vm.prank(admin);
|
||||
vm.expectRevert("DODOPMMIntegration: same token");
|
||||
integration.createPool(
|
||||
address(officialUSDT),
|
||||
address(officialUSDT),
|
||||
3,
|
||||
1e18,
|
||||
0.5e18,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
function testCreatePoolRevertsZeroBase() public {
|
||||
vm.prank(admin);
|
||||
vm.expectRevert("DODOPMMIntegration: zero base");
|
||||
integration.createPool(
|
||||
address(0),
|
||||
address(officialUSDT),
|
||||
3,
|
||||
1e18,
|
||||
0.5e18,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user