-
Notifications
You must be signed in to change notification settings - Fork 5
/
SakarDEXCTFTest.t.sol
74 lines (51 loc) · 2.21 KB
/
SakarDEXCTFTest.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import {Test, console2} from "forge-std/Test.sol";
import {SakarDEXCTFDeployer} from "script/sakarkc2122-dex/SakarDEXCTFDeployer.s.sol";
import {IDex} from "src/sakarkc2122-dex/interfaces/IDex.sol";
import {IToken1} from "src/sakarkc2122-dex/interfaces/IToken1.sol";
import {IToken2} from "src/sakarkc2122-dex/interfaces/IToken2.sol";
/*///////////////////////////////////////////////
// Import dependencies for your solution here! //
// (if you need any) //
///////////////////////////////////////////////*/
contract PomodoroeCTFTest is Test, SakarDEXCTFDeployer {
IDex public dex;
IToken1 public token1;
IToken2 public token2;
/// @notice Deploy the ExampleCTF and the solution contract
function setUp() public override(SakarDEXCTFDeployer) {
address sakar = makeAddr("I am Sakar and I am deploying this CTF!");
SakarDEXCTFDeployer.setUp();
(address _dex, address _token1, address _token2) = deploySakarDEXCTF();
dex = IDex(_dex);
token1 = IToken1(_token1);
token2 = IToken2(_token2);
vm.startPrank(sakar);
token1.mint(sakar, 1000);
token2.mint(sakar, 1000);
dex.setTokens(address(token1), address(token2));
token1.approve(address(dex), type(uint256).max);
token2.approve(address(dex), type(uint256).max);
dex.addLiquidity(address(token1), 1000);
dex.addLiquidity(address(token2), 1000);
vm.stopPrank();
}
/// @notice Test that the ExampleCTF is unsolved if we don't do anything
function test_sakarDEXUnsolved() external {
address user = makeAddr("user");
token1.mint(user, 100);
token2.mint(user, 100);
assertFalse(dex.isSolved());
}
/// @notice Test that the ExampleCTF is solved if we call the solve function
function test_sakarDEXSolved() external {
address user = makeAddr("user");
token1.mint(user, 100);
token2.mint(user, 100);
/*//////////////////////////////////////
// Write your solution here //
//////////////////////////////////////*/
assertTrue(dex.isSolved());
}
}