-
Notifications
You must be signed in to change notification settings - Fork 1
/
Truster.t.sol
37 lines (30 loc) · 1.28 KB
/
Truster.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
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "forge-std/Test.sol";
import "forge-std/console.sol";
import { DamnValuableToken } from "../src/DamnValuableToken.sol";
import { TrusterLenderPool } from "../src/truster/TrusterLenderPool.sol";
import { Attacker } from "../src/truster/Attacker.sol";
contract TrusterTest is Test {
uint256 internal constant TOKENS_IN_POOL = 1_000_000e18;
Attacker attacker;
DamnValuableToken token;
TrusterLenderPool pool;
function setUp() public{
token = new DamnValuableToken();
pool = new TrusterLenderPool(token);
token.transfer(address(pool), TOKENS_IN_POOL);
assertEq(token.balanceOf(address(pool)), TOKENS_IN_POOL);
}
function testExploit() public {
attacker = new Attacker(address(pool), address(token));
validation();
}
function validation() internal {
assertEq(token.balanceOf(address(pool)), 0);
assertEq(token.balanceOf(address(attacker)), TOKENS_IN_POOL);
console.log("Balance of the attacker: ", token.balanceOf(address(attacker)) / 1e18);
console.log("Balance of the pool: ", token.balanceOf(address(pool)) / 1e18);
console.log(unicode"\n🎉🥳 Congratulations, you beat the level!!! 🥳🎉");
}
}