-
Notifications
You must be signed in to change notification settings - Fork 21
/
DexTwo.t.sol
39 lines (29 loc) · 1.01 KB
/
DexTwo.t.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "forge-std/Test.sol";
import "./DexTwoFactory.sol";
contract DexTwoTest is Test {
DexTwoFactory factory;
function setUp() public {
factory = new DexTwoFactory();
}
function testDexTwo() public {
address dex = factory.createInstance(address(this));
address token1 = DexTwo(dex).token1();
address token2 = DexTwo(dex).token2();
SwappableTokenTwo token3 = new SwappableTokenTwo(
address(this),
"Token 3",
"TKN3",
400
);
token3.approve(dex, type(uint256).max);
DexTwo(dex).approve(dex, type(uint256).max);
token3.transfer(dex, 100);
DexTwo(dex).swap(address(token3), token1, 100);
DexTwo(dex).swap(address(token3), token2, 200);
assertEq(IERC20(token1).balanceOf(dex), 0);
assertEq(IERC20(token2).balanceOf(dex), 0);
assertTrue(factory.validateInstance(payable(dex), address(this)));
}
}