mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge branch 'develop' of https://github.com/ethereum/cpp-ethereum into develop
This commit is contained in:
commit
6c2822eafd
@ -76,7 +76,7 @@ BOOST_AUTO_TEST_CASE(basic_test)
|
|||||||
char const* interface = R"([
|
char const* interface = R"([
|
||||||
{
|
{
|
||||||
"name": "f",
|
"name": "f",
|
||||||
"const": false,
|
"constant": false,
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"name": "a",
|
"name": "a",
|
||||||
@ -115,7 +115,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods)
|
|||||||
char const* interface = R"([
|
char const* interface = R"([
|
||||||
{
|
{
|
||||||
"name": "f",
|
"name": "f",
|
||||||
"const": false,
|
"constant": false,
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"name": "a",
|
"name": "a",
|
||||||
@ -131,7 +131,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods)
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "g",
|
"name": "g",
|
||||||
"const": false,
|
"constant": false,
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"name": "b",
|
"name": "b",
|
||||||
@ -159,7 +159,7 @@ BOOST_AUTO_TEST_CASE(multiple_params)
|
|||||||
char const* interface = R"([
|
char const* interface = R"([
|
||||||
{
|
{
|
||||||
"name": "f",
|
"name": "f",
|
||||||
"const": false,
|
"constant": false,
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"name": "a",
|
"name": "a",
|
||||||
@ -193,7 +193,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order)
|
|||||||
char const* interface = R"([
|
char const* interface = R"([
|
||||||
{
|
{
|
||||||
"name": "c",
|
"name": "c",
|
||||||
"const": false,
|
"constant": false,
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"name": "b",
|
"name": "b",
|
||||||
@ -209,7 +209,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order)
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "f",
|
"name": "f",
|
||||||
"const": false,
|
"constant": false,
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"name": "a",
|
"name": "a",
|
||||||
@ -232,13 +232,13 @@ BOOST_AUTO_TEST_CASE(const_function)
|
|||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = "contract test {\n"
|
||||||
" function foo(uint a, uint b) returns(uint d) { return a + b; }\n"
|
" function foo(uint a, uint b) returns(uint d) { return a + b; }\n"
|
||||||
" function boo(uint32 a) const returns(uint b) { return a * 4; }\n"
|
" function boo(uint32 a) constant returns(uint b) { return a * 4; }\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
char const* interface = R"([
|
char const* interface = R"([
|
||||||
{
|
{
|
||||||
"name": "boo",
|
"name": "boo",
|
||||||
"const": true,
|
"constant": true,
|
||||||
"inputs": [{
|
"inputs": [{
|
||||||
"name": "a",
|
"name": "a",
|
||||||
"type": "uint32"
|
"type": "uint32"
|
||||||
@ -252,7 +252,7 @@ BOOST_AUTO_TEST_CASE(const_function)
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "foo",
|
"name": "foo",
|
||||||
"const": false,
|
"constant": false,
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"name": "a",
|
"name": "a",
|
||||||
|
@ -91,7 +91,7 @@ BOOST_AUTO_TEST_CASE(empty_function)
|
|||||||
{
|
{
|
||||||
char const* text = "contract test {\n"
|
char const* text = "contract test {\n"
|
||||||
" uint256 stateVar;\n"
|
" uint256 stateVar;\n"
|
||||||
" function functionName(hash160 arg1, address addr) const\n"
|
" function functionName(hash160 arg1, address addr) constant\n"
|
||||||
" returns (int id)\n"
|
" returns (int id)\n"
|
||||||
" { }\n"
|
" { }\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
#include <libethereum/Client.h>
|
#include <libethereum/Client.h>
|
||||||
#include <liblll/Compiler.h>
|
#include <liblll/Compiler.h>
|
||||||
|
#include <libevm/VMFactory.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev::eth;
|
using namespace dev::eth;
|
||||||
@ -330,7 +331,7 @@ void checkStorage(map<u256, u256> _expectedStore, map<u256, u256> _resultStore,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
BOOST_CHECK_EQUAL(_resultStore.size(), _expectedStore.size());
|
BOOST_CHECK_EQUAL(_resultStore.size(), _expectedStore.size());
|
||||||
for (auto&& resultStorePair : _resultStore)
|
for (auto&& resultStorePair: _resultStore)
|
||||||
{
|
{
|
||||||
if (!_expectedStore.count(resultStorePair.first))
|
if (!_expectedStore.count(resultStorePair.first))
|
||||||
BOOST_ERROR(_expectedAddr << ": unexpected store key " << resultStorePair.first);
|
BOOST_ERROR(_expectedAddr << ": unexpected store key " << resultStorePair.first);
|
||||||
@ -472,4 +473,20 @@ void executeTests(const string& _name, const string& _testPathAppendix, std::fun
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void processCommandLineOptions()
|
||||||
|
{
|
||||||
|
auto argc = boost::unit_test::framework::master_test_suite().argc;
|
||||||
|
auto argv = boost::unit_test::framework::master_test_suite().argv;
|
||||||
|
|
||||||
|
for (auto i = 0; i < argc; ++i)
|
||||||
|
{
|
||||||
|
if (std::string(argv[i]) == "--jit")
|
||||||
|
{
|
||||||
|
eth::VMFactory::setKind(eth::VMKind::JIT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} } // namespaces
|
} } // namespaces
|
||||||
|
@ -76,6 +76,7 @@ void checkLog(eth::LogEntries _resultLogs, eth::LogEntries _expectedLogs);
|
|||||||
void executeTests(const std::string& _name, const std::string& _testPathAppendix, std::function<void(json_spirit::mValue&, bool)> doTests);
|
void executeTests(const std::string& _name, const std::string& _testPathAppendix, std::function<void(json_spirit::mValue&, bool)> doTests);
|
||||||
std::string getTestPath();
|
std::string getTestPath();
|
||||||
void userDefinedTest(std::string testTypeFlag, std::function<void(json_spirit::mValue&, bool)> doTests);
|
void userDefinedTest(std::string testTypeFlag, std::function<void(json_spirit::mValue&, bool)> doTests);
|
||||||
|
void processCommandLineOptions();
|
||||||
|
|
||||||
template<typename mapType>
|
template<typename mapType>
|
||||||
void checkAddresses(mapType& _expectedAddrs, mapType& _resultAddrs)
|
void checkAddresses(mapType& _expectedAddrs, mapType& _resultAddrs)
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
* @date 2014
|
* @date 2014
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// @debris disabled as tests fail with:
|
||||||
|
// unknown location(0): fatal error in "jsonrpc_setMining": std::exception: Exception -32003 : Client connector error: : libcurl error: 28
|
||||||
|
// /home/gav/Eth/cpp-ethereum/test/jsonrpc.cpp(169): last checkpoint
|
||||||
#if ETH_JSONRPC && 0
|
#if ETH_JSONRPC && 0
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
@ -29,7 +32,7 @@
|
|||||||
#include <libwebthree/WebThree.h>
|
#include <libwebthree/WebThree.h>
|
||||||
#include <libweb3jsonrpc/WebThreeStubServer.h>
|
#include <libweb3jsonrpc/WebThreeStubServer.h>
|
||||||
#include <libweb3jsonrpc/CorsHttpServer.h>
|
#include <libweb3jsonrpc/CorsHttpServer.h>
|
||||||
#include <json/json.h>
|
//#include <json/json.h>
|
||||||
#include <jsonrpccpp/server/connectors/httpserver.h>
|
#include <jsonrpccpp/server/connectors/httpserver.h>
|
||||||
#include <jsonrpccpp/client/connectors/httpclient.h>
|
#include <jsonrpccpp/client/connectors/httpclient.h>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
@ -43,6 +43,8 @@ namespace dev { namespace test {
|
|||||||
|
|
||||||
void doStateTests(json_spirit::mValue& v, bool _fillin)
|
void doStateTests(json_spirit::mValue& v, bool _fillin)
|
||||||
{
|
{
|
||||||
|
processCommandLineOptions();
|
||||||
|
|
||||||
for (auto& i: v.get_obj())
|
for (auto& i: v.get_obj())
|
||||||
{
|
{
|
||||||
cerr << i.first << endl;
|
cerr << i.first << endl;
|
||||||
|
24
vm.cpp
24
vm.cpp
@ -20,6 +20,7 @@
|
|||||||
* vm test functions.
|
* vm test functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <libethereum/Executive.h>
|
#include <libethereum/Executive.h>
|
||||||
#include <libevm/VMFactory.h>
|
#include <libevm/VMFactory.h>
|
||||||
@ -308,6 +309,8 @@ namespace dev { namespace test {
|
|||||||
|
|
||||||
void doVMTests(json_spirit::mValue& v, bool _fillin)
|
void doVMTests(json_spirit::mValue& v, bool _fillin)
|
||||||
{
|
{
|
||||||
|
processCommandLineOptions();
|
||||||
|
|
||||||
for (auto& i: v.get_obj())
|
for (auto& i: v.get_obj())
|
||||||
{
|
{
|
||||||
cnote << i.first;
|
cnote << i.first;
|
||||||
@ -317,7 +320,7 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
|
|||||||
BOOST_REQUIRE(o.count("pre") > 0);
|
BOOST_REQUIRE(o.count("pre") > 0);
|
||||||
BOOST_REQUIRE(o.count("exec") > 0);
|
BOOST_REQUIRE(o.count("exec") > 0);
|
||||||
|
|
||||||
dev::test::FakeExtVM fev;
|
FakeExtVM fev;
|
||||||
fev.importEnv(o["env"].get_obj());
|
fev.importEnv(o["env"].get_obj());
|
||||||
fev.importState(o["pre"].get_obj());
|
fev.importState(o["pre"].get_obj());
|
||||||
|
|
||||||
@ -332,12 +335,12 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bytes output;
|
bytes output;
|
||||||
auto vm = eth::VMFactory::create(fev.gas);
|
|
||||||
|
|
||||||
u256 gas;
|
u256 gas;
|
||||||
bool vmExceptionOccured = false;
|
bool vmExceptionOccured = false;
|
||||||
|
auto startTime = std::chrono::high_resolution_clock::now();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
auto vm = eth::VMFactory::create(fev.gas);
|
||||||
output = vm->go(fev, fev.simpleTrace()).toBytes();
|
output = vm->go(fev, fev.simpleTrace()).toBytes();
|
||||||
gas = vm->gas();
|
gas = vm->gas();
|
||||||
}
|
}
|
||||||
@ -357,6 +360,21 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
|
|||||||
BOOST_ERROR("Failed VM Test with Exception: " << _e.what());
|
BOOST_ERROR("Failed VM Test with Exception: " << _e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto endTime = std::chrono::high_resolution_clock::now();
|
||||||
|
auto argc = boost::unit_test::framework::master_test_suite().argc;
|
||||||
|
auto argv = boost::unit_test::framework::master_test_suite().argv;
|
||||||
|
for (auto i = 0; i < argc; ++i)
|
||||||
|
{
|
||||||
|
if (std::string(argv[i]) == "--show-times")
|
||||||
|
{
|
||||||
|
auto testDuration = endTime - startTime;
|
||||||
|
cnote << "Execution time: "
|
||||||
|
<< std::chrono::duration_cast<std::chrono::milliseconds>(testDuration).count()
|
||||||
|
<< " ms";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// delete null entries in storage for the sake of comparison
|
// delete null entries in storage for the sake of comparison
|
||||||
|
|
||||||
for (auto &a: fev.addresses)
|
for (auto &a: fev.addresses)
|
||||||
|
Loading…
Reference in New Issue
Block a user