Remove blockhash workaround in tests

This is now obsolete as final constantinople doesn't contain the blockhash EIP.

Revert 3e55aa3fa2.
This commit is contained in:
Alex Beregszaszi 2019-02-28 21:17:56 +00:00
parent ab33ff1408
commit c3ab43dca7

View File

@ -3084,37 +3084,33 @@ BOOST_AUTO_TEST_CASE(gasprice)
BOOST_AUTO_TEST_CASE(blockhash) BOOST_AUTO_TEST_CASE(blockhash)
{ {
// depending on the aleth version, this test only works for pre-constantinople char const* sourceCode = R"(
if (Options::get().evmVersion() < langutil::EVMVersion::constantinople()) contract C {
{ uint256 counter;
char const* sourceCode = R"( function g() public returns (bool) { counter++; return true; }
contract C { function f() public returns (bytes32[] memory r) {
uint256 counter; r = new bytes32[](259);
function g() public returns (bool) { counter++; return true; } for (uint i = 0; i < 259; i++)
function f() public returns (bytes32[] memory r) { r[i] = blockhash(block.number - 257 + i);
r = new bytes32[](259);
for (uint i = 0; i < 259; i++)
r[i] = blockhash(block.number - 257 + i);
}
} }
)"; }
compileAndRun(sourceCode); )";
// generate a sufficient amount of blocks compileAndRun(sourceCode);
while (blockNumber() < u256(255)) // generate a sufficient amount of blocks
ABI_CHECK(callContractFunction("g()"), encodeArgs(true)); while (blockNumber() < u256(255))
ABI_CHECK(callContractFunction("g()"), encodeArgs(true));
vector<u256> hashes; vector<u256> hashes;
// ``blockhash()`` is only valid for the last 256 blocks, otherwise zero // ``blockhash()`` is only valid for the last 256 blocks, otherwise zero
hashes.emplace_back(0); hashes.emplace_back(0);
for (u256 i = blockNumber() - u256(255); i <= blockNumber(); i++) for (u256 i = blockNumber() - u256(255); i <= blockNumber(); i++)
hashes.emplace_back(blockHash(i)); hashes.emplace_back(blockHash(i));
// the current block hash is not yet known at execution time and therefore zero // the current block hash is not yet known at execution time and therefore zero
hashes.emplace_back(0); hashes.emplace_back(0);
// future block hashes are zero // future block hashes are zero
hashes.emplace_back(0); hashes.emplace_back(0);
ABI_CHECK(callContractFunction("f()"), encodeDyn(hashes)); ABI_CHECK(callContractFunction("f()"), encodeDyn(hashes));
}
} }
BOOST_AUTO_TEST_CASE(value_complex) BOOST_AUTO_TEST_CASE(value_complex)