-
Notifications
You must be signed in to change notification settings - Fork 35
/
Challenge4.t.sol
58 lines (42 loc) · 2.01 KB
/
Challenge4.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
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import "forge-std/Test.sol";
import {VaultFactory} from "../src/4_RescuePosi/myVaultFactory.sol";
import {VaultWalletTemplate} from "../src/4_RescuePosi/myVaultWalletTemplate.sol";
import {PosiCoin} from "../src/4_RescuePosi/PosiCoin.sol";
/*////////////////////////////////////////////////////////////
// DEFINE ANY NECESSARY CONTRACTS HERE //
// If you need a contract for your hack, define it below //
////////////////////////////////////////////////////////////*/
/*////////////////////////////////////////////////////////////
// TEST CONTRACT //
////////////////////////////////////////////////////////////*/
contract Challenge4Test is Test {
VaultFactory public FACTORY;
PosiCoin public POSI;
address public unclaimedAddress = 0x92fF93023d916bC4580B535a077601d5cda5665E;
address public whitehat = makeAddr("whitehat");
address public devs = makeAddr("devs");
function setUp() public {
vm.label(unclaimedAddress, "Unclaimed Address");
// Instantiate the Factory
FACTORY = new VaultFactory();
// Instantiate the POSICoin
POSI = new PosiCoin();
// OOPS transferred to the wrong address!
POSI.transfer(unclaimedAddress, 1000 ether);
}
function testWhitehatRescue() public {
vm.deal(whitehat, 10 ether);
vm.startPrank(whitehat, whitehat);
/*////////////////////////////////////////////////////
// Add your hack below! //
// //
// terminal command to run the specific test: //
// forge test --match-contract Challenge4Test -vvvv //
////////////////////////////////////////////////////*/
//==================================================//
vm.stopPrank();
assertEq(POSI.balanceOf(devs), 1000 ether, "devs' POSI balance should be 1000 POSI");
}
}