solidity/test/libsolidity/semanticTests/various/code_access_runtime.sol

29 lines
489 B
Solidity
Raw Normal View History

2020-05-06 15:40:06 +00:00
contract D {
uint256 x;
2020-06-23 12:14:24 +00:00
constructor() {
2020-05-06 15:40:06 +00:00
x = 7;
}
function f() public view returns (uint256) {
return x;
}
}
contract C {
function test() public returns (uint256) {
2020-07-15 15:26:51 +00:00
D d = new D();
bytes32 hash;
assembly { hash := extcodehash(d) }
assert(hash == keccak256(type(D).runtimeCode));
return 42;
2020-05-06 15:40:06 +00:00
}
}
// ====
// EVMVersion: >=constantinople
2020-07-15 15:26:51 +00:00
// compileViaYul: also
2020-05-06 15:40:06 +00:00
// ----
// test() -> 42
// gas legacy: 101638