mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge remote-tracking branch 'upstream/develop' into stateTests
Conflicts: test/state.cpp test/vm.cpp
This commit is contained in:
commit
26f4637205
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);
|
||||||
|
@ -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()
|
||||||
|
|
||||||
|
32
vm.cpp
32
vm.cpp
@ -35,25 +35,14 @@ h160 FakeExtVM::create(u256 _endowment, u256* _gas, bytesConstRef _init, OnOpFun
|
|||||||
{
|
{
|
||||||
Address na = right160(sha3(rlpList(myAddress, get<1>(addresses[myAddress]))));
|
Address na = right160(sha3(rlpList(myAddress, get<1>(addresses[myAddress]))));
|
||||||
|
|
||||||
Transaction t;
|
Transaction t(_endowment, gasPrice, *_gas, _init.toBytes());
|
||||||
t.value = _endowment;
|
|
||||||
t.gasPrice = gasPrice;
|
|
||||||
t.gas = *_gas;
|
|
||||||
t.data = _init.toBytes();
|
|
||||||
t.type = eth::Transaction::ContractCreation;
|
|
||||||
callcreates.push_back(t);
|
callcreates.push_back(t);
|
||||||
return na;
|
return na;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FakeExtVM::call(Address _receiveAddress, u256 _value, bytesConstRef _data, u256* _gas, bytesRef _out, OnOpFunc const&, Address _myAddressOverride, Address _codeAddressOverride)
|
bool FakeExtVM::call(Address _receiveAddress, u256 _value, bytesConstRef _data, u256* _gas, bytesRef _out, OnOpFunc const&, Address _myAddressOverride, Address _codeAddressOverride)
|
||||||
{
|
{
|
||||||
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);
|
||||||
(void)_out;
|
(void)_out;
|
||||||
(void)_myAddressOverride;
|
(void)_myAddressOverride;
|
||||||
@ -224,10 +213,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;
|
||||||
@ -242,12 +231,9 @@ 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;
|
Transaction t = tx["destination"].get_str().empty() ?
|
||||||
t.type = tx["destination"].get_str().empty() ? Transaction::ContractCreation : Transaction::MessageCall;
|
Transaction(toInt(tx["value"]), 0, toInt(tx["gasLimit"]), data) :
|
||||||
t.receiveAddress = Address(tx["destination"].get_str());
|
Transaction(toInt(tx["value"]), 0, toInt(tx["gasLimit"]), Address(tx["destination"].get_str()), data);
|
||||||
t.value = toInt(tx["value"]);
|
|
||||||
t.gas = toInt(tx["gasLimit"]);
|
|
||||||
t.data = importData(tx);
|
|
||||||
callcreates.push_back(t);
|
callcreates.push_back(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user