No write access to parameters of external functions.

This commit is contained in:
Christian 2015-02-14 01:22:44 +01:00
parent 7dd200d140
commit 8290b6305b
2 changed files with 45 additions and 0 deletions

View File

@ -2534,6 +2534,21 @@ BOOST_AUTO_TEST_CASE(constructing_enums_from_ints)
BOOST_CHECK(callContractFunction("test()") == encodeArgs(1));
}
BOOST_AUTO_TEST_CASE(external_function)
{
char const* sourceCode = R"(
contract c {
function f(uint a) returns (uint) { return a; }
function test(uint a, uint b) external returns (uint r_a, uint r_b) {
r_a = f(a + 7);
r_b = b;
}
}
)";
compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction("test(uint256,uint256)", 2, 3) == encodeArgs(2, 3+7));
}
BOOST_AUTO_TEST_SUITE_END()
}

View File

@ -1133,6 +1133,36 @@ BOOST_AUTO_TEST_CASE(external_base_visibility)
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError);
}
BOOST_AUTO_TEST_CASE(external_argument_assign)
{
char const* sourceCode = R"(
contract c {
function f(uint a) external { a = 1; }
}
)";
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError);
}
BOOST_AUTO_TEST_CASE(external_argument_increment)
{
char const* sourceCode = R"(
contract c {
function f(uint a) external { a++; }
}
)";
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError);
}
BOOST_AUTO_TEST_CASE(external_argument_delete)
{
char const* sourceCode = R"(
contract c {
function f(uint a) external { delete a; }
}
)";
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError);
}
BOOST_AUTO_TEST_SUITE_END()
}