-
Notifications
You must be signed in to change notification settings - Fork 21
/
Stake.t.sol
36 lines (28 loc) · 973 Bytes
/
Stake.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
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
import "forge-std/Test.sol";
import "./StakeFactory.sol";
import "openzeppelin-contracts-08/token/ERC20/ERC20.sol";
contract StakeTest is Test {
StakeFactory factory;
Stake stakeInstance;
function setUp() public {
factory = new StakeFactory();
stakeInstance = Stake(factory.createInstance(address(this)));
}
function testStake() public {
new Deal{value: 0.0011 ether + 1}(stakeInstance);
ERC20 WETH = ERC20(stakeInstance.WETH());
WETH.approve(address(stakeInstance), type(uint256).max);
uint256 amount = 0.0011 ether;
stakeInstance.StakeWETH(amount);
stakeInstance.Unstake(amount);
assertTrue(factory.validateInstance(payable(address(stakeInstance)), address(this)));
}
receive() external payable {}
}
contract Deal {
constructor(Stake stake) payable {
stake.StakeETH{value: msg.value}();
}
}