aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Kotewicz <marek.kotewicz@gmail.com>2015-02-19 15:21:02 +0800
committerMarek Kotewicz <marek.kotewicz@gmail.com>2015-02-19 15:21:02 +0800
commitd9e38eb3a8a63e5e429f623ae350e109a9e73c25 (patch)
tree57b3e024941fae39e5192462b2518c1bf0bebe36
parent7c38963394f63583048afcf0be11af54d636ae1f (diff)
parent98739c362a9ca0d1410518d667956a406d63afa8 (diff)
downloaddexon-solidity-d9e38eb3a8a63e5e429f623ae350e109a9e73c25.tar.gz
dexon-solidity-d9e38eb3a8a63e5e429f623ae350e109a9e73c25.tar.zst
dexon-solidity-d9e38eb3a8a63e5e429f623ae350e109a9e73c25.zip
Merge branch 'develop' into jsonrpc
-rw-r--r--SolidityEndToEndTest.cpp36
-rw-r--r--SolidityNameAndTypeResolution.cpp12
-rw-r--r--SolidityParser.cpp6
3 files changed, 45 insertions, 9 deletions
diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp
index 103b1126..8c87db2d 100644
--- a/SolidityEndToEndTest.cpp
+++ b/SolidityEndToEndTest.cpp
@@ -2479,6 +2479,42 @@ BOOST_AUTO_TEST_CASE(struct_copy)
BOOST_CHECK(callContractFunction("retrieve(uint256)", 8) == encodeArgs(0, 0, 0, 0));
}
+BOOST_AUTO_TEST_CASE(struct_containing_bytes_copy_and_delete)
+{
+ char const* sourceCode = R"(
+ contract c {
+ struct Struct { uint a; bytes data; uint b; }
+ Struct data1;
+ Struct data2;
+ function set(uint _a, bytes _data, uint _b) external returns (bool) {
+ data1.a = _a;
+ data1.b = _b;
+ data1.data = _data;
+ return true;
+ }
+ function copy() returns (bool) {
+ data1 = data2;
+ return true;
+ }
+ function del() returns (bool) {
+ delete data1;
+ return true;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ string data = "123456789012345678901234567890123";
+ BOOST_CHECK(m_state.storage(m_contractAddress).empty());
+ BOOST_CHECK(callContractFunction("set(uint256,bytes,uint256)", u256(data.length()), 12, data, 13) == encodeArgs(true));
+ BOOST_CHECK(!m_state.storage(m_contractAddress).empty());
+ BOOST_CHECK(callContractFunction("copy()") == encodeArgs(true));
+ BOOST_CHECK(m_state.storage(m_contractAddress).empty());
+ BOOST_CHECK(callContractFunction("set(uint256,bytes,uint256)", u256(data.length()), 12, data, 13) == encodeArgs(true));
+ BOOST_CHECK(!m_state.storage(m_contractAddress).empty());
+ BOOST_CHECK(callContractFunction("del()") == encodeArgs(true));
+ BOOST_CHECK(m_state.storage(m_contractAddress).empty());
+}
+
BOOST_AUTO_TEST_CASE(struct_copy_via_local)
{
char const* sourceCode = R"(
diff --git a/SolidityNameAndTypeResolution.cpp b/SolidityNameAndTypeResolution.cpp
index 6b337ac7..bfef873c 100644
--- a/SolidityNameAndTypeResolution.cpp
+++ b/SolidityNameAndTypeResolution.cpp
@@ -470,7 +470,7 @@ BOOST_AUTO_TEST_CASE(illegal_override_indirect)
BOOST_AUTO_TEST_CASE(illegal_override_visibility)
{
char const* text = R"(
- contract B { function f() protected {} }
+ contract B { function f() inheritable {} }
contract C is B { function f() public {} }
)";
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
@@ -706,7 +706,7 @@ BOOST_AUTO_TEST_CASE(private_state_variable)
" uint64(2);\n"
" }\n"
"uint256 private foo;\n"
- "uint256 protected bar;\n"
+ "uint256 inheritable bar;\n"
"}\n";
ASTPointer<SourceUnit> source;
@@ -717,7 +717,7 @@ BOOST_AUTO_TEST_CASE(private_state_variable)
function = retrieveFunctionBySignature(contract, "foo()");
BOOST_CHECK_MESSAGE(function == nullptr, "Accessor function of a private variable should not exist");
function = retrieveFunctionBySignature(contract, "bar()");
- BOOST_CHECK_MESSAGE(function == nullptr, "Accessor function of a protected variable should not exist");
+ BOOST_CHECK_MESSAGE(function == nullptr, "Accessor function of an inheritable variable should not exist");
}
BOOST_AUTO_TEST_CASE(fallback_function)
@@ -832,11 +832,11 @@ BOOST_AUTO_TEST_CASE(access_to_default_function_visibility)
BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
}
-BOOST_AUTO_TEST_CASE(access_to_protected_function)
+BOOST_AUTO_TEST_CASE(access_to_inheritable_function)
{
char const* text = R"(
contract c {
- function f() protected {}
+ function f() inheritable {}
}
contract d {
function g() { c(0).f(); }
@@ -856,7 +856,7 @@ BOOST_AUTO_TEST_CASE(access_to_default_state_variable_visibility)
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
}
-BOOST_AUTO_TEST_CASE(access_to_protected_state_variable)
+BOOST_AUTO_TEST_CASE(access_to_inheritable_state_variable)
{
char const* text = R"(
contract c {
diff --git a/SolidityParser.cpp b/SolidityParser.cpp
index 5f9064e0..ddb58244 100644
--- a/SolidityParser.cpp
+++ b/SolidityParser.cpp
@@ -651,13 +651,13 @@ BOOST_AUTO_TEST_CASE(visibility_specifiers)
char const* text = R"(
contract c {
uint private a;
- uint protected b;
+ uint inheritable b;
uint public c;
uint d;
function f() {}
function f_priv() private {}
function f_public() public {}
- function f_protected() protected {}
+ function f_inheritable() inheritable {}
})";
BOOST_CHECK_NO_THROW(parseText(text));
}
@@ -666,7 +666,7 @@ BOOST_AUTO_TEST_CASE(multiple_visibility_specifiers)
{
char const* text = R"(
contract c {
- uint private protected a;
+ uint private inheritable a;
})";
BOOST_CHECK_THROW(parseText(text), ParserError);
}