-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eof: Update
semanticTests
tests for EOF
- Loading branch information
Showing
51 changed files
with
309 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,7 @@ contract D { | |
return test(); | ||
} | ||
} | ||
// ==== | ||
// bytecodeFormat: legacy | ||
// ---- | ||
// f() -> true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
test/libsolidity/semanticTests/functionCall/eof/call_options_overload.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
contract C { | ||
function f(uint x) external payable returns (uint) { return 1; } | ||
function f(uint x, uint y) external payable returns (uint) { return 2; } | ||
function call() public payable returns (uint x, uint y) { | ||
x = this.f{value: 10}(2); | ||
y = this.f{value: 10}(2, 3); | ||
} | ||
function bal() external returns (uint) { return address(this).balance; } | ||
receive() external payable {} | ||
} | ||
// ==== | ||
// bytecodeFormat: >=EOFv1 | ||
// ---- | ||
// (), 1 ether | ||
// call() -> 1, 2 | ||
// bal() -> 1000000000000000000 |
25 changes: 25 additions & 0 deletions
25
test/libsolidity/semanticTests/functionCall/eof/calling_nonexisting_contract.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
abstract contract D { | ||
function g() public virtual; | ||
} | ||
|
||
|
||
contract C { | ||
D d = D(address(0x1212)); | ||
|
||
function f() public returns (uint256) { | ||
// This call throws on legacy bytecode because of calling nonexisting contract. Legacy checks that there is | ||
// a non-empty code under under an address. EOF doesn't do it because non-observability assumption | ||
d.g(); | ||
return 7; | ||
} | ||
|
||
function h() public returns (uint256) { | ||
address(d).call(""); // this does not throw (low-level) | ||
return 7; | ||
} | ||
} | ||
// ==== | ||
// bytecodeFormat: >=EOFv1 | ||
// ---- | ||
// f() -> 7 | ||
// h() -> 7 |
24 changes: 24 additions & 0 deletions
24
test/libsolidity/semanticTests/functionCall/eof/external_call_at_construction_time.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// This tests skipping the extcodesize check. | ||
|
||
contract T { | ||
constructor() { this.f(); } | ||
function f() external {} | ||
} | ||
contract U { | ||
constructor() { this.f(); } | ||
function f() external returns (uint) {} | ||
} | ||
|
||
contract C { | ||
function f(uint c) external returns (uint) { | ||
if (c == 0) new T(); | ||
else if (c == 1) new U(); | ||
return 1 + c; | ||
} | ||
} | ||
// ==== | ||
// bytecodeFormat: >=EOFv1 | ||
// ---- | ||
// f(uint256): 0 -> 1 | ||
// f(uint256): 1 -> FAILURE | ||
// f(uint256): 2 -> 3 |
39 changes: 39 additions & 0 deletions
39
test/libsolidity/semanticTests/functionCall/eof/external_call_to_nonexisting.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// This tests skipping the extcodesize check. | ||
|
||
interface I { | ||
function a() external pure; | ||
function b() external; | ||
function c() external payable; | ||
function x() external returns (uint); | ||
function y() external returns (string memory); | ||
} | ||
contract C { | ||
I i = I(address(0xcafecafe)); | ||
constructor() payable {} | ||
function f(uint c) external returns (uint) { | ||
if (c == 0) i.a(); | ||
else if (c == 1) i.b(); | ||
else if (c == 2) i.c(); | ||
else if (c == 3) i.c{value: 1}(); | ||
else if (c == 4) i.x(); | ||
else if (c == 5) i.y(); | ||
return 1 + c; | ||
} | ||
} | ||
// ==== | ||
// bytecodeFormat: >=EOFv1 | ||
// ---- | ||
// constructor(), 1 ether -> | ||
// gas irOptimized: 88853 | ||
// gas irOptimized code: 164400 | ||
// gas legacy: 102721 | ||
// gas legacy code: 334400 | ||
// gas legacyOptimized: 91499 | ||
// gas legacyOptimized code: 196400 | ||
// f(uint256): 0 -> 1 | ||
// f(uint256): 1 -> 2 | ||
// f(uint256): 2 -> 3 | ||
// f(uint256): 3 -> 4 | ||
// f(uint256): 4 -> FAILURE | ||
// f(uint256): 5 -> FAILURE | ||
// f(uint256): 6 -> 7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,5 +19,7 @@ contract C { | |
return true; | ||
} | ||
} | ||
// ==== | ||
// bytecodeFormat: legacy | ||
// ---- | ||
// test_function() -> true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
test/libsolidity/semanticTests/reverts/eof/revert_return_area.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
contract C { | ||
fallback() external { | ||
revert("abc"); | ||
} | ||
|
||
function f() public returns (uint s, uint r) { | ||
address x = address(this); | ||
assembly { | ||
mstore(0, 7) | ||
s := extcall(x, 0, 0, 0) | ||
returndatacopy(0, 0, 32) | ||
r := mload(0) | ||
} | ||
} | ||
} | ||
// ==== | ||
// bytecodeFormat: >=EOFv1 | ||
// ---- | ||
// f() -> 0x01, 0x08c379a000000000000000000000000000000000000000000000000000000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
test/libsolidity/semanticTests/saltedCreate/eof/salted_create_with_value.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
contract B | ||
{ | ||
uint x; | ||
function getBalance() public view returns (uint) { | ||
return address(this).balance * 1000 + x; | ||
} | ||
constructor(uint _x) payable { | ||
x = _x; | ||
} | ||
} | ||
|
||
contract A { | ||
function f() public payable returns (uint, uint, uint) { | ||
B x = new B{salt: "abc1", value: 3}(7); | ||
B y = new B{value: 3, salt: "abc2"}(8); | ||
B z = new B{salt: "abc3", value: 3}(9); | ||
return (x.getBalance(), y.getBalance(), z.getBalance()); | ||
} | ||
} | ||
// ==== | ||
// bytecodeFormat: >=EOFv1 | ||
// ---- | ||
// f(), 10 ether -> 3007, 3008, 3009 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.