mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge branch 'develop' into build_enhancement
This commit is contained in:
commit
05137b2884
@ -72,7 +72,7 @@ ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller): m_TestObject(_o
|
|||||||
if (!isFiller)
|
if (!isFiller)
|
||||||
{
|
{
|
||||||
importState(_o["post"].get_obj(), m_statePost);
|
importState(_o["post"].get_obj(), m_statePost);
|
||||||
m_environment.sub.logs = importLog(_o["logs"].get_obj());
|
m_environment.sub.logs = importLog(_o["logs"].get_array());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,16 +259,17 @@ bytes importCode(json_spirit::mObject& _o)
|
|||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogEntries importLog(json_spirit::mObject& _o)
|
LogEntries importLog(json_spirit::mArray& _a)
|
||||||
{
|
{
|
||||||
LogEntries logEntries;
|
LogEntries logEntries;
|
||||||
for (auto const& l: _o)
|
for (auto const& l: _a)
|
||||||
{
|
{
|
||||||
json_spirit::mObject o = l.second.get_obj();
|
json_spirit::mObject o = l.get_obj();
|
||||||
// cant use BOOST_REQUIRE, because this function is used outside boost test (createRandomTest)
|
// cant use BOOST_REQUIRE, because this function is used outside boost test (createRandomTest)
|
||||||
assert(o.count("address") > 0);
|
assert(o.count("address") > 0);
|
||||||
assert(o.count("topics") > 0);
|
assert(o.count("topics") > 0);
|
||||||
assert(o.count("data") > 0);
|
assert(o.count("data") > 0);
|
||||||
|
assert(o.count("bloom") > 0);
|
||||||
LogEntry log;
|
LogEntry log;
|
||||||
log.address = Address(o["address"].get_str());
|
log.address = Address(o["address"].get_str());
|
||||||
for (auto const& t: o["topics"].get_array())
|
for (auto const& t: o["topics"].get_array())
|
||||||
@ -279,9 +280,9 @@ LogEntries importLog(json_spirit::mObject& _o)
|
|||||||
return logEntries;
|
return logEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
json_spirit::mObject exportLog(eth::LogEntries _logs)
|
json_spirit::mArray exportLog(eth::LogEntries _logs)
|
||||||
{
|
{
|
||||||
json_spirit::mObject ret;
|
json_spirit::mArray ret;
|
||||||
if (_logs.size() == 0) return ret;
|
if (_logs.size() == 0) return ret;
|
||||||
for (LogEntry const& l: _logs)
|
for (LogEntry const& l: _logs)
|
||||||
{
|
{
|
||||||
@ -292,7 +293,8 @@ json_spirit::mObject exportLog(eth::LogEntries _logs)
|
|||||||
topics.push_back(toString(t));
|
topics.push_back(toString(t));
|
||||||
o["topics"] = topics;
|
o["topics"] = topics;
|
||||||
o["data"] = "0x" + toHex(l.data);
|
o["data"] = "0x" + toHex(l.data);
|
||||||
ret[toString(l.bloom())] = o;
|
o["bloom"] = toString(l.bloom());
|
||||||
|
ret.push_back(o);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -68,8 +68,8 @@ u256 toInt(json_spirit::mValue const& _v);
|
|||||||
byte toByte(json_spirit::mValue const& _v);
|
byte toByte(json_spirit::mValue const& _v);
|
||||||
bytes importCode(json_spirit::mObject& _o);
|
bytes importCode(json_spirit::mObject& _o);
|
||||||
bytes importData(json_spirit::mObject& _o);
|
bytes importData(json_spirit::mObject& _o);
|
||||||
eth::LogEntries importLog(json_spirit::mObject& _o);
|
eth::LogEntries importLog(json_spirit::mArray& _o);
|
||||||
json_spirit::mObject exportLog(eth::LogEntries _logs);
|
json_spirit::mArray exportLog(eth::LogEntries _logs);
|
||||||
void checkOutput(bytes const& _output, json_spirit::mObject& _o);
|
void checkOutput(bytes const& _output, json_spirit::mObject& _o);
|
||||||
void checkStorage(std::map<u256, u256> _expectedStore, std::map<u256, u256> _resultStore, Address _expectedAddr);
|
void checkStorage(std::map<u256, u256> _expectedStore, std::map<u256, u256> _resultStore, Address _expectedAddr);
|
||||||
void checkLog(eth::LogEntries _resultLogs, eth::LogEntries _expectedLogs);
|
void checkLog(eth::LogEntries _resultLogs, eth::LogEntries _expectedLogs);
|
||||||
|
@ -189,7 +189,7 @@ void doMyTests(json_spirit::mValue& v)
|
|||||||
o["callcreates"] = fev.exportCallCreates();
|
o["callcreates"] = fev.exportCallCreates();
|
||||||
o["out"] = "0x" + toHex(output);
|
o["out"] = "0x" + toHex(output);
|
||||||
fev.push(o, "gas", gas);
|
fev.push(o, "gas", gas);
|
||||||
o["logs"] = mValue(test::exportLog(fev.sub.logs));
|
o["logs"] = test::exportLog(fev.sub.logs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,9 +46,13 @@ namespace
|
|||||||
bytes compileContract(const string& _sourceCode)
|
bytes compileContract(const string& _sourceCode)
|
||||||
{
|
{
|
||||||
Parser parser;
|
Parser parser;
|
||||||
ASTPointer<ContractDefinition> contract;
|
ASTPointer<SourceUnit> sourceUnit;
|
||||||
BOOST_REQUIRE_NO_THROW(contract = parser.parse(make_shared<Scanner>(CharStream(_sourceCode))));
|
BOOST_REQUIRE_NO_THROW(sourceUnit = parser.parse(make_shared<Scanner>(CharStream(_sourceCode))));
|
||||||
NameAndTypeResolver resolver({});
|
NameAndTypeResolver resolver({});
|
||||||
|
resolver.registerDeclarations(*sourceUnit);
|
||||||
|
for (ASTPointer<ASTNode> const& node: sourceUnit->getNodes())
|
||||||
|
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
|
||||||
|
{
|
||||||
BOOST_REQUIRE_NO_THROW(resolver.resolveNamesAndTypes(*contract));
|
BOOST_REQUIRE_NO_THROW(resolver.resolveNamesAndTypes(*contract));
|
||||||
|
|
||||||
Compiler compiler;
|
Compiler compiler;
|
||||||
@ -57,6 +61,9 @@ bytes compileContract(const string& _sourceCode)
|
|||||||
//compiler.streamAssembly(cout);
|
//compiler.streamAssembly(cout);
|
||||||
return compiler.getAssembledBytecode();
|
return compiler.getAssembledBytecode();
|
||||||
}
|
}
|
||||||
|
BOOST_FAIL("No contract found in source.");
|
||||||
|
return bytes();
|
||||||
|
}
|
||||||
|
|
||||||
/// Checks that @a _compiledCode is present starting from offset @a _offset in @a _expectation.
|
/// Checks that @a _compiledCode is present starting from offset @a _offset in @a _expectation.
|
||||||
/// This is necessary since the compiler will add boilerplate add the beginning that is not
|
/// This is necessary since the compiler will add boilerplate add the beginning that is not
|
||||||
|
@ -86,9 +86,13 @@ bytes compileFirstExpression(const string& _sourceCode, vector<vector<string>> _
|
|||||||
vector<vector<string>> _localVariables = {})
|
vector<vector<string>> _localVariables = {})
|
||||||
{
|
{
|
||||||
Parser parser;
|
Parser parser;
|
||||||
ASTPointer<ContractDefinition> contract;
|
ASTPointer<SourceUnit> sourceUnit;
|
||||||
BOOST_REQUIRE_NO_THROW(contract = parser.parse(make_shared<Scanner>(CharStream(_sourceCode))));
|
BOOST_REQUIRE_NO_THROW(sourceUnit = parser.parse(make_shared<Scanner>(CharStream(_sourceCode))));
|
||||||
NameAndTypeResolver resolver({});
|
NameAndTypeResolver resolver({});
|
||||||
|
resolver.registerDeclarations(*sourceUnit);
|
||||||
|
for (ASTPointer<ASTNode> const& node: sourceUnit->getNodes())
|
||||||
|
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
|
||||||
|
{
|
||||||
BOOST_REQUIRE_NO_THROW(resolver.resolveNamesAndTypes(*contract));
|
BOOST_REQUIRE_NO_THROW(resolver.resolveNamesAndTypes(*contract));
|
||||||
FirstExpressionExtractor extractor(*contract);
|
FirstExpressionExtractor extractor(*contract);
|
||||||
BOOST_REQUIRE(extractor.getExpression() != nullptr);
|
BOOST_REQUIRE(extractor.getExpression() != nullptr);
|
||||||
@ -108,6 +112,9 @@ bytes compileFirstExpression(const string& _sourceCode, vector<vector<string>> _
|
|||||||
// cout << eth::disassemble(instructions) << endl;
|
// cout << eth::disassemble(instructions) << endl;
|
||||||
return instructions;
|
return instructions;
|
||||||
}
|
}
|
||||||
|
BOOST_FAIL("No contract found in source.");
|
||||||
|
return bytes();
|
||||||
|
}
|
||||||
|
|
||||||
} // end anonymous namespace
|
} // end anonymous namespace
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public:
|
|||||||
msg += *extra;
|
msg += *extra;
|
||||||
BOOST_FAIL(msg);
|
BOOST_FAIL(msg);
|
||||||
}
|
}
|
||||||
std::string generatedInterfaceString = m_compilerStack.getJsonDocumentation(DocumentationType::ABI_INTERFACE);
|
std::string generatedInterfaceString = m_compilerStack.getJsonDocumentation("", DocumentationType::ABI_INTERFACE);
|
||||||
Json::Value generatedInterface;
|
Json::Value generatedInterface;
|
||||||
m_reader.parse(generatedInterfaceString, generatedInterface);
|
m_reader.parse(generatedInterfaceString, generatedInterface);
|
||||||
Json::Value expectedInterface;
|
Json::Value expectedInterface;
|
||||||
|
@ -41,9 +41,11 @@ namespace
|
|||||||
void parseTextAndResolveNames(std::string const& _source)
|
void parseTextAndResolveNames(std::string const& _source)
|
||||||
{
|
{
|
||||||
Parser parser;
|
Parser parser;
|
||||||
ASTPointer<ContractDefinition> contract = parser.parse(
|
ASTPointer<SourceUnit> sourceUnit = parser.parse(std::make_shared<Scanner>(CharStream(_source)));
|
||||||
std::make_shared<Scanner>(CharStream(_source)));
|
|
||||||
NameAndTypeResolver resolver({});
|
NameAndTypeResolver resolver({});
|
||||||
|
resolver.registerDeclarations(*sourceUnit);
|
||||||
|
for (ASTPointer<ASTNode> const& node: sourceUnit->getNodes())
|
||||||
|
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
|
||||||
resolver.resolveNamesAndTypes(*contract);
|
resolver.resolveNamesAndTypes(*contract);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,9 +55,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_userDocumentation)
|
if (_userDocumentation)
|
||||||
generatedDocumentationString = m_compilerStack.getJsonDocumentation(DocumentationType::NATSPEC_USER);
|
generatedDocumentationString = m_compilerStack.getJsonDocumentation("", DocumentationType::NATSPEC_USER);
|
||||||
else
|
else
|
||||||
generatedDocumentationString = m_compilerStack.getJsonDocumentation(DocumentationType::NATSPEC_DEV);
|
generatedDocumentationString = m_compilerStack.getJsonDocumentation("", DocumentationType::NATSPEC_DEV);
|
||||||
Json::Value generatedDocumentation;
|
Json::Value generatedDocumentation;
|
||||||
m_reader.parse(generatedDocumentationString, generatedDocumentation);
|
m_reader.parse(generatedDocumentationString, generatedDocumentation);
|
||||||
Json::Value expectedDocumentation;
|
Json::Value expectedDocumentation;
|
||||||
|
@ -21,13 +21,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
#include <libdevcore/Log.h>
|
#include <libdevcore/Log.h>
|
||||||
#include <libsolidity/Scanner.h>
|
#include <libsolidity/Scanner.h>
|
||||||
#include <libsolidity/Parser.h>
|
#include <libsolidity/Parser.h>
|
||||||
#include <libsolidity/Exceptions.h>
|
#include <libsolidity/Exceptions.h>
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
namespace dev
|
namespace dev
|
||||||
{
|
{
|
||||||
namespace solidity
|
namespace solidity
|
||||||
@ -40,7 +42,12 @@ namespace
|
|||||||
ASTPointer<ContractDefinition> parseText(std::string const& _source)
|
ASTPointer<ContractDefinition> parseText(std::string const& _source)
|
||||||
{
|
{
|
||||||
Parser parser;
|
Parser parser;
|
||||||
return parser.parse(std::make_shared<Scanner>(CharStream(_source)));
|
ASTPointer<SourceUnit> sourceUnit = parser.parse(std::make_shared<Scanner>(CharStream(_source)));
|
||||||
|
for (ASTPointer<ASTNode> const& node: sourceUnit->getNodes())
|
||||||
|
if (ASTPointer<ContractDefinition> contract = dynamic_pointer_cast<ContractDefinition>(node))
|
||||||
|
return contract;
|
||||||
|
BOOST_FAIL("No contract found in source.");
|
||||||
|
return ASTPointer<ContractDefinition>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,6 +387,50 @@ BOOST_AUTO_TEST_CASE(statement_starting_with_type_conversion)
|
|||||||
BOOST_CHECK_NO_THROW(parseText(text));
|
BOOST_CHECK_NO_THROW(parseText(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(import_directive)
|
||||||
|
{
|
||||||
|
char const* text = "import \"abc\";\n"
|
||||||
|
"contract test {\n"
|
||||||
|
" function fun() {\n"
|
||||||
|
" uint64(2);\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n";
|
||||||
|
BOOST_CHECK_NO_THROW(parseText(text));
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(multiple_contracts)
|
||||||
|
{
|
||||||
|
char const* text = "contract test {\n"
|
||||||
|
" function fun() {\n"
|
||||||
|
" uint64(2);\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
"contract test2 {\n"
|
||||||
|
" function fun() {\n"
|
||||||
|
" uint64(2);\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n";
|
||||||
|
BOOST_CHECK_NO_THROW(parseText(text));
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(multiple_contracts_and_imports)
|
||||||
|
{
|
||||||
|
char const* text = "import \"abc\";\n"
|
||||||
|
"contract test {\n"
|
||||||
|
" function fun() {\n"
|
||||||
|
" uint64(2);\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
"import \"def\";\n"
|
||||||
|
"contract test2 {\n"
|
||||||
|
" function fun() {\n"
|
||||||
|
" uint64(2);\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
"import \"ghi\";\n";
|
||||||
|
BOOST_CHECK_NO_THROW(parseText(text));
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
1851
stLogTestsFiller.json
Normal file
1851
stLogTestsFiller.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -634,6 +634,86 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"CallRecursiveBombLog": {
|
||||||
|
"env" : {
|
||||||
|
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
|
||||||
|
"currentNumber" : "0",
|
||||||
|
"currentGasLimit" : "10000000",
|
||||||
|
"currentDifficulty" : "256",
|
||||||
|
"currentTimestamp" : 1,
|
||||||
|
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
|
||||||
|
},
|
||||||
|
"pre" : {
|
||||||
|
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
|
||||||
|
"balance" : "20000000",
|
||||||
|
"nonce" : 0,
|
||||||
|
"code" : "{ (CALL 100000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 0 0 0) }",
|
||||||
|
"storage": {}
|
||||||
|
},
|
||||||
|
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
|
||||||
|
"balance" : "1000000000000000000",
|
||||||
|
"nonce" : 0,
|
||||||
|
"code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (LOG0 0 32) [[ 0 ]] (+ (SLOAD 0) 1) [[ 1 ]] (CALL (- (GAS) 224) (ADDRESS) 0 0 0 0 0) } ",
|
||||||
|
"storage": {}
|
||||||
|
},
|
||||||
|
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
|
||||||
|
"balance" : "1000000000000000000",
|
||||||
|
"nonce" : 0,
|
||||||
|
"code" : "",
|
||||||
|
"storage": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"transaction" : {
|
||||||
|
"nonce" : "0",
|
||||||
|
"gasPrice" : "1",
|
||||||
|
"gasLimit" : "1000000",
|
||||||
|
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
|
||||||
|
"value" : "100000",
|
||||||
|
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
|
||||||
|
"data" : ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"CallRecursiveBombLog2": {
|
||||||
|
"env" : {
|
||||||
|
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
|
||||||
|
"currentNumber" : "0",
|
||||||
|
"currentGasLimit" : "10000000",
|
||||||
|
"currentDifficulty" : "256",
|
||||||
|
"currentTimestamp" : 1,
|
||||||
|
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
|
||||||
|
},
|
||||||
|
"pre" : {
|
||||||
|
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
|
||||||
|
"balance" : "20000000",
|
||||||
|
"nonce" : 0,
|
||||||
|
"code" : "{ (CALL 100000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 0 0 0) }",
|
||||||
|
"storage": {}
|
||||||
|
},
|
||||||
|
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
|
||||||
|
"balance" : "1000000000000000000",
|
||||||
|
"nonce" : 0,
|
||||||
|
"code" : "{ (MSTORE 0 (GAS)) (LOG0 0 32) [[ 0 ]] (+ (SLOAD 0) 1) [[ 1 ]] (CALL (- (GAS) 224) (ADDRESS) 0 0 0 0 0) } ",
|
||||||
|
"storage": {}
|
||||||
|
},
|
||||||
|
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
|
||||||
|
"balance" : "1000000000000000000",
|
||||||
|
"nonce" : 0,
|
||||||
|
"code" : "",
|
||||||
|
"storage": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"transaction" : {
|
||||||
|
"nonce" : "0",
|
||||||
|
"gasPrice" : "1",
|
||||||
|
"gasLimit" : "1000000",
|
||||||
|
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
|
||||||
|
"value" : "100000",
|
||||||
|
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
|
||||||
|
"data" : ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
"CallRecursiveBomb1": {
|
"CallRecursiveBomb1": {
|
||||||
"env" : {
|
"env" : {
|
||||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
|
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
|
||||||
|
@ -125,6 +125,11 @@ BOOST_AUTO_TEST_CASE(stPreCompiledContracts)
|
|||||||
dev::test::executeTests("stPreCompiledContracts", "/StateTests", dev::test::doStateTests);
|
dev::test::executeTests("stPreCompiledContracts", "/StateTests", dev::test::doStateTests);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(stLogTests)
|
||||||
|
{
|
||||||
|
dev::test::executeTests("stLogTests", "/StateTests", dev::test::doStateTests);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(stSpecialTest)
|
BOOST_AUTO_TEST_CASE(stSpecialTest)
|
||||||
{
|
{
|
||||||
dev::test::executeTests("stSpecialTest", "/StateTests", dev::test::doStateTests);
|
dev::test::executeTests("stSpecialTest", "/StateTests", dev::test::doStateTests);
|
||||||
|
39
vm.cpp
39
vm.cpp
@ -120,41 +120,6 @@ void FakeExtVM::importEnv(mObject& _o)
|
|||||||
currentBlock.coinbaseAddress = Address(_o["currentCoinbase"].get_str());
|
currentBlock.coinbaseAddress = Address(_o["currentCoinbase"].get_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
mObject FakeExtVM::exportLog()
|
|
||||||
{
|
|
||||||
mObject ret;
|
|
||||||
for (LogEntry const& l: sub.logs)
|
|
||||||
{
|
|
||||||
mObject o;
|
|
||||||
o["address"] = toString(l.address);
|
|
||||||
mArray topics;
|
|
||||||
for (auto const& t: l.topics)
|
|
||||||
topics.push_back(toString(t));
|
|
||||||
o["topics"] = topics;
|
|
||||||
o["data"] = "0x" + toHex(l.data);
|
|
||||||
ret[toString(l.bloom())] = o;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FakeExtVM::importLog(mObject& _o)
|
|
||||||
{
|
|
||||||
for (auto const& l: _o)
|
|
||||||
{
|
|
||||||
mObject o = l.second.get_obj();
|
|
||||||
// cant use BOOST_REQUIRE, because this function is used outside boost test (createRandomTest)
|
|
||||||
assert(o.count("address") > 0);
|
|
||||||
assert(o.count("topics") > 0);
|
|
||||||
assert(o.count("data") > 0);
|
|
||||||
LogEntry log;
|
|
||||||
log.address = Address(o["address"].get_str());
|
|
||||||
for (auto const& t: o["topics"].get_array())
|
|
||||||
log.topics.push_back(h256(t.get_str()));
|
|
||||||
log.data = importData(o);
|
|
||||||
sub.logs.push_back(log);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mObject FakeExtVM::exportState()
|
mObject FakeExtVM::exportState()
|
||||||
{
|
{
|
||||||
mObject ret;
|
mObject ret;
|
||||||
@ -384,7 +349,7 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
|
|||||||
o["callcreates"] = fev.exportCallCreates();
|
o["callcreates"] = fev.exportCallCreates();
|
||||||
o["out"] = "0x" + toHex(output);
|
o["out"] = "0x" + toHex(output);
|
||||||
fev.push(o, "gas", gas);
|
fev.push(o, "gas", gas);
|
||||||
o["logs"] = mValue(exportLog(fev.sub.logs));
|
o["logs"] = exportLog(fev.sub.logs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -402,7 +367,7 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
|
|||||||
dev::test::FakeExtVM test;
|
dev::test::FakeExtVM test;
|
||||||
test.importState(o["post"].get_obj());
|
test.importState(o["post"].get_obj());
|
||||||
test.importCallCreates(o["callcreates"].get_array());
|
test.importCallCreates(o["callcreates"].get_array());
|
||||||
test.sub.logs = importLog(o["logs"].get_obj());
|
test.sub.logs = importLog(o["logs"].get_array());
|
||||||
|
|
||||||
checkOutput(output, o);
|
checkOutput(output, o);
|
||||||
|
|
||||||
|
2
vm.h
2
vm.h
@ -72,8 +72,6 @@ public:
|
|||||||
void importExec(json_spirit::mObject& _o);
|
void importExec(json_spirit::mObject& _o);
|
||||||
json_spirit::mArray exportCallCreates();
|
json_spirit::mArray exportCallCreates();
|
||||||
void importCallCreates(json_spirit::mArray& _callcreates);
|
void importCallCreates(json_spirit::mArray& _callcreates);
|
||||||
json_spirit::mObject exportLog();
|
|
||||||
void importLog(json_spirit::mObject& _o);
|
|
||||||
|
|
||||||
eth::OnOpFunc simpleTrace();
|
eth::OnOpFunc simpleTrace();
|
||||||
|
|
||||||
|
@ -55,6 +55,34 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"log_2logs": {
|
||||||
|
"env" : {
|
||||||
|
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
|
||||||
|
"currentNumber" : "0",
|
||||||
|
"currentGasLimit" : "1000000",
|
||||||
|
"currentDifficulty" : "256",
|
||||||
|
"currentTimestamp" : 1,
|
||||||
|
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
|
||||||
|
},
|
||||||
|
"pre" : {
|
||||||
|
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
|
||||||
|
"balance" : "1000000000000000000",
|
||||||
|
"nonce" : 0,
|
||||||
|
"code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (LOG0 0 32) (LOG0 2 16) }",
|
||||||
|
"storage": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"exec" : {
|
||||||
|
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
|
||||||
|
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
|
||||||
|
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
|
||||||
|
"value" : "1000000000000000000",
|
||||||
|
"data" : "",
|
||||||
|
"gasPrice" : "100000000000000",
|
||||||
|
"gas" : "10000"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
"log0_nonEmptyMem_logMemSize1": {
|
"log0_nonEmptyMem_logMemSize1": {
|
||||||
"env" : {
|
"env" : {
|
||||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
|
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
|
||||||
|
Loading…
Reference in New Issue
Block a user