aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-07-01 18:38:27 +0800
committerGitHub <noreply@github.com>2017-07-01 18:38:27 +0800
commit06f8949f1033e6dc90e9645fcb6a869ecaaf5887 (patch)
tree48d2df042f06b357b293ff9648104e7e2d890063
parentb3be9d6fdc195519eccce22f07af5ee42af399ed (diff)
parent4dfc413b8e6e8f687fb19b1a39e0d2006f373579 (diff)
downloaddexon-solidity-06f8949f1033e6dc90e9645fcb6a869ecaaf5887.tar
dexon-solidity-06f8949f1033e6dc90e9645fcb6a869ecaaf5887.tar.gz
dexon-solidity-06f8949f1033e6dc90e9645fcb6a869ecaaf5887.tar.bz2
dexon-solidity-06f8949f1033e6dc90e9645fcb6a869ecaaf5887.tar.lz
dexon-solidity-06f8949f1033e6dc90e9645fcb6a869ecaaf5887.tar.xz
dexon-solidity-06f8949f1033e6dc90e9645fcb6a869ecaaf5887.tar.zst
dexon-solidity-06f8949f1033e6dc90e9645fcb6a869ecaaf5887.zip
Merge pull request #2498 from ethereum/enum_conversion
[WIP] Disallow storing invalid booleans
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index da725581..a6c01283 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -3702,6 +3702,50 @@ BOOST_AUTO_TEST_CASE(enum_explicit_overflow)
BOOST_CHECK(callContractFunction("getChoiceExp(uint256)", 0) == encodeArgs(0));
}
+BOOST_AUTO_TEST_CASE(storing_invalid_boolean)
+{
+ char const* sourceCode = R"(
+ contract C {
+ event Ev(bool);
+ bool public perm;
+ function set() returns(uint) {
+ bool tmp;
+ assembly {
+ tmp := 5
+ }
+ perm = tmp;
+ return 1;
+ }
+ function ret() returns(bool) {
+ bool tmp;
+ assembly {
+ tmp := 5
+ }
+ return tmp;
+ }
+ function ev() returns(uint) {
+ bool tmp;
+ assembly {
+ tmp := 5
+ }
+ Ev(tmp);
+ return 1;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ BOOST_CHECK(callContractFunction("set()") == encodeArgs(1));
+ BOOST_CHECK(callContractFunction("perm()") == encodeArgs(1));
+ BOOST_CHECK(callContractFunction("ret()") == encodeArgs(1));
+ BOOST_CHECK(callContractFunction("ev()") == encodeArgs(1));
+ BOOST_REQUIRE_EQUAL(m_logs.size(), 1);
+ BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
+ BOOST_CHECK(m_logs[0].data == encodeArgs(1));
+ BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
+ BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Ev(bool)")));
+}
+
+
BOOST_AUTO_TEST_CASE(using_contract_enums_with_explicit_contract_name)
{
char const* sourceCode = R"(