diff options
author | Marek Kotewicz <marek.kotewicz@gmail.com> | 2014-12-10 22:32:50 +0800 |
---|---|---|
committer | Marek Kotewicz <marek.kotewicz@gmail.com> | 2014-12-10 22:32:50 +0800 |
commit | 2ec5b1770b814a3409bdc5f5de400b3a8b49f2bb (patch) | |
tree | 761f3a729f85bc3c6c3f1a9829529ee1b1065823 | |
parent | 0e98fec2789f4e6326e26f082697aeb370fdca49 (diff) | |
parent | 93722eab8ac58bc3e33825f0dc71b60fcc4ddb95 (diff) | |
download | dexon-solidity-2ec5b1770b814a3409bdc5f5de400b3a8b49f2bb.tar.gz dexon-solidity-2ec5b1770b814a3409bdc5f5de400b3a8b49f2bb.tar.zst dexon-solidity-2ec5b1770b814a3409bdc5f5de400b3a8b49f2bb.zip |
Merge branch 'develop' into build_enhancement
-rw-r--r-- | solidityCompiler.cpp | 4 | ||||
-rw-r--r-- | solidityEndToEndTest.cpp | 35 |
2 files changed, 37 insertions, 2 deletions
diff --git a/solidityCompiler.cpp b/solidityCompiler.cpp index 9862cba8..004740b5 100644 --- a/solidityCompiler.cpp +++ b/solidityCompiler.cpp @@ -125,8 +125,8 @@ BOOST_AUTO_TEST_CASE(different_argument_numbers) byte(Instruction::JUMP), // end of f byte(Instruction::JUMPDEST), // beginning of g byte(Instruction::PUSH1), 0x0, - byte(Instruction::DUP1), // initialized e and h - byte(Instruction::PUSH1), byte(0x29 + shift), // ret address + byte(Instruction::PUSH1), 0x0, // initialized e and h + byte(Instruction::PUSH1), byte(0x2a + shift), // ret address byte(Instruction::PUSH1), 0x1, byte(Instruction::PUSH1), 0xff, byte(Instruction::AND), byte(Instruction::PUSH1), 0x2, byte(Instruction::PUSH1), 0xff, byte(Instruction::AND), byte(Instruction::PUSH1), 0x3, byte(Instruction::PUSH1), 0xff, byte(Instruction::AND), diff --git a/solidityEndToEndTest.cpp b/solidityEndToEndTest.cpp index 1ea9fe35..36d6af71 100644 --- a/solidityEndToEndTest.cpp +++ b/solidityEndToEndTest.cpp @@ -1026,6 +1026,41 @@ BOOST_AUTO_TEST_CASE(calls_to_this) BOOST_REQUIRE(callContractFunction(0, a, b) == toBigEndian(a * b + 10)); } +BOOST_AUTO_TEST_CASE(inter_contract_calls_with_local_vars) +{ + // note that a reference to another contract's function occupies two stack slots, + // so this tests correct stack slot allocation + char const* sourceCode = R"( + contract Helper { + function multiply(uint a, uint b) returns (uint c) { + return a * b; + } + } + contract Main { + Helper h; + function callHelper(uint a, uint b) returns (uint c) { + var fu = h.multiply; + var y = 9; + var ret = fu(a, b); + return ret + y; + } + function getHelper() returns (address haddress) { + return address(h); + } + function setHelper(address haddress) { + h = Helper(haddress); + } + })"; + compileAndRun(sourceCode, 0, "Helper"); + u160 const helperAddress = m_contractAddress; + compileAndRun(sourceCode, 0, "Main"); + BOOST_REQUIRE(callContractFunction(2, helperAddress) == bytes()); + BOOST_REQUIRE(callContractFunction(1, helperAddress) == toBigEndian(helperAddress)); + u256 a(3456789); + u256 b("0x282837623374623234aa74"); + BOOST_REQUIRE(callContractFunction(0, a, b) == toBigEndian(a * b + 9)); +} + BOOST_AUTO_TEST_SUITE_END() } |