diff --git a/fixtures/solidity/translated_semantic_tests/various/selfdestruct_post_cancun/selfdestruct_post_cancun.sol b/fixtures/solidity/translated_semantic_tests/various/selfdestruct_post_cancun/selfdestruct_post_cancun.sol index 60678b04c..dce992e16 100644 --- a/fixtures/solidity/translated_semantic_tests/various/selfdestruct_post_cancun/selfdestruct_post_cancun.sol +++ b/fixtures/solidity/translated_semantic_tests/various/selfdestruct_post_cancun/selfdestruct_post_cancun.sol @@ -12,38 +12,39 @@ contract C { contract D { C public c; constructor() payable {} + function call() public payable { + // Just for sending funds to this contract + } function deploy_create() public payable { c = new C{value: 1 ether}(); } function deploy_create2() public payable { c = new C{value: 1 ether, salt: hex"1234"}(); } + + function transferAllFunds() public returns (bool) { + bool success = payable(msg.sender).send(address(this).balance); + return success; + } + function terminate() public { // NOTE: A second call to `c.terminate()` or any other function of the contract `c` will succeed if the // previous selfdestruct was performed in a different transaction, since the contract will still exists. c.terminate(); } - function test_create_and_terminate() public { + function create_and_terminate() public { deploy_create(); - assert(exists()); - test_balance_after_create(); terminate(); - test_balance_after_selfdestruct(); } - function test_create2_and_terminate() public { + function create2_and_terminate() public { deploy_create2(); - assert(exists()); - test_balance_after_create(); terminate(); - test_balance_after_selfdestruct(); } - function test_balance_after_create() public view { - assert(address(this).balance == 0); - assert(address(c).balance == 1 ether); + function balance() public view returns (uint) { + return address(this).balance; } - function test_balance_after_selfdestruct() public view { - assert(address(this).balance == 1 ether); - assert(address(c).balance == 0); + function balance_inner() public view returns (uint) { + return address(c).balance; } function exists() public view returns (bool) { return address(c).code.length != 0; diff --git a/fixtures/solidity/translated_semantic_tests/various/selfdestruct_post_cancun/test.json b/fixtures/solidity/translated_semantic_tests/various/selfdestruct_post_cancun/test.json index 90e154fa5..08a1d217e 100644 --- a/fixtures/solidity/translated_semantic_tests/various/selfdestruct_post_cancun/test.json +++ b/fixtures/solidity/translated_semantic_tests/various/selfdestruct_post_cancun/test.json @@ -5,7 +5,7 @@ "inputs": [ { "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", - "comment": "constructor(), 1 ether ->; gas irOptimized: 67028; gas irOptimized code: 175400; gas legacy: 76227; gas legacy code: 298200; gas legacyOptimized: 66516; gas legacyOptimized code: 168000", + "comment": "0 constructor(), 1 ether ->; gas irOptimized: 67028; gas irOptimized code: 175400; gas legacy: 76227; gas legacy code: 298200; gas legacyOptimized: 66516; gas legacyOptimized code: 168000", "instance": "D", "method": "#deployer", "calldata": [], @@ -16,7 +16,7 @@ }, { "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", - "comment": "exists() -> false", + "comment": "1 exists() -> false", "instance": "D", "method": "exists()", "calldata": [], @@ -27,17 +27,55 @@ }, { "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", - "comment": "test_create_and_terminate() ->", + "comment": "2 terminate() -> FAILURE", "instance": "D", - "method": "test_create_and_terminate()", + "method": "terminate()", + "calldata": [], + "expected": { + "exception": true + } + }, + + + + + + + { + "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", + "comment": "3 create_and_terminate() ->", + "instance": "D", + "method": "create_and_terminate()", + "calldata": [], + "expected": { + "exception": false + } + }, + { + "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", + "comment": "4 balance() -> 1010000000000000000", + "instance": "D", + "method": "balance()", "calldata": [], "expected": { + "return_data": "0x0000000000000000000000000000000000000000000000000e043da617250000", "exception": false } }, { "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", - "comment": "exists() -> false", + "comment": "5 balance_inner() -> 0", + "instance": "D", + "method": "balance_inner()", + "calldata": [], + "expected": { + "return_data": "0x0000000000000000000000000000000000000000000000000000000000000000", + "exception": false + } + }, + { + "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", + "comment": "6 exists() -> false", "instance": "D", "method": "exists()", "calldata": [], @@ -46,93 +84,121 @@ "exception": false } }, + + + + + { "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", - "comment": "terminate() -> FAILURE", + "comment": "7 transferAllFunds() -> true", "instance": "D", - "method": "terminate()", + "method": "transferAllFunds()", "calldata": [], "expected": { - "exception": true + "return_data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "exception": false } }, { "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", - "comment": "deploy_create() ->", + "comment": "8 balance() -> 0", "instance": "D", - "method": "deploy_create()", + "method": "balance()", "calldata": [], "expected": { + "return_data": "0x0000000000000000000000000000000000000000000000000000000000000000", "exception": false } }, { "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", - "comment": "test_balance_after_create() ->", + "comment": "9 call() ->", + "instance": "D", + "method": "call()", + "calldata": [], + "expected": { + "exception": false + }, + "value": "1000000000000000000 wei" + }, + { + "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", + "comment": "10 balance() -> 1000000000000000000", "instance": "D", - "method": "test_balance_after_create()", + "method": "balance()", "calldata": [], "expected": { + "return_data": "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", "exception": false } }, + + + + { "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", - "comment": "exists() -> true", + "comment": "11 create2_and_terminate() ->", "instance": "D", - "method": "exists()", + "method": "create2_and_terminate()", "calldata": [], "expected": { - "return_data": "0x0000000000000000000000000000000000000000000000000000000000000001", "exception": false } }, { "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", - "comment": "terminate() ->", + "comment": "12 balance() -> 1010000000000000000", "instance": "D", - "method": "terminate()", + "method": "balance()", "calldata": [], "expected": { + "return_data": "0x0000000000000000000000000000000000000000000000000e043da617250000", "exception": false } }, { "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", - "comment": "test_balance_after_selfdestruct() ->", + "comment": "13 balance_inner() -> 0", "instance": "D", - "method": "test_balance_after_selfdestruct()", + "method": "balance_inner()", "calldata": [], "expected": { + "return_data": "0x0000000000000000000000000000000000000000000000000000000000000000", "exception": false } }, { "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", - "comment": "exists() -> true", + "comment": "14 exists() -> false", "instance": "D", "method": "exists()", "calldata": [], "expected": { - "return_data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "return_data": "0x0000000000000000000000000000000000000000000000000000000000000000", "exception": false } }, + + + { "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", - "comment": "test_create2_and_terminate() ->", + "comment": "15 transferAllFunds() -> true", "instance": "D", - "method": "test_create2_and_terminate()", + "method": "transferAllFunds()", "calldata": [], "expected": { + "return_data": "0x0000000000000000000000000000000000000000000000000000000000000001", "exception": false } }, { "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", - "comment": "exists() -> false", + "comment": "16 balance() -> 0", "instance": "D", - "method": "exists()", + "method": "balance()", "calldata": [], "expected": { "return_data": "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -141,9 +207,37 @@ }, { "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", - "comment": "deploy_create2() ->", + "comment": "17 call() ->", "instance": "D", - "method": "deploy_create2()", + "method": "call()", + "calldata": [], + "expected": { + "exception": false + }, + "value": "1000000000000000000 wei" + }, + { + "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", + "comment": "18 balance() -> 1000000000000000000", + "instance": "D", + "method": "balance()", + "calldata": [], + "expected": { + "return_data": "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", + "exception": false + } + }, + + + + + + + { + "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", + "comment": "19 deploy_create() ->", + "instance": "D", + "method": "deploy_create()", "calldata": [], "expected": { "exception": false @@ -151,17 +245,29 @@ }, { "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", - "comment": "test_balance_after_create() ->", + "comment": "20 balance() ->", "instance": "D", - "method": "test_balance_after_create()", + "method": "balance()", "calldata": [], "expected": { + "return_data": "0x0000000000000000000000000000000000000000000000000000000000000000", "exception": false } }, { "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", - "comment": "exists() -> true", + "comment": "21 balance_inner() ->", + "instance": "D", + "method": "balance_inner()", + "calldata": [], + "expected": { + "return_data": "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", + "exception": false + } + }, + { + "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", + "comment": "22 exists() -> true", "instance": "D", "method": "exists()", "calldata": [], @@ -172,7 +278,7 @@ }, { "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", - "comment": "terminate() ->", + "comment": "23 terminate() ->", "instance": "D", "method": "terminate()", "calldata": [], @@ -182,17 +288,68 @@ }, { "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", - "comment": "test_balance_after_selfdestruct() ->", + "comment": "24 balance_inner() ->", + "instance": "D", + "method": "balance_inner()", + "calldata": [], + "expected": { + "return_data": "0x0000000000000000000000000000000000000000000000000000000000000000", + "exception": false + } + }, + { + "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", + "comment": "25 exists() -> true", + "instance": "D", + "method": "exists()", + "calldata": [], + "expected": { + "return_data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "exception": false + } + }, + + + + + + + + { + "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", + "comment": "26 deploy_create2() ->", + "instance": "D", + "method": "deploy_create2()", + "calldata": [], + "expected": { + "exception": false + } + }, + { + "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", + "comment": "27 balance() ->", "instance": "D", - "method": "test_balance_after_selfdestruct()", + "method": "balance()", "calldata": [], "expected": { + "return_data": "0x0000000000000000000000000000000000000000000000000000000000000000", "exception": false } }, { "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", - "comment": "exists() -> true", + "comment": "28 balance_inner() ->", + "instance": "D", + "method": "balance_inner()", + "calldata": [], + "expected": { + "return_data": "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", + "exception": false + } + }, + { + "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", + "comment": "29 exists() -> true", "instance": "D", "method": "exists()", "calldata": [], @@ -203,13 +360,35 @@ }, { "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", - "comment": "terminate() ->", + "comment": "30 terminate() ->", "instance": "D", "method": "terminate()", "calldata": [], "expected": { "exception": false } + }, + { + "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", + "comment": "31 balance_inner() ->", + "instance": "D", + "method": "balance_inner()", + "calldata": [], + "expected": { + "return_data": "0x0000000000000000000000000000000000000000000000000000000000000000", + "exception": false + } + }, + { + "caller": "0x185303174a8eee5cc1ee9e56a23cd8b6a7db7616", + "comment": "32 exists() -> true", + "instance": "D", + "method": "exists()", + "calldata": [], + "expected": { + "return_data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "exception": false + } } ] }