-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
debug.rs
94 lines (82 loc) · 2.37 KB
/
debug.rs
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
use itertools::Itertools;
use std::path::Path;
// Sets up a debuggable test case.
// Run with `cargo test-debugger`.
forgetest_async!(
#[ignore = "ran manually"]
manual_debug_setup,
|prj, cmd| {
cmd.args(["init", "--force"]).arg(prj.root()).assert_non_empty_stdout();
cmd.forge_fuse();
prj.add_source("Counter2.sol", r#"
contract A {
address public a;
uint public b;
int public c;
bytes32 public d;
bool public e;
bytes public f;
string public g;
constructor(address _a, uint _b, int _c, bytes32 _d, bool _e, bytes memory _f, string memory _g) {
a = _a;
b = _b;
c = _c;
d = _d;
e = _e;
f = _f;
g = _g;
}
function getA() public view returns (address) {
return a;
}
function setA(address _a) public {
a = _a;
}
}"#,
)
.unwrap();
let script = prj.add_script("Counter.s.sol", r#"
import "../src/Counter2.sol";
import "forge-std/Script.sol";
import "forge-std/Test.sol";
contract B is A {
A public other;
address public self = address(this);
constructor(address _a, uint _b, int _c, bytes32 _d, bool _e, bytes memory _f, string memory _g)
A(_a, _b, _c, _d, _e, _f, _g)
{
other = new A(_a, _b, _c, _d, _e, _f, _g);
}
}
contract Script0 is Script, Test {
function run() external {
assertEq(uint256(1), uint256(1));
vm.startBroadcast();
B b = new B(msg.sender, 2 ** 32, -1 * (2 ** 32), keccak256(abi.encode(1)), true, "abcdef", "hello");
assertEq(b.getA(), msg.sender);
b.setA(tx.origin);
assertEq(b.getA(), tx.origin);
address _b = b.self();
bytes32 _d = b.d();
bytes32 _d2 = b.other().d();
}
}"#,
)
.unwrap();
cmd.args(["build"]).assert_success();
cmd.forge_fuse();
cmd.args([
"script",
script.to_str().unwrap(),
"--root",
prj.root().to_str().unwrap(),
"--tc=Script0",
"--debug",
]);
eprintln!("root: {}", prj.root().display());
let cmd_path = Path::new(cmd.cmd().get_program()).canonicalize().unwrap();
let args = cmd.cmd().get_args().map(|s| s.to_str().unwrap()).format(" ");
eprintln!(" cmd: {} {args}", cmd_path.display());
std::mem::forget(prj);
}
);