Use STATICCALL for view and pure

This commit is contained in:
Leonardo Alt
2018-07-11 14:45:22 +02:00
parent 238dbe1b99
commit 38026d3114
4 changed files with 60 additions and 18 deletions
+37 -1
View File
@@ -12173,7 +12173,6 @@ BOOST_AUTO_TEST_CASE(abi_encode_call)
BOOST_AUTO_TEST_CASE(staticcall_for_view_and_pure)
{
char const* sourceCode = R"(
pragma experimental "v0.5.0";
contract C {
uint x;
function f() public returns (uint) {
@@ -12408,6 +12407,43 @@ BOOST_AUTO_TEST_CASE(senders_balance)
BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(27)));
}
BOOST_AUTO_TEST_CASE(write_storage_external)
{
char const* sourceCode = R"(
contract C {
uint public x;
function f(uint y) public payable {
x = y;
}
function g(uint y) external {
x = y;
}
function h() public {
this.g(12);
}
}
contract D {
C c = new C();
function f() public payable returns (uint) {
c.g(3);
return c.x();
}
function g() public returns (uint) {
c.g(8);
return c.x();
}
function h() public returns (uint) {
c.h();
return c.x();
}
}
)";
compileAndRun(sourceCode, 0, "D");
ABI_CHECK(callContractFunction("f()"), encodeArgs(3));
ABI_CHECK(callContractFunction("g()"), encodeArgs(8));
ABI_CHECK(callContractFunction("h()"), encodeArgs(12));
}
BOOST_AUTO_TEST_SUITE_END()
}