-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPuzzleBox.t.sol
52 lines (45 loc) · 1.62 KB
/
PuzzleBox.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "forge-std/Test.sol";
import "../src/PuzzleBox.sol";
import "../src/PuzzleBoxSolution_V0.sol";
contract PuzzleBoxFixture is Test {
event Lock(bytes4 selector, bool isLocked);
event Operate(address operator);
event Drip(uint256 dripId, uint256 fee);
event Spread(uint256 amount, uint256 remaining);
event Zip();
event Creep();
event Torch(uint256[] dripIds);
event Burned(uint256 dripId);
event Open(address winner);
PuzzleBoxFactory _factory = new PuzzleBoxFactory();
PuzzleBox _puzzle;
PuzzleBoxSolution_V0 _solution;
// address deployer;
// Use a modifier instead of setUp() to keep it all in one tx.
modifier initEnv() {
// deployer = vm.addr(0xcc7ec7a48ef9945cd647aa5c01a0dc8967612dd70c0a24f7bfb53e29a04f04fe);
// vm.deal(deployer, 1 ether);
// vm.startPrank(deployer);
_puzzle = _factory.createPuzzleBox{value: 1337}();
_solution = PuzzleBoxSolution_V0(address(new SolutionContainer(type(PuzzleBoxSolution_V0).runtimeCode)));
_;
}
function test_win() external initEnv {
// Uncomment to verify a complete solution.
// vm.expectEmit(false, false, false, false, address(_puzzle));
// emit Open(address(0));
// vm.breakpoint("b");
uint256 gas = gasleft();
_solution.solve(_puzzle);
console.log("GAS USED", gas - gasleft());
}
}
contract SolutionContainer {
constructor(bytes memory solutionRuntime) {
assembly {
return(add(solutionRuntime, 0x20), mload(solutionRuntime))
}
}
}