Skip to content

Commit 4a23e6c

Browse files
committed
Tests for basefee
1 parent b168ef4 commit 4a23e6c

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
contract C {
2+
function f() public returns (uint) {
3+
return block.basefee;
4+
}
5+
function g() public returns (uint ret) {
6+
assembly {
7+
ret := basefee()
8+
}
9+
}
10+
}
11+
// ====
12+
// EVMVersion: >=london
13+
// compileViaYul: also
14+
// ----
15+
// f() -> FAILURE
16+
// f() -> FAILURE
17+
// f() -> FAILURE
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
contract C {
2+
function f() public view returns (uint) {
3+
return block.basefee;
4+
}
5+
function g() public view returns (uint ret) {
6+
assembly {
7+
ret := basefee()
8+
}
9+
}
10+
}
11+
// ====
12+
// EVMVersion: <=london
13+
// ----
14+
// TypeError 5921: (74-87): "basefee" is not supported by the VM version.
15+
// TypeError 5430: (183-190): The "basefee" instruction is only available for London-compatible VMs (you are currently compiling for "berlin").
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
contract C {
2+
function f() public view returns (uint) {
3+
return block.basefee;
4+
}
5+
function g() public view returns (uint ret) {
6+
assembly {
7+
ret := basefee()
8+
}
9+
}
10+
}
11+
// ====
12+
// EVMVersion: >=london
13+
// ----
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
contract C {
2+
function f() public pure {
3+
assembly { pop(basefee()) }
4+
}
5+
function g() public pure returns (uint) {
6+
return block.basefee;
7+
}
8+
}
9+
// ====
10+
// EVMVersion: >=london
11+
// ----
12+
// TypeError 2527: (67-76): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
13+
// TypeError 2527: (147-160): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".

0 commit comments

Comments
 (0)