File tree Expand file tree Collapse file tree 2 files changed +46
-23
lines changed Expand file tree Collapse file tree 2 files changed +46
-23
lines changed Original file line number Diff line number Diff line change @@ -912,29 +912,6 @@ BOOST_AUTO_TEST_CASE(transfer_ether)
912
912
)
913
913
}
914
914
915
- BOOST_AUTO_TEST_CASE (selfdestruct)
916
- {
917
- char const * sourceCode = R"(
918
- contract test {
919
- constructor() payable {}
920
- function a(address payable receiver) public returns (uint ret) {
921
- selfdestruct(receiver);
922
- return 10;
923
- }
924
- }
925
- )" ;
926
- u256 amount (130 );
927
- h160 address (23 );
928
- ALSO_VIA_YUL (
929
- DISABLE_EWASM_TESTRUN ()
930
-
931
- compileAndRun (sourceCode, amount);
932
- ABI_CHECK (callContractFunction (" a(address)" , address), bytes ());
933
- BOOST_CHECK (!addressHasCode (m_contractAddress));
934
- BOOST_CHECK_EQUAL (balanceAt (address), amount);
935
- )
936
- }
937
-
938
915
BOOST_AUTO_TEST_CASE (keccak256)
939
916
{
940
917
char const * sourceCode = R"(
Original file line number Diff line number Diff line change
1
+ contract C {
2
+ event Terminated ();
3
+
4
+ constructor () payable {
5
+ }
6
+
7
+ function terminate () external {
8
+ emit Terminated ();
9
+ selfdestruct (payable (msg .sender ));
10
+ // Execution stops here, so the second one is not executed.
11
+ selfdestruct (payable (msg .sender ));
12
+ emit Terminated ();
13
+ }
14
+ }
15
+
16
+ contract D {
17
+ C public c;
18
+
19
+ constructor () payable {
20
+ c = new C {value: 1 ether }();
21
+ }
22
+
23
+ function f () external {
24
+ c.terminate ();
25
+ }
26
+
27
+ function exists () external returns (bool ) {
28
+ return address (c).code.length != 0 ;
29
+ }
30
+ }
31
+ // ----
32
+ // constructor(), 1 ether ->
33
+ // gas irOptimized: 188203
34
+ // gas legacy: 261114
35
+ // gas legacyOptimized: 181602
36
+ // c() -> 0x137aa4dfc0911524504fcd4d98501f179bc13b4a
37
+ // balance: 0x137aa4dfc0911524504fcd4d98501f179bc13b4a -> 1000000000000000000
38
+ // balance -> 0
39
+ // exists() -> true
40
+ // f() ->
41
+ // ~ emit Terminated() from 0x137aa4dfc0911524504fcd4d98501f179bc13b4a
42
+ // balance: 0x137aa4dfc0911524504fcd4d98501f179bc13b4a -> 0
43
+ // ~ emit Terminated() from 0x137aa4dfc0911524504fcd4d98501f179bc13b4a
44
+ // balance -> 1000000000000000000
45
+ // ~ emit Terminated() from 0x137aa4dfc0911524504fcd4d98501f179bc13b4a
46
+ // exists() -> false
You can’t perform that action at this time.
0 commit comments