aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-11-30 23:06:18 +0800
committerchriseth <c@ethdev.com>2015-11-30 23:06:18 +0800
commita8736b7b271dac117f15164cf4d2dfabcdd2c6fd (patch)
treefd868faadee1029f9466e98c8159f402c1921d1d /test
parenta3801be40c264296a6530d62141d96546b884190 (diff)
parentb97bb086de91e1f834e6e92cfdc8a985a6f761de (diff)
downloaddexon-solidity-a8736b7b271dac117f15164cf4d2dfabcdd2c6fd.tar.gz
dexon-solidity-a8736b7b271dac117f15164cf4d2dfabcdd2c6fd.tar.zst
dexon-solidity-a8736b7b271dac117f15164cf4d2dfabcdd2c6fd.zip
Merge pull request #256 from chriseth/selfdestruct
Introduce selfdestruct alias for suicide.
Diffstat (limited to 'test')
-rw-r--r--test/contracts/Wallet.cpp4
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp16
2 files changed, 18 insertions, 2 deletions
diff --git a/test/contracts/Wallet.cpp b/test/contracts/Wallet.cpp
index 4a4848f1..476e817b 100644
--- a/test/contracts/Wallet.cpp
+++ b/test/contracts/Wallet.cpp
@@ -361,9 +361,9 @@ contract Wallet is multisig, multiowned, daylimit {
multiowned(_owners, _required) daylimit(_daylimit) {
}
- // kills the contract sending everything to `_to`.
+ // destroys the contract sending everything to `_to`.
function kill(address _to) onlymanyowners(sha3(msg.data)) external {
- suicide(_to);
+ selfdestruct(_to);
}
// gets called when no other function matches
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 5782e6c8..78ceacfa 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -1483,6 +1483,22 @@ BOOST_AUTO_TEST_CASE(suicide)
BOOST_CHECK_EQUAL(m_state.balance(address), amount);
}
+BOOST_AUTO_TEST_CASE(selfdestruct)
+{
+ char const* sourceCode = "contract test {\n"
+ " function a(address receiver) returns (uint ret) {\n"
+ " selfdestruct(receiver);\n"
+ " return 10;\n"
+ " }\n"
+ "}\n";
+ u256 amount(130);
+ compileAndRun(sourceCode, amount);
+ u160 address(23);
+ BOOST_CHECK(callContractFunction("a(address)", address) == bytes());
+ BOOST_CHECK(!m_state.addressHasCode(m_contractAddress));
+ BOOST_CHECK_EQUAL(m_state.balance(address), amount);
+}
+
BOOST_AUTO_TEST_CASE(sha3)
{
char const* sourceCode = "contract test {\n"