diff options
author | chriseth <chris@ethereum.org> | 2018-03-14 00:28:58 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-03-14 00:34:21 +0800 |
commit | 834d63de2c4dc9c119862f8bf25b4f7c9f408d6e (patch) | |
tree | a75716c1431f68e71a9005250b446fedacf779f2 /test/libsolidity/SolidityEndToEndTest.cpp | |
parent | 7a066efd7e0f371cfaee69c1f6b5f0aed1bfd107 (diff) | |
download | dexon-solidity-834d63de2c4dc9c119862f8bf25b4f7c9f408d6e.tar.gz dexon-solidity-834d63de2c4dc9c119862f8bf25b4f7c9f408d6e.tar.zst dexon-solidity-834d63de2c4dc9c119862f8bf25b4f7c9f408d6e.zip |
Allow ``block.blockhash`` without being called.
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 33cd1419..c0ff586d 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -1788,6 +1788,23 @@ BOOST_AUTO_TEST_CASE(transfer_ether) ABI_CHECK(callContractFunction("b(address,uint256)", oogRecipient, 10), encodeArgs()); } +BOOST_AUTO_TEST_CASE(uncalled_blockhash) +{ + char const* code = R"( + contract C { + function f() public view returns (bytes32) + { + var x = block.blockhash; + return x(block.number - 1); + } + } + )"; + compileAndRun(code, 0, "C"); + bytes result = callContractFunction("f()"); + BOOST_REQUIRE_EQUAL(result.size(), 32); + BOOST_CHECK(result[0] != 0 || result[1] != 0 || result[2] != 0); +} + BOOST_AUTO_TEST_CASE(log0) { char const* sourceCode = R"( |