-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[evm] add SelfDestruct6780 test (#4509)
- Loading branch information
Showing
6 changed files
with
157 additions
and
13 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
37 changes: 37 additions & 0 deletions
37
action/protocol/execution/testdata-cancun/selfdestruct.json
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,37 @@ | ||
{ | ||
"initGenesis": { | ||
"isBering" : true, | ||
"isIceland" : true, | ||
"isLondon" : true, | ||
"isShanghai" : true, | ||
"isCancun": true | ||
}, | ||
"initBalances": [{ | ||
"account": "io1mflp9m6hcgm2qcghchsdqj3z3eccrnekx9p0ms", | ||
"rawBalance": "1000000000000000000000000000" | ||
}], | ||
"deployments": [{ | ||
"rawByteCode": "608060405234801561000f575f80fd5b50335f806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506102f88061005c5f395ff3fe608060405260043610610037575f3560e01c80630c08bf881461004257806312065fe0146100585780638da5cb5b146100825761003e565b3661003e57005b5f80fd5b34801561004d575f80fd5b506100566100ac565b005b348015610063575f80fd5b5061006c610171565b60405161007991906101b3565b60405180910390f35b34801561008d575f80fd5b50610096610178565b6040516100a3919061020b565b60405180910390f35b5f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610139576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610130906102a4565b60405180910390fd5b5f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b5f47905090565b5f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b5f819050919050565b6101ad8161019b565b82525050565b5f6020820190506101c65f8301846101a4565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6101f5826101cc565b9050919050565b610205816101eb565b82525050565b5f60208201905061021e5f8301846101fc565b92915050565b5f82825260208201905092915050565b7f4f6e6c7920746865206f776e65722063616e2064657374726f792074686520635f8201527f6f6e747261637400000000000000000000000000000000000000000000000000602082015250565b5f61028e602783610224565b915061029982610234565b604082019050919050565b5f6020820190508181035f8301526102bb81610282565b905091905056fea2646970667358221220b78ecca519bda7ff2a88d8d2e964b5eaa98e01e80322cffe2fc97d17b9dcb6e464736f6c63430008180033", | ||
"rawPrivateKey": "cfa6ef757dee2e50351620dca002d32b9c090cfda55fb81f37f1d26b273743f1", | ||
"rawAmount": "0", | ||
"rawGasLimit": 5000000, | ||
"rawGasPrice": "2000000000000", | ||
"rawExpectedGasConsumed": 269559, | ||
"expectedStatus": 1, | ||
"expectedBalances": [], | ||
"comment": "deploy selfdestruct" | ||
}], | ||
"executions": [{ | ||
"rawPrivateKey": "cfa6ef757dee2e50351620dca002d32b9c090cfda55fb81f37f1d26b273743f1", | ||
"rawByteCode": "0c08bf88", | ||
"rawAmount": "0", | ||
"rawGasLimit": 1000000, | ||
"rawGasPrice": "2000000000000", | ||
"rawAccessList": [], | ||
"rawExpectedGasConsumed": 17819, | ||
"expectedStatus": 1, | ||
"readOnly": true, | ||
"rawReturnValue": "", | ||
"comment": "call selfdestruct" | ||
}] | ||
} |
18 changes: 18 additions & 0 deletions
18
action/protocol/execution/testdata-cancun/selfdestruct_oncreation.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,18 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
// this is the contract for "_selfdestructOnCreationContract" under blockchain/integrity | ||
|
||
contract SelfDestructOnCreation { | ||
address payable public owner; | ||
|
||
constructor() payable { | ||
owner = payable(msg.sender); // Set contract deployer as owner | ||
selfdestruct(owner); // Self-destruct the contract immediately, sending any funds to the recipient | ||
} | ||
|
||
// Function to check balance of the contract | ||
function getBalance() external view returns (uint256) { | ||
return address(this).balance; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
action/protocol/execution/testdata-cancun/selfdestruction.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 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
contract SelfDestructExample { | ||
address payable public owner; | ||
|
||
constructor() { | ||
owner = payable(msg.sender); // Set contract deployer as owner | ||
} | ||
|
||
// Function to self-destruct the contract | ||
function terminate() external { | ||
require(msg.sender == owner, "Only the owner can destroy the contract"); | ||
selfdestruct(owner); // Send remaining funds to the owner and destroy the contract | ||
} | ||
|
||
// Fallback function to receive Ether | ||
receive() external payable {} | ||
|
||
// Function to check balance of the contract | ||
function getBalance() external view returns (uint256) { | ||
return address(this).balance; | ||
} | ||
} |
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
Large diffs are not rendered by default.
Oops, something went wrong.