forked from ethereum/solidity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also drop less useful EndToEndTest
- Loading branch information
Showing
2 changed files
with
46 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
contract C { | ||
event Terminated(); | ||
|
||
constructor() payable { | ||
} | ||
|
||
function terminate() external { | ||
emit Terminated(); | ||
selfdestruct(payable(msg.sender)); | ||
// Execution stops here, so the second one is not executed. | ||
selfdestruct(payable(msg.sender)); | ||
emit Terminated(); | ||
} | ||
} | ||
|
||
contract D { | ||
C public c; | ||
|
||
constructor() payable { | ||
c = new C{value: 1 ether}(); | ||
} | ||
|
||
function f() external { | ||
c.terminate(); | ||
} | ||
|
||
function exists() external returns (bool) { | ||
return address(c).code.length != 0; | ||
} | ||
} | ||
// ---- | ||
// constructor(), 1 ether -> | ||
// gas irOptimized: 188203 | ||
// gas legacy: 261114 | ||
// gas legacyOptimized: 181602 | ||
// c() -> 0x137aa4dfc0911524504fcd4d98501f179bc13b4a | ||
// balance: 0x137aa4dfc0911524504fcd4d98501f179bc13b4a -> 1000000000000000000 | ||
// balance -> 0 | ||
// exists() -> true | ||
// f() -> | ||
// ~ emit Terminated() from 0x137aa4dfc0911524504fcd4d98501f179bc13b4a | ||
// balance: 0x137aa4dfc0911524504fcd4d98501f179bc13b4a -> 0 | ||
// ~ emit Terminated() from 0x137aa4dfc0911524504fcd4d98501f179bc13b4a | ||
// balance -> 1000000000000000000 | ||
// ~ emit Terminated() from 0x137aa4dfc0911524504fcd4d98501f179bc13b4a | ||
// exists() -> false |