mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge remote-tracking branch 'ethereum/develop' into HEAD
Conflicts: libsolidity/Compiler.cpp test/solidityCompiler.cpp
This commit is contained in:
commit
3e73402ba3
14
crypto.cpp
14
crypto.cpp
@ -339,16 +339,11 @@ BOOST_AUTO_TEST_CASE(eth_keypairs)
|
|||||||
BOOST_REQUIRE(p.pub() == Public(fromHex("97466f2b32bc3bb76d4741ae51cd1d8578b48d3f1e68da206d47321aec267ce78549b514e4453d74ef11b0cd5e4e4c364effddac8b51bcfc8de80682f952896f")));
|
BOOST_REQUIRE(p.pub() == Public(fromHex("97466f2b32bc3bb76d4741ae51cd1d8578b48d3f1e68da206d47321aec267ce78549b514e4453d74ef11b0cd5e4e4c364effddac8b51bcfc8de80682f952896f")));
|
||||||
BOOST_REQUIRE(p.address() == Address(fromHex("8a40bfaa73256b60764c1bf40675a99083efb075")));
|
BOOST_REQUIRE(p.address() == Address(fromHex("8a40bfaa73256b60764c1bf40675a99083efb075")));
|
||||||
{
|
{
|
||||||
eth::Transaction t;
|
eth::Transaction t(1000, 0, 0, h160(fromHex("944400f4b88ac9589a0f17ed4671da26bddb668b")), bytes(), 0, p.secret());
|
||||||
t.nonce = 0;
|
|
||||||
t.type = eth::Transaction::MessageCall;
|
|
||||||
t.receiveAddress = h160(fromHex("944400f4b88ac9589a0f17ed4671da26bddb668b"));
|
|
||||||
t.value = 1000;
|
|
||||||
auto rlp = t.rlp(false);
|
auto rlp = t.rlp(false);
|
||||||
cnote << RLP(rlp);
|
cnote << RLP(rlp);
|
||||||
cnote << toHex(rlp);
|
cnote << toHex(rlp);
|
||||||
cnote << t.sha3(false);
|
cnote << t.sha3(false);
|
||||||
t.sign(p.secret());
|
|
||||||
rlp = t.rlp(true);
|
rlp = t.rlp(true);
|
||||||
cnote << RLP(rlp);
|
cnote << RLP(rlp);
|
||||||
cnote << toHex(rlp);
|
cnote << toHex(rlp);
|
||||||
@ -368,16 +363,11 @@ int cryptoTest()
|
|||||||
assert(p.pub() == Public(fromHex("97466f2b32bc3bb76d4741ae51cd1d8578b48d3f1e68da206d47321aec267ce78549b514e4453d74ef11b0cd5e4e4c364effddac8b51bcfc8de80682f952896f")));
|
assert(p.pub() == Public(fromHex("97466f2b32bc3bb76d4741ae51cd1d8578b48d3f1e68da206d47321aec267ce78549b514e4453d74ef11b0cd5e4e4c364effddac8b51bcfc8de80682f952896f")));
|
||||||
assert(p.address() == Address(fromHex("8a40bfaa73256b60764c1bf40675a99083efb075")));
|
assert(p.address() == Address(fromHex("8a40bfaa73256b60764c1bf40675a99083efb075")));
|
||||||
{
|
{
|
||||||
eth::Transaction t;
|
eth::Transaction t(1000, 0, 0, h160(fromHex("944400f4b88ac9589a0f17ed4671da26bddb668b")), bytes(), 0, p.secret());
|
||||||
t.nonce = 0;
|
|
||||||
t.type = eth::Transaction::MessageCall;
|
|
||||||
t.receiveAddress = h160(fromHex("944400f4b88ac9589a0f17ed4671da26bddb668b"));
|
|
||||||
t.value = 1000;
|
|
||||||
auto rlp = t.rlp(false);
|
auto rlp = t.rlp(false);
|
||||||
cnote << RLP(rlp);
|
cnote << RLP(rlp);
|
||||||
cnote << toHex(rlp);
|
cnote << toHex(rlp);
|
||||||
cnote << t.sha3(false);
|
cnote << t.sha3(false);
|
||||||
t.sign(p.secret());
|
|
||||||
rlp = t.rlp(true);
|
rlp = t.rlp(true);
|
||||||
cnote << RLP(rlp);
|
cnote << RLP(rlp);
|
||||||
cnote << toHex(rlp);
|
cnote << toHex(rlp);
|
||||||
|
96
jsonrpc.cpp
96
jsonrpc.cpp
@ -43,44 +43,39 @@ using namespace dev;
|
|||||||
using namespace dev::eth;
|
using namespace dev::eth;
|
||||||
namespace js = json_spirit;
|
namespace js = json_spirit;
|
||||||
|
|
||||||
namespace jsonrpc_tests
|
WebThreeDirect *web3;
|
||||||
{
|
|
||||||
|
|
||||||
string name = "Ethereum(++) tests";
|
|
||||||
string dbPath;
|
|
||||||
auto s = set<string>{"eth", "shh"};
|
|
||||||
dev::p2p::NetworkPreferences np(30303, std::string(), false);
|
|
||||||
dev::WebThreeDirect web3(name, dbPath, true, s, np);
|
|
||||||
|
|
||||||
unique_ptr<WebThreeStubServer> jsonrpcServer;
|
unique_ptr<WebThreeStubServer> jsonrpcServer;
|
||||||
unique_ptr<WebThreeStubClient> jsonrpcClient;
|
unique_ptr<WebThreeStubClient> jsonrpcClient;
|
||||||
|
|
||||||
struct JsonrpcFixture {
|
struct Setup
|
||||||
JsonrpcFixture()
|
{
|
||||||
|
Setup()
|
||||||
{
|
{
|
||||||
cnote << "setup jsonrpc";
|
static bool setup = false;
|
||||||
|
if (setup)
|
||||||
|
return;
|
||||||
|
setup = true;
|
||||||
|
|
||||||
web3.setIdealPeerCount(5);
|
dev::p2p::NetworkPreferences nprefs(30303, std::string(), false);
|
||||||
web3.ethereum()->setForceMining(true);
|
web3 = new WebThreeDirect("Ethereum(++) tests", "", true, {"eth", "shh"}, nprefs);
|
||||||
jsonrpcServer = unique_ptr<WebThreeStubServer>(new WebThreeStubServer(new jsonrpc::CorsHttpServer(8080), web3, {}));
|
|
||||||
|
web3->setIdealPeerCount(5);
|
||||||
|
web3->ethereum()->setForceMining(true);
|
||||||
|
jsonrpcServer = unique_ptr<WebThreeStubServer>(new WebThreeStubServer(new jsonrpc::CorsHttpServer(8080), *web3, {}));
|
||||||
jsonrpcServer->setIdentities({});
|
jsonrpcServer->setIdentities({});
|
||||||
jsonrpcServer->StartListening();
|
jsonrpcServer->StartListening();
|
||||||
|
|
||||||
jsonrpcClient = unique_ptr<WebThreeStubClient>(new WebThreeStubClient(new jsonrpc::HttpClient("http://localhost:8080")));
|
jsonrpcClient = unique_ptr<WebThreeStubClient>(new WebThreeStubClient(new jsonrpc::HttpClient("http://localhost:8080")));
|
||||||
}
|
}
|
||||||
~JsonrpcFixture()
|
|
||||||
{
|
|
||||||
cnote << "teardown jsonrpc";
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
BOOST_GLOBAL_FIXTURE(JsonrpcFixture)
|
BOOST_FIXTURE_TEST_SUITE(environment, Setup)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(jsonrpc_defaultBlock)
|
BOOST_AUTO_TEST_CASE(jsonrpc_defaultBlock)
|
||||||
{
|
{
|
||||||
cnote << "Testing jsonrpc defaultBlock...";
|
cnote << "Testing jsonrpc defaultBlock...";
|
||||||
int defaultBlock = jsonrpcClient->defaultBlock();
|
int defaultBlock = jsonrpcClient->defaultBlock();
|
||||||
BOOST_CHECK_EQUAL(defaultBlock, web3.ethereum()->getDefault());
|
BOOST_CHECK_EQUAL(defaultBlock, web3->ethereum()->getDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(jsonrpc_gasPrice)
|
BOOST_AUTO_TEST_CASE(jsonrpc_gasPrice)
|
||||||
@ -94,26 +89,26 @@ BOOST_AUTO_TEST_CASE(jsonrpc_isListening)
|
|||||||
{
|
{
|
||||||
cnote << "Testing jsonrpc isListening...";
|
cnote << "Testing jsonrpc isListening...";
|
||||||
|
|
||||||
web3.startNetwork();
|
web3->startNetwork();
|
||||||
bool listeningOn = jsonrpcClient->listening();
|
bool listeningOn = jsonrpcClient->listening();
|
||||||
BOOST_CHECK_EQUAL(listeningOn, web3.isNetworkStarted());
|
BOOST_CHECK_EQUAL(listeningOn, web3->isNetworkStarted());
|
||||||
|
|
||||||
web3.stopNetwork();
|
web3->stopNetwork();
|
||||||
bool listeningOff = jsonrpcClient->listening();
|
bool listeningOff = jsonrpcClient->listening();
|
||||||
BOOST_CHECK_EQUAL(listeningOff, web3.isNetworkStarted());
|
BOOST_CHECK_EQUAL(listeningOff, web3->isNetworkStarted());
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(jsonrpc_isMining)
|
BOOST_AUTO_TEST_CASE(jsonrpc_isMining)
|
||||||
{
|
{
|
||||||
cnote << "Testing jsonrpc isMining...";
|
cnote << "Testing jsonrpc isMining...";
|
||||||
|
|
||||||
web3.ethereum()->startMining();
|
web3->ethereum()->startMining();
|
||||||
bool miningOn = jsonrpcClient->mining();
|
bool miningOn = jsonrpcClient->mining();
|
||||||
BOOST_CHECK_EQUAL(miningOn, web3.ethereum()->isMining());
|
BOOST_CHECK_EQUAL(miningOn, web3->ethereum()->isMining());
|
||||||
|
|
||||||
web3.ethereum()->stopMining();
|
web3->ethereum()->stopMining();
|
||||||
bool miningOff = jsonrpcClient->mining();
|
bool miningOff = jsonrpcClient->mining();
|
||||||
BOOST_CHECK_EQUAL(miningOff, web3.ethereum()->isMining());
|
BOOST_CHECK_EQUAL(miningOff, web3->ethereum()->isMining());
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(jsonrpc_accounts)
|
BOOST_AUTO_TEST_CASE(jsonrpc_accounts)
|
||||||
@ -139,18 +134,18 @@ BOOST_AUTO_TEST_CASE(jsonrpc_number)
|
|||||||
{
|
{
|
||||||
cnote << "Testing jsonrpc number2...";
|
cnote << "Testing jsonrpc number2...";
|
||||||
int number = jsonrpcClient->number();
|
int number = jsonrpcClient->number();
|
||||||
BOOST_CHECK_EQUAL(number, web3.ethereum()->number() + 1);
|
BOOST_CHECK_EQUAL(number, web3->ethereum()->number() + 1);
|
||||||
dev::eth::mine(*(web3.ethereum()), 1);
|
dev::eth::mine(*(web3->ethereum()), 1);
|
||||||
int numberAfter = jsonrpcClient->number();
|
int numberAfter = jsonrpcClient->number();
|
||||||
BOOST_CHECK_EQUAL(number + 1, numberAfter);
|
BOOST_CHECK_EQUAL(number + 1, numberAfter);
|
||||||
BOOST_CHECK_EQUAL(numberAfter, web3.ethereum()->number() + 1);
|
BOOST_CHECK_EQUAL(numberAfter, web3->ethereum()->number() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(jsonrpc_peerCount)
|
BOOST_AUTO_TEST_CASE(jsonrpc_peerCount)
|
||||||
{
|
{
|
||||||
cnote << "Testing jsonrpc peerCount...";
|
cnote << "Testing jsonrpc peerCount...";
|
||||||
int peerCount = jsonrpcClient->peerCount();
|
int peerCount = jsonrpcClient->peerCount();
|
||||||
BOOST_CHECK_EQUAL(web3.peerCount(), peerCount);
|
BOOST_CHECK_EQUAL(web3->peerCount(), peerCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(jsonrpc_setListening)
|
BOOST_AUTO_TEST_CASE(jsonrpc_setListening)
|
||||||
@ -158,10 +153,10 @@ BOOST_AUTO_TEST_CASE(jsonrpc_setListening)
|
|||||||
cnote << "Testing jsonrpc setListening...";
|
cnote << "Testing jsonrpc setListening...";
|
||||||
|
|
||||||
jsonrpcClient->setListening(true);
|
jsonrpcClient->setListening(true);
|
||||||
BOOST_CHECK_EQUAL(web3.isNetworkStarted(), true);
|
BOOST_CHECK_EQUAL(web3->isNetworkStarted(), true);
|
||||||
|
|
||||||
jsonrpcClient->setListening(false);
|
jsonrpcClient->setListening(false);
|
||||||
BOOST_CHECK_EQUAL(web3.isNetworkStarted(), false);
|
BOOST_CHECK_EQUAL(web3->isNetworkStarted(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(jsonrpc_setMining)
|
BOOST_AUTO_TEST_CASE(jsonrpc_setMining)
|
||||||
@ -169,10 +164,10 @@ BOOST_AUTO_TEST_CASE(jsonrpc_setMining)
|
|||||||
cnote << "Testing jsonrpc setMining...";
|
cnote << "Testing jsonrpc setMining...";
|
||||||
|
|
||||||
jsonrpcClient->setMining(true);
|
jsonrpcClient->setMining(true);
|
||||||
BOOST_CHECK_EQUAL(web3.ethereum()->isMining(), true);
|
BOOST_CHECK_EQUAL(web3->ethereum()->isMining(), true);
|
||||||
|
|
||||||
jsonrpcClient->setMining(false);
|
jsonrpcClient->setMining(false);
|
||||||
BOOST_CHECK_EQUAL(web3.ethereum()->isMining(), false);
|
BOOST_CHECK_EQUAL(web3->ethereum()->isMining(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(jsonrpc_stateAt)
|
BOOST_AUTO_TEST_CASE(jsonrpc_stateAt)
|
||||||
@ -181,36 +176,36 @@ BOOST_AUTO_TEST_CASE(jsonrpc_stateAt)
|
|||||||
dev::KeyPair key = KeyPair::create();
|
dev::KeyPair key = KeyPair::create();
|
||||||
auto address = key.address();
|
auto address = key.address();
|
||||||
string stateAt = jsonrpcClient->stateAt(toJS(address), "0");
|
string stateAt = jsonrpcClient->stateAt(toJS(address), "0");
|
||||||
BOOST_CHECK_EQUAL(toJS(web3.ethereum()->stateAt(address, jsToU256("0"), 0)), stateAt);
|
BOOST_CHECK_EQUAL(toJS(web3->ethereum()->stateAt(address, jsToU256("0"), 0)), stateAt);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(jsonrpc_transact)
|
BOOST_AUTO_TEST_CASE(jsonrpc_transact)
|
||||||
{
|
{
|
||||||
cnote << "Testing jsonrpc transact...";
|
cnote << "Testing jsonrpc transact...";
|
||||||
string coinbase = jsonrpcClient->coinbase();
|
string coinbase = jsonrpcClient->coinbase();
|
||||||
BOOST_CHECK_EQUAL(jsToAddress(coinbase), web3.ethereum()->address());
|
BOOST_CHECK_EQUAL(jsToAddress(coinbase), web3->ethereum()->address());
|
||||||
|
|
||||||
dev::KeyPair key = KeyPair::create();
|
dev::KeyPair key = KeyPair::create();
|
||||||
auto address = key.address();
|
auto address = key.address();
|
||||||
auto receiver = KeyPair::create();
|
auto receiver = KeyPair::create();
|
||||||
web3.ethereum()->setAddress(address);
|
web3->ethereum()->setAddress(address);
|
||||||
|
|
||||||
coinbase = jsonrpcClient->coinbase();
|
coinbase = jsonrpcClient->coinbase();
|
||||||
BOOST_CHECK_EQUAL(jsToAddress(coinbase), web3.ethereum()->address());
|
BOOST_CHECK_EQUAL(jsToAddress(coinbase), web3->ethereum()->address());
|
||||||
BOOST_CHECK_EQUAL(jsToAddress(coinbase), address);
|
BOOST_CHECK_EQUAL(jsToAddress(coinbase), address);
|
||||||
|
|
||||||
jsonrpcServer->setAccounts({key});
|
jsonrpcServer->setAccounts({key});
|
||||||
auto balance = web3.ethereum()->balanceAt(address, 0);
|
auto balance = web3->ethereum()->balanceAt(address, 0);
|
||||||
string balanceString = jsonrpcClient->balanceAt(toJS(address));
|
string balanceString = jsonrpcClient->balanceAt(toJS(address));
|
||||||
double countAt = jsonrpcClient->countAt(toJS(address));
|
double countAt = jsonrpcClient->countAt(toJS(address));
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(countAt, (double)(uint64_t)web3.ethereum()->countAt(address));
|
BOOST_CHECK_EQUAL(countAt, (double)(uint64_t)web3->ethereum()->countAt(address));
|
||||||
BOOST_CHECK_EQUAL(countAt, 0);
|
BOOST_CHECK_EQUAL(countAt, 0);
|
||||||
BOOST_CHECK_EQUAL(toJS(balance), balanceString);
|
BOOST_CHECK_EQUAL(toJS(balance), balanceString);
|
||||||
BOOST_CHECK_EQUAL(jsToDecimal(balanceString), "0");
|
BOOST_CHECK_EQUAL(jsToDecimal(balanceString), "0");
|
||||||
|
|
||||||
dev::eth::mine(*(web3.ethereum()), 1);
|
dev::eth::mine(*(web3->ethereum()), 1);
|
||||||
balance = web3.ethereum()->balanceAt(address, 0);
|
balance = web3->ethereum()->balanceAt(address, 0);
|
||||||
balanceString = jsonrpcClient->balanceAt(toJS(address));
|
balanceString = jsonrpcClient->balanceAt(toJS(address));
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(toJS(balance), balanceString);
|
BOOST_CHECK_EQUAL(toJS(balance), balanceString);
|
||||||
@ -230,21 +225,20 @@ BOOST_AUTO_TEST_CASE(jsonrpc_transact)
|
|||||||
|
|
||||||
jsonrpcClient->transact(t);
|
jsonrpcClient->transact(t);
|
||||||
jsonrpcServer->setAccounts({});
|
jsonrpcServer->setAccounts({});
|
||||||
dev::eth::mine(*(web3.ethereum()), 1);
|
dev::eth::mine(*(web3->ethereum()), 1);
|
||||||
|
|
||||||
countAt = jsonrpcClient->countAt(toJS(address));
|
countAt = jsonrpcClient->countAt(toJS(address));
|
||||||
auto balance2 = web3.ethereum()->balanceAt(receiver.address());
|
auto balance2 = web3->ethereum()->balanceAt(receiver.address());
|
||||||
string balanceString2 = jsonrpcClient->balanceAt(toJS(receiver.address()));
|
string balanceString2 = jsonrpcClient->balanceAt(toJS(receiver.address()));
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(countAt, (double)(uint64_t)web3.ethereum()->countAt(address));
|
BOOST_CHECK_EQUAL(countAt, (double)(uint64_t)web3->ethereum()->countAt(address));
|
||||||
BOOST_CHECK_EQUAL(countAt, 1);
|
BOOST_CHECK_EQUAL(countAt, 1);
|
||||||
BOOST_CHECK_EQUAL(toJS(balance2), balanceString2);
|
BOOST_CHECK_EQUAL(toJS(balance2), balanceString2);
|
||||||
BOOST_CHECK_EQUAL(jsToDecimal(balanceString2), "750000000000000000");
|
BOOST_CHECK_EQUAL(jsToDecimal(balanceString2), "750000000000000000");
|
||||||
BOOST_CHECK_EQUAL(txAmount, balance2);
|
BOOST_CHECK_EQUAL(txAmount, balance2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -211,7 +211,15 @@ BOOST_AUTO_TEST_CASE(else_if_statement)
|
|||||||
BOOST_CHECK_NO_THROW(parseText(text));
|
BOOST_CHECK_NO_THROW(parseText(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(statement_starting_with_type_conversion)
|
||||||
|
{
|
||||||
|
char const* text = "contract test {\n"
|
||||||
|
" function fun() {\n"
|
||||||
|
" uint64(2);\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n";
|
||||||
|
BOOST_CHECK_NO_THROW(parseText(text));
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
|
@ -65,12 +65,7 @@ int stateTest()
|
|||||||
// Inject a transaction to transfer funds from miner to me.
|
// Inject a transaction to transfer funds from miner to me.
|
||||||
bytes tx;
|
bytes tx;
|
||||||
{
|
{
|
||||||
Transaction t;
|
Transaction t(1000, 0, 0, me.address(), bytes(), s.transactionsFrom(myMiner.address()), myMiner.secret());
|
||||||
t.nonce = s.transactionsFrom(myMiner.address());
|
|
||||||
t.value = 1000; // 1e3 wei.
|
|
||||||
t.type = eth::Transaction::MessageCall;
|
|
||||||
t.receiveAddress = me.address();
|
|
||||||
t.sign(myMiner.secret());
|
|
||||||
assert(t.sender() == myMiner.address());
|
assert(t.sender() == myMiner.address());
|
||||||
tx = t.rlp();
|
tx = t.rlp();
|
||||||
}
|
}
|
||||||
|
38
vm.cpp
38
vm.cpp
@ -36,11 +36,7 @@ FakeExtVM::FakeExtVM(eth::BlockInfo const& _previousBlock, eth::BlockInfo const&
|
|||||||
|
|
||||||
h160 FakeExtVM::create(u256 _endowment, u256* _gas, bytesConstRef _init, OnOpFunc const&)
|
h160 FakeExtVM::create(u256 _endowment, u256* _gas, bytesConstRef _init, OnOpFunc const&)
|
||||||
{
|
{
|
||||||
Transaction t;
|
Transaction t(_endowment, gasPrice, *_gas, _init.toBytes());
|
||||||
t.value = _endowment;
|
|
||||||
t.gasPrice = gasPrice;
|
|
||||||
t.gas = *_gas;
|
|
||||||
t.data = _init.toBytes();
|
|
||||||
|
|
||||||
m_s.noteSending(myAddress);
|
m_s.noteSending(myAddress);
|
||||||
m_ms.internal.resize(m_ms.internal.size() + 1);
|
m_ms.internal.resize(m_ms.internal.size() + 1);
|
||||||
@ -55,7 +51,6 @@ h160 FakeExtVM::create(u256 _endowment, u256* _gas, bytesConstRef _init, OnOpFun
|
|||||||
get<3>(addresses[ret]) = m_s.code(ret);
|
get<3>(addresses[ret]) = m_s.code(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
t.type = eth::Transaction::ContractCreation;
|
|
||||||
callcreates.push_back(t);
|
callcreates.push_back(t);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -64,13 +59,7 @@ bool FakeExtVM::call(Address _receiveAddress, u256 _value, bytesConstRef _data,
|
|||||||
{
|
{
|
||||||
u256 contractgas = 0xffff;
|
u256 contractgas = 0xffff;
|
||||||
|
|
||||||
Transaction t;
|
Transaction t(_value, gasPrice, *_gas, _receiveAddress, _data.toVector());
|
||||||
t.value = _value;
|
|
||||||
t.gasPrice = gasPrice;
|
|
||||||
t.gas = *_gas;
|
|
||||||
t.data = _data.toVector();
|
|
||||||
t.type = eth::Transaction::MessageCall;
|
|
||||||
t.receiveAddress = _receiveAddress;
|
|
||||||
callcreates.push_back(t);
|
callcreates.push_back(t);
|
||||||
|
|
||||||
string codeOf_CodeAddress = _codeAddressOverride ? toHex(get<3>(addresses[_codeAddressOverride])) : toHex(get<3>(addresses[_receiveAddress]) );
|
string codeOf_CodeAddress = _codeAddressOverride ? toHex(get<3>(addresses[_codeAddressOverride])) : toHex(get<3>(addresses[_receiveAddress]) );
|
||||||
@ -386,10 +375,10 @@ mArray FakeExtVM::exportCallCreates()
|
|||||||
for (Transaction const& tx: callcreates)
|
for (Transaction const& tx: callcreates)
|
||||||
{
|
{
|
||||||
mObject o;
|
mObject o;
|
||||||
o["destination"] = tx.type == Transaction::ContractCreation ? "" : toString(tx.receiveAddress);
|
o["destination"] = tx.type() == Transaction::ContractCreation ? "" : toString(tx.receiveAddress());
|
||||||
push(o, "gasLimit", tx.gas);
|
push(o, "gasLimit", tx.gas());
|
||||||
push(o, "value", tx.value);
|
push(o, "value", tx.value());
|
||||||
o["data"] = "0x" + toHex(tx.data);
|
o["data"] = "0x" + toHex(tx.data());
|
||||||
ret.push_back(o);
|
ret.push_back(o);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -404,19 +393,18 @@ void FakeExtVM::importCallCreates(mArray& _callcreates)
|
|||||||
BOOST_REQUIRE(tx.count("value") > 0);
|
BOOST_REQUIRE(tx.count("value") > 0);
|
||||||
BOOST_REQUIRE(tx.count("destination") > 0);
|
BOOST_REQUIRE(tx.count("destination") > 0);
|
||||||
BOOST_REQUIRE(tx.count("gasLimit") > 0);
|
BOOST_REQUIRE(tx.count("gasLimit") > 0);
|
||||||
Transaction t;
|
bytes data;
|
||||||
t.type = tx["destination"].get_str().empty() ? Transaction::ContractCreation : Transaction::MessageCall;
|
|
||||||
t.receiveAddress = Address(tx["destination"].get_str());
|
|
||||||
t.value = toInt(tx["value"]);
|
|
||||||
t.gas = toInt(tx["gasLimit"]);
|
|
||||||
if (tx["data"].type() == str_type)
|
if (tx["data"].type() == str_type)
|
||||||
if (tx["data"].get_str().find_first_of("0x") == 0)
|
if (tx["data"].get_str().find_first_of("0x") == 0)
|
||||||
t.data = fromHex(tx["data"].get_str().substr(2));
|
data = fromHex(tx["data"].get_str().substr(2));
|
||||||
else
|
else
|
||||||
t.data = fromHex(tx["data"].get_str());
|
data = fromHex(tx["data"].get_str());
|
||||||
else
|
else
|
||||||
for (auto const& j: tx["data"].get_array())
|
for (auto const& j: tx["data"].get_array())
|
||||||
t.data.push_back(toByte(j));
|
data.push_back(toByte(j));
|
||||||
|
Transaction t = tx["destination"].get_str().empty() ?
|
||||||
|
Transaction(toInt(tx["value"]), 0, toInt(tx["gasLimit"]), data) :
|
||||||
|
Transaction(toInt(tx["value"]), 0, toInt(tx["gasLimit"]), Address(tx["destination"].get_str()), data);
|
||||||
callcreates.push_back(t);
|
callcreates.push_back(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user