aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--SolidityCompiler.cpp8
-rw-r--r--SolidityEndToEndTest.cpp45
-rw-r--r--SolidityExpressionCompiler.cpp88
-rw-r--r--SolidityOptimizer.cpp8
-rw-r--r--SolidityScanner.cpp12
-rw-r--r--TestHelper.cpp8
-rw-r--r--TestHelper.h1
-rw-r--r--state.cpp10
-rw-r--r--vm.cpp3
-rw-r--r--vmBlockInfoTestFiller.json56
10 files changed, 147 insertions, 92 deletions
diff --git a/SolidityCompiler.cpp b/SolidityCompiler.cpp
index 1a9685f0..b4874e19 100644
--- a/SolidityCompiler.cpp
+++ b/SolidityCompiler.cpp
@@ -134,10 +134,10 @@ BOOST_AUTO_TEST_CASE(different_argument_numbers)
byte(Instruction::JUMPDEST), // beginning of g
byte(Instruction::PUSH1), 0x0,
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),
+ byte(Instruction::PUSH1), byte(0x21 + shift), // ret address
+ byte(Instruction::PUSH1), 0x1,
+ byte(Instruction::PUSH1), 0x2,
+ byte(Instruction::PUSH1), 0x3,
byte(Instruction::PUSH1), byte(0x1 + shift),
// stack here: ret e h 0x20 1 2 3 0x1
byte(Instruction::JUMP),
diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp
index 1ddd26f7..bc184dfc 100644
--- a/SolidityEndToEndTest.cpp
+++ b/SolidityEndToEndTest.cpp
@@ -857,10 +857,8 @@ BOOST_AUTO_TEST_CASE(log0)
" log0(1);\n"
" }\n"
"}\n";
- u256 amount(130);
- compileAndRun(sourceCode, amount + 1);
- u160 address(23);
- callContractFunction("a()", address, amount);
+ compileAndRun(sourceCode);
+ callContractFunction("a()");
BOOST_CHECK_EQUAL(m_logs.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1)));
@@ -874,10 +872,8 @@ BOOST_AUTO_TEST_CASE(log1)
" log1(1, 2);\n"
" }\n"
"}\n";
- u256 amount(130);
- compileAndRun(sourceCode, amount + 1);
- u160 address(23);
- callContractFunction("a()", address, amount);
+ compileAndRun(sourceCode);
+ callContractFunction("a()");
BOOST_CHECK_EQUAL(m_logs.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1)));
@@ -892,10 +888,8 @@ BOOST_AUTO_TEST_CASE(log2)
" log2(1, 2, 3);\n"
" }\n"
"}\n";
- u256 amount(130);
- compileAndRun(sourceCode, amount + 1);
- u160 address(23);
- callContractFunction("a()", address, amount);
+ compileAndRun(sourceCode);
+ callContractFunction("a()");
BOOST_CHECK_EQUAL(m_logs.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1)));
@@ -911,10 +905,8 @@ BOOST_AUTO_TEST_CASE(log3)
" log3(1, 2, 3, 4);\n"
" }\n"
"}\n";
- u256 amount(130);
- compileAndRun(sourceCode, amount + 1);
- u160 address(23);
- callContractFunction("a()", address, amount);
+ compileAndRun(sourceCode);
+ callContractFunction("a()");
BOOST_CHECK_EQUAL(m_logs.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1)));
@@ -930,10 +922,8 @@ BOOST_AUTO_TEST_CASE(log4)
" log4(1, 2, 3, 4, 5);\n"
" }\n"
"}\n";
- u256 amount(130);
- compileAndRun(sourceCode, amount + 1);
- u160 address(23);
- callContractFunction("a()", address, amount);
+ compileAndRun(sourceCode);
+ callContractFunction("a()");
BOOST_CHECK_EQUAL(m_logs.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1)));
@@ -942,6 +932,21 @@ BOOST_AUTO_TEST_CASE(log4)
BOOST_CHECK_EQUAL(m_logs[0].topics[i], h256(u256(i + 2)));
}
+BOOST_AUTO_TEST_CASE(log_in_constructor)
+{
+ char const* sourceCode = "contract test {\n"
+ " function test() {\n"
+ " log1(1, 2);\n"
+ " }\n"
+ "}\n";
+ compileAndRun(sourceCode);
+ BOOST_CHECK_EQUAL(m_logs.size(), 1);
+ BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
+ BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1)));
+ BOOST_CHECK_EQUAL(m_logs[0].topics.size(), 1);
+ BOOST_CHECK_EQUAL(m_logs[0].topics[0], h256(u256(2)));
+}
+
BOOST_AUTO_TEST_CASE(suicide)
{
char const* sourceCode = "contract test {\n"
diff --git a/SolidityExpressionCompiler.cpp b/SolidityExpressionCompiler.cpp
index 9c375418..579af5bb 100644
--- a/SolidityExpressionCompiler.cpp
+++ b/SolidityExpressionCompiler.cpp
@@ -174,8 +174,8 @@ BOOST_AUTO_TEST_CASE(comparison)
bytes code = compileFirstExpression(sourceCode);
bytes expectation({byte(eth::Instruction::PUSH1), 0x1,
- byte(eth::Instruction::PUSH2), 0x11, 0xaa, byte(eth::Instruction::PUSH2), 0xff, 0xff, byte(eth::Instruction::AND),
- byte(eth::Instruction::PUSH2), 0x10, 0xaa, byte(eth::Instruction::PUSH2), 0xff, 0xff, byte(eth::Instruction::AND),
+ byte(eth::Instruction::PUSH2), 0x11, 0xaa,
+ byte(eth::Instruction::PUSH2), 0x10, 0xaa,
byte(eth::Instruction::LT),
byte(eth::Instruction::EQ),
byte(eth::Instruction::ISZERO)});
@@ -189,20 +189,18 @@ BOOST_AUTO_TEST_CASE(short_circuiting)
"}\n";
bytes code = compileFirstExpression(sourceCode);
- bytes expectation({byte(eth::Instruction::PUSH1), 0xa,
- byte(eth::Instruction::PUSH1), 0x8,
- byte(eth::Instruction::ADD), byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND),
- byte(eth::Instruction::PUSH1), 0x4, byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND),
+ bytes expectation({byte(eth::Instruction::PUSH1), 0x12, // 8 + 10
+ byte(eth::Instruction::PUSH1), 0x4,
byte(eth::Instruction::GT),
- byte(eth::Instruction::ISZERO), // after this we have 10 + 8 >= 4
+ byte(eth::Instruction::ISZERO), // after this we have 4 <= 8 + 10
byte(eth::Instruction::DUP1),
- byte(eth::Instruction::PUSH1), 0x20,
+ byte(eth::Instruction::PUSH1), 0x11,
byte(eth::Instruction::JUMPI), // short-circuit if it is true
byte(eth::Instruction::POP),
- byte(eth::Instruction::PUSH1), 0x2, byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND),
- byte(eth::Instruction::PUSH1), 0x9, byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND),
+ byte(eth::Instruction::PUSH1), 0x2,
+ byte(eth::Instruction::PUSH1), 0x9,
byte(eth::Instruction::EQ),
- byte(eth::Instruction::ISZERO), // after this we have 2 != 9
+ byte(eth::Instruction::ISZERO), // after this we have 9 != 2
byte(eth::Instruction::JUMPDEST),
byte(eth::Instruction::PUSH1), 0x1,
byte(eth::Instruction::EQ),
@@ -213,28 +211,24 @@ BOOST_AUTO_TEST_CASE(short_circuiting)
BOOST_AUTO_TEST_CASE(arithmetics)
{
char const* sourceCode = "contract test {\n"
- " function f() { var x = ((((((((9 ^ 8) & 7) | 6) - 5) + 4) % 3) / 2) * 1); }"
+ " function f(uint y) { var x = ((((((((y ^ 8) & 7) | 6) - 5) + 4) % 3) / 2) * 1); }"
"}\n";
- bytes code = compileFirstExpression(sourceCode);
+ bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}, {"test", "f", "x"}});
bytes expectation({byte(eth::Instruction::PUSH1), 0x1,
byte(eth::Instruction::PUSH1), 0x2,
- byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND),
byte(eth::Instruction::PUSH1), 0x3,
- byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND),
byte(eth::Instruction::PUSH1), 0x4,
byte(eth::Instruction::PUSH1), 0x5,
byte(eth::Instruction::PUSH1), 0x6,
byte(eth::Instruction::PUSH1), 0x7,
byte(eth::Instruction::PUSH1), 0x8,
- byte(eth::Instruction::PUSH1), 0x9,
+ byte(eth::Instruction::DUP10),
byte(eth::Instruction::XOR),
byte(eth::Instruction::AND),
byte(eth::Instruction::OR),
byte(eth::Instruction::SUB),
byte(eth::Instruction::ADD),
- byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND),
byte(eth::Instruction::MOD),
- byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND),
byte(eth::Instruction::DIV),
byte(eth::Instruction::MUL)});
BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end());
@@ -243,15 +237,15 @@ BOOST_AUTO_TEST_CASE(arithmetics)
BOOST_AUTO_TEST_CASE(unary_operators)
{
char const* sourceCode = "contract test {\n"
- " function f() { var x = !(~+- 1 == 2); }"
+ " function f(int y) { var x = !(~+- y == 2); }"
"}\n";
- bytes code = compileFirstExpression(sourceCode);
+ bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}, {"test", "f", "x"}});
- bytes expectation({byte(eth::Instruction::PUSH1), 0x2, byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND),
- byte(eth::Instruction::PUSH1), 0x1,
+ bytes expectation({byte(eth::Instruction::PUSH1), 0x2,
+ byte(eth::Instruction::DUP3),
byte(eth::Instruction::PUSH1), 0x0,
byte(eth::Instruction::SUB),
- byte(eth::Instruction::NOT), byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND),
+ byte(eth::Instruction::NOT),
byte(eth::Instruction::EQ),
byte(eth::Instruction::ISZERO)});
BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end());
@@ -315,7 +309,7 @@ BOOST_AUTO_TEST_CASE(assignment)
bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "a"}, {"test", "f", "b"}});
// Stack: a, b
- bytes expectation({byte(eth::Instruction::PUSH1), 0x2, byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND),
+ bytes expectation({byte(eth::Instruction::PUSH1), 0x2,
byte(eth::Instruction::DUP2),
byte(eth::Instruction::DUP4),
byte(eth::Instruction::ADD),
@@ -338,14 +332,14 @@ BOOST_AUTO_TEST_CASE(function_call)
{{"test", "f", "a"}, {"test", "f", "b"}});
// Stack: a, b
- bytes expectation({byte(eth::Instruction::PUSH1), 0x02, byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND),
- byte(eth::Instruction::PUSH1), 0x12,
- byte(eth::Instruction::PUSH1), 0x01, byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND),
+ bytes expectation({byte(eth::Instruction::PUSH1), 0x02,
+ byte(eth::Instruction::PUSH1), 0x0c,
+ byte(eth::Instruction::PUSH1), 0x01,
byte(eth::Instruction::DUP5),
byte(eth::Instruction::ADD),
// Stack here: a b 2 <ret label> (a+1)
byte(eth::Instruction::DUP4),
- byte(eth::Instruction::PUSH1), 0x19,
+ byte(eth::Instruction::PUSH1), 0x13,
byte(eth::Instruction::JUMP),
byte(eth::Instruction::JUMPDEST),
// Stack here: a b 2 g(a+1, b)
@@ -363,40 +357,36 @@ BOOST_AUTO_TEST_CASE(function_call)
BOOST_AUTO_TEST_CASE(negative_literals_8bits)
{
- // these all fit in 8 bits
char const* sourceCode = "contract test {\n"
- " function f() { int8 x = -0 + -1 + -0x01 + -127 + -128; }\n"
+ " function f() { int8 x = -0x80; }\n"
"}\n";
bytes code = compileFirstExpression(sourceCode);
- bytes expectation(bytes({byte(eth::Instruction::PUSH32)}) + bytes(31, 0xff) + bytes(1, 0x80) +
- bytes({byte(eth::Instruction::PUSH32)}) + bytes(31, 0xff) + bytes(1, 0x81) +
- bytes({byte(eth::Instruction::PUSH32)}) + bytes(32, 0xff) +
- bytes({byte(eth::Instruction::PUSH32)}) + bytes(32, 0xff) +
- bytes({byte(eth::Instruction::PUSH1), 0x00,
- byte(eth::Instruction::ADD),
- byte(eth::Instruction::ADD),
- byte(eth::Instruction::ADD),
- byte(eth::Instruction::ADD)}));
+ bytes expectation(bytes({byte(eth::Instruction::PUSH32)}) + bytes(31, 0xff) + bytes(1, 0x80));
BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end());
}
BOOST_AUTO_TEST_CASE(negative_literals_16bits)
{
- // -1 should need 8 bits, -129 should need 16 bits, how many bits are used is visible
- // from the SIGNEXTEND opcodes
char const* sourceCode = "contract test {\n"
- " function f() { int64 x = int64(-1 + -129); }\n"
+ " function f() { int64 x = ~0xabc; }\n"
+ "}\n";
+ bytes code = compileFirstExpression(sourceCode);
+
+ bytes expectation(bytes({byte(eth::Instruction::PUSH32)}) + bytes(30, 0xff) + bytes{0xf5, 0x43});
+ BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end());
+}
+
+BOOST_AUTO_TEST_CASE(intermediately_overflowing_literals)
+{
+ // first literal itself is too large for 256 bits but it fits after all constant operations
+ // have been applied
+ char const* sourceCode = "contract test {\n"
+ " function f() { var x = (0xffffffffffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffff01) & 0xbf; }\n"
"}\n";
bytes code = compileFirstExpression(sourceCode);
- bytes expectation(bytes({byte(eth::Instruction::PUSH32)}) + bytes(31, 0xff) + bytes(1, 0x7f) +
- bytes({byte(eth::Instruction::PUSH32)}) + bytes(32, 0xff) +
- bytes({byte(eth::Instruction::PUSH1), 0x00,
- byte(eth::Instruction::SIGNEXTEND),
- byte(eth::Instruction::ADD),
- byte(eth::Instruction::PUSH1), 0x01,
- byte(eth::Instruction::SIGNEXTEND)}));
+ bytes expectation(bytes({byte(eth::Instruction::PUSH1), 0xbf}));
BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end());
}
diff --git a/SolidityOptimizer.cpp b/SolidityOptimizer.cpp
index 97233250..41ec1f90 100644
--- a/SolidityOptimizer.cpp
+++ b/SolidityOptimizer.cpp
@@ -94,7 +94,7 @@ BOOST_AUTO_TEST_CASE(large_integers)
b = 0x10000000000000000000000002;
}
})";
- compileBothVersions(58, sourceCode);
+ compileBothVersions(36, sourceCode);
compareVersions("f()");
}
@@ -106,7 +106,7 @@ BOOST_AUTO_TEST_CASE(invariants)
return int(0) | (int(1) * (int(0) ^ (0 + a)));
}
})";
- compileBothVersions(53, sourceCode);
+ compileBothVersions(41, sourceCode);
compareVersions("f(uint256)", u256(0x12334664));
}
@@ -120,7 +120,7 @@ BOOST_AUTO_TEST_CASE(unused_expressions)
data;
}
})";
- compileBothVersions(36, sourceCode);
+ compileBothVersions(33, sourceCode);
compareVersions("f()");
}
@@ -135,7 +135,7 @@ BOOST_AUTO_TEST_CASE(constant_folding_both_sides)
return 98 ^ (7 * ((1 | (x | 1000)) * 40) ^ 102);
}
})";
- compileBothVersions(56, sourceCode);
+ compileBothVersions(37, sourceCode);
compareVersions("f(uint256)");
}
diff --git a/SolidityScanner.cpp b/SolidityScanner.cpp
index b7942d29..7dc9ef48 100644
--- a/SolidityScanner.cpp
+++ b/SolidityScanner.cpp
@@ -103,14 +103,17 @@ BOOST_AUTO_TEST_CASE(negative_numbers)
BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::VAR);
BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER);
BOOST_CHECK_EQUAL(scanner.next(), Token::ASSIGN);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::SUB);
BOOST_CHECK_EQUAL(scanner.next(), Token::NUMBER);
- BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), "-.2");
+ BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), ".2");
BOOST_CHECK_EQUAL(scanner.next(), Token::ADD);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::SUB);
BOOST_CHECK_EQUAL(scanner.next(), Token::NUMBER);
- BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), "-0x78");
+ BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), "0x78");
BOOST_CHECK_EQUAL(scanner.next(), Token::ADD);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::SUB);
BOOST_CHECK_EQUAL(scanner.next(), Token::NUMBER);
- BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), "-7.3");
+ BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), "7.3");
BOOST_CHECK_EQUAL(scanner.next(), Token::ADD);
BOOST_CHECK_EQUAL(scanner.next(), Token::NUMBER);
BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), "8.9");
@@ -130,8 +133,9 @@ BOOST_AUTO_TEST_CASE(locations)
BOOST_CHECK_EQUAL(scanner.next(), Token::SEMICOLON);
BOOST_CHECK_EQUAL(scanner.getCurrentLocation().start, 24);
BOOST_CHECK_EQUAL(scanner.getCurrentLocation().end, 25);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::SUB);
BOOST_CHECK_EQUAL(scanner.next(), Token::NUMBER);
- BOOST_CHECK_EQUAL(scanner.getCurrentLocation().start, 26);
+ BOOST_CHECK_EQUAL(scanner.getCurrentLocation().start, 27);
BOOST_CHECK_EQUAL(scanner.getCurrentLocation().end, 32);
BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER);
BOOST_CHECK_EQUAL(scanner.getCurrentLocation().start, 45);
diff --git a/TestHelper.cpp b/TestHelper.cpp
index ea848c7c..ff330d60 100644
--- a/TestHelper.cpp
+++ b/TestHelper.cpp
@@ -489,4 +489,12 @@ void processCommandLineOptions()
}
}
+LastHashes lastHashes(u256 _currentBlockNumber)
+{
+ LastHashes ret;
+ for (u256 i = 1; i <= 256 && i <= _currentBlockNumber; ++i)
+ ret.push_back(sha3(toString(_currentBlockNumber - i)));
+ return ret;
+}
+
} } // namespaces
diff --git a/TestHelper.h b/TestHelper.h
index 20328c91..85017c84 100644
--- a/TestHelper.h
+++ b/TestHelper.h
@@ -77,6 +77,7 @@ void executeTests(const std::string& _name, const std::string& _testPathAppendix
std::string getTestPath();
void userDefinedTest(std::string testTypeFlag, std::function<void(json_spirit::mValue&, bool)> doTests);
void processCommandLineOptions();
+eth::LastHashes lastHashes(u256 _currentBlockNumber);
template<typename mapType>
void checkAddresses(mapType& _expectedAddrs, mapType& _resultAddrs)
diff --git a/state.cpp b/state.cpp
index db8350e4..6da18e70 100644
--- a/state.cpp
+++ b/state.cpp
@@ -39,16 +39,6 @@ using namespace dev::eth;
namespace dev { namespace test {
-LastHashes lastHashes(u256 _currentBlockNumber)
-{
- LastHashes ret;
- for (u256 i = 1; i <= 256 && i <= _currentBlockNumber; ++i)
- ret.push_back(sha3(toString(_currentBlockNumber - i)));
- return ret;
-}
-
-
-
void doStateTests(json_spirit::mValue& v, bool _fillin)
{
processCommandLineOptions();
diff --git a/vm.cpp b/vm.cpp
index 18bf5797..6ae95f25 100644
--- a/vm.cpp
+++ b/vm.cpp
@@ -33,7 +33,7 @@ using namespace dev::eth;
using namespace dev::test;
FakeExtVM::FakeExtVM(eth::BlockInfo const& _previousBlock, eth::BlockInfo const& _currentBlock, unsigned _depth): /// TODO: XXX: remove the default argument & fix.
- ExtVMFace(Address(), Address(), Address(), 0, 1, bytesConstRef(), bytes(), _previousBlock, _currentBlock, LastHashes(), _depth) {}
+ ExtVMFace(Address(), Address(), Address(), 0, 1, bytesConstRef(), bytes(), _previousBlock, _currentBlock, test::lastHashes(_currentBlock.number), _depth) {}
h160 FakeExtVM::create(u256 _endowment, u256& io_gas, bytesConstRef _init, OnOpFunc const&)
{
@@ -117,6 +117,7 @@ void FakeExtVM::importEnv(mObject& _o)
previousBlock.hash = h256(_o["previousHash"].get_str());
currentBlock.number = toInt(_o["currentNumber"]);
+ lastHashes = test::lastHashes(currentBlock.number);
currentBlock.gasLimit = toInt(_o["currentGasLimit"]);
currentBlock.difficulty = toInt(_o["currentDifficulty"]);
currentBlock.timestamp = toInt(_o["currentTimestamp"]);
diff --git a/vmBlockInfoTestFiller.json b/vmBlockInfoTestFiller.json
index 15c27017..89862947 100644
--- a/vmBlockInfoTestFiller.json
+++ b/vmBlockInfoTestFiller.json
@@ -111,6 +111,62 @@
}
},
+ "blockhashInRange": {
+ "env" : {
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
+ "currentNumber" : "257",
+ "currentGasLimit" : "1000000",
+ "currentDifficulty" : "256",
+ "currentTimestamp" : 1,
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "nonce" : 0,
+ "code" : "{ [[ 0 ]] (BLOCKHASH 1) [[ 1 ]] (BLOCKHASH 2) [[ 2 ]] (BLOCKHASH 256) }",
+ "storage": {}
+ }
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000",
+ "data" : "",
+ "gasPrice" : "100000000000000",
+ "gas" : "10000"
+ }
+ },
+
+ "blockhashOutOfRange": {
+ "env" : {
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
+ "currentNumber" : "257",
+ "currentGasLimit" : "1000000",
+ "currentDifficulty" : "256",
+ "currentTimestamp" : 1,
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "nonce" : 0,
+ "code" : "{ [[ 0 ]] (BLOCKHASH 0) [[ 1 ]] (BLOCKHASH 257) [[ 2 ]] (BLOCKHASH 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }",
+ "storage": {}
+ }
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000",
+ "data" : "",
+ "gasPrice" : "100000000000000",
+ "gas" : "10000"
+ }
+ },
+
"coinbase": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",