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 build_enhancement
Conflicts: windows/LibEthereum.vcxproj windows/LibEthereum.vcxproj.filters Solved by removing files (not necessary anymore)
This commit is contained in:
commit
8e9659752d
@ -109,9 +109,6 @@ void ImportTest::importState(json_spirit::mObject& _o, State& _state)
|
|||||||
|
|
||||||
Address address = Address(i.first);
|
Address address = Address(i.first);
|
||||||
|
|
||||||
for (auto const& j: o["storage"].get_obj())
|
|
||||||
_state.setStorage(address, toInt(j.first), toInt(j.second));
|
|
||||||
|
|
||||||
bytes code = importCode(o);
|
bytes code = importCode(o);
|
||||||
|
|
||||||
if (code.size())
|
if (code.size())
|
||||||
@ -122,6 +119,9 @@ void ImportTest::importState(json_spirit::mObject& _o, State& _state)
|
|||||||
else
|
else
|
||||||
_state.m_cache[address] = Account(toInt(o["balance"]), Account::NormalCreation);
|
_state.m_cache[address] = Account(toInt(o["balance"]), Account::NormalCreation);
|
||||||
|
|
||||||
|
for (auto const& j: o["storage"].get_obj())
|
||||||
|
_state.setStorage(address, toInt(j.first), toInt(j.second));
|
||||||
|
|
||||||
for(int i=0; i<toInt(o["nonce"]); ++i)
|
for(int i=0; i<toInt(o["nonce"]); ++i)
|
||||||
_state.noteSending(address);
|
_state.noteSending(address);
|
||||||
|
|
||||||
@ -329,6 +329,10 @@ void checkStorage(map<u256, u256> _expectedStore, map<u256, u256> _resultStore,
|
|||||||
BOOST_CHECK_MESSAGE(expectedStoreValue == resultStoreValue, _expectedAddr << ": store[" << expectedStoreKey << "] = " << resultStoreValue << ", expected " << expectedStoreValue);
|
BOOST_CHECK_MESSAGE(expectedStoreValue == resultStoreValue, _expectedAddr << ": store[" << expectedStoreKey << "] = " << resultStoreValue << ", expected " << expectedStoreValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BOOST_CHECK_EQUAL(_resultStore.size(), _expectedStore.size());
|
||||||
|
for (auto&& resultStorePair : _resultStore)
|
||||||
|
if (!_expectedStore.count(resultStorePair.first))
|
||||||
|
BOOST_ERROR(_expectedAddr << ": unexpected store key " << resultStorePair.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkLog(LogEntries _resultLogs, LogEntries _expectedLogs)
|
void checkLog(LogEntries _resultLogs, LogEntries _expectedLogs)
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include <libdevcore/CommonIO.h>
|
#include <libdevcore/CommonIO.h>
|
||||||
#include <libdevcore/CommonData.h>
|
#include <libdevcore/CommonData.h>
|
||||||
#include <libevmcore/Instruction.h>
|
#include <libevmcore/Instruction.h>
|
||||||
#include <libevm/VM.h>
|
#include <libevm/VMFactory.h>
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -142,14 +142,14 @@ void doMyTests(json_spirit::mValue& v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bytes output;
|
bytes output;
|
||||||
eth::VM vm(fev.gas);
|
auto vm = eth::VMFactory::create(fev.gas);
|
||||||
|
|
||||||
u256 gas;
|
u256 gas;
|
||||||
bool vmExceptionOccured = false;
|
bool vmExceptionOccured = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
output = vm.go(fev, fev.simpleTrace()).toBytes();
|
output = vm->go(fev, fev.simpleTrace()).toBytes();
|
||||||
gas = vm.gas();
|
gas = vm->gas();
|
||||||
}
|
}
|
||||||
catch (eth::VMException const& _e)
|
catch (eth::VMException const& _e)
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
* @date 2014
|
* @date 2014
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if ETH_JSONRPC
|
#if ETH_JSONRPC && 0
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE(smoke_test)
|
|||||||
"}\n";
|
"}\n";
|
||||||
bytes code = compileContract(sourceCode);
|
bytes code = compileContract(sourceCode);
|
||||||
|
|
||||||
unsigned boilerplateSize = 42;
|
unsigned boilerplateSize = 40;
|
||||||
bytes expectation({byte(Instruction::JUMPDEST),
|
bytes expectation({byte(Instruction::JUMPDEST),
|
||||||
byte(Instruction::PUSH1), 0x0, // initialize local variable x
|
byte(Instruction::PUSH1), 0x0, // initialize local variable x
|
||||||
byte(Instruction::PUSH1), 0x2,
|
byte(Instruction::PUSH1), 0x2,
|
||||||
@ -107,8 +107,8 @@ BOOST_AUTO_TEST_CASE(different_argument_numbers)
|
|||||||
"}\n";
|
"}\n";
|
||||||
bytes code = compileContract(sourceCode);
|
bytes code = compileContract(sourceCode);
|
||||||
|
|
||||||
unsigned shift = 70;
|
unsigned shift = 68;
|
||||||
unsigned boilerplateSize = 83;
|
unsigned boilerplateSize = 81;
|
||||||
bytes expectation({byte(Instruction::JUMPDEST),
|
bytes expectation({byte(Instruction::JUMPDEST),
|
||||||
byte(Instruction::PUSH1), 0x0, // initialize return variable d
|
byte(Instruction::PUSH1), 0x0, // initialize return variable d
|
||||||
byte(Instruction::DUP3),
|
byte(Instruction::DUP3),
|
||||||
@ -158,8 +158,8 @@ BOOST_AUTO_TEST_CASE(ifStatement)
|
|||||||
"}\n";
|
"}\n";
|
||||||
bytes code = compileContract(sourceCode);
|
bytes code = compileContract(sourceCode);
|
||||||
|
|
||||||
unsigned shift = 29;
|
unsigned shift = 27;
|
||||||
unsigned boilerplateSize = 42;
|
unsigned boilerplateSize = 40;
|
||||||
bytes expectation({byte(Instruction::JUMPDEST),
|
bytes expectation({byte(Instruction::JUMPDEST),
|
||||||
byte(Instruction::PUSH1), 0x0,
|
byte(Instruction::PUSH1), 0x0,
|
||||||
byte(Instruction::DUP1),
|
byte(Instruction::DUP1),
|
||||||
@ -200,8 +200,8 @@ BOOST_AUTO_TEST_CASE(loops)
|
|||||||
"}\n";
|
"}\n";
|
||||||
bytes code = compileContract(sourceCode);
|
bytes code = compileContract(sourceCode);
|
||||||
|
|
||||||
unsigned shift = 29;
|
unsigned shift = 27;
|
||||||
unsigned boilerplateSize = 42;
|
unsigned boilerplateSize = 40;
|
||||||
bytes expectation({byte(Instruction::JUMPDEST),
|
bytes expectation({byte(Instruction::JUMPDEST),
|
||||||
byte(Instruction::JUMPDEST),
|
byte(Instruction::JUMPDEST),
|
||||||
byte(Instruction::PUSH1), 0x1,
|
byte(Instruction::PUSH1), 0x1,
|
||||||
|
@ -363,6 +363,48 @@ BOOST_AUTO_TEST_CASE(small_signed_types)
|
|||||||
testSolidityAgainstCpp(0, small_signed_types_cpp);
|
testSolidityAgainstCpp(0, small_signed_types_cpp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(strings)
|
||||||
|
{
|
||||||
|
char const* sourceCode = "contract test {\n"
|
||||||
|
" function fixed() returns(string32 ret) {\n"
|
||||||
|
" return \"abc\\x00\\xff__\";\n"
|
||||||
|
" }\n"
|
||||||
|
" function pipeThrough(string2 small, bool one) returns(string16 large, bool oneRet) {\n"
|
||||||
|
" oneRet = one;\n"
|
||||||
|
" large = small;\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n";
|
||||||
|
compileAndRun(sourceCode);
|
||||||
|
bytes expectation(32, 0);
|
||||||
|
expectation[0] = byte('a');
|
||||||
|
expectation[1] = byte('b');
|
||||||
|
expectation[2] = byte('c');
|
||||||
|
expectation[3] = byte(0);
|
||||||
|
expectation[4] = byte(0xff);
|
||||||
|
expectation[5] = byte('_');
|
||||||
|
expectation[6] = byte('_');
|
||||||
|
BOOST_CHECK(callContractFunction(0, bytes()) == expectation);
|
||||||
|
expectation = bytes(17, 0);
|
||||||
|
expectation[0] = 0;
|
||||||
|
expectation[1] = 2;
|
||||||
|
expectation[16] = 1;
|
||||||
|
BOOST_CHECK(callContractFunction(1, bytes({0x00, 0x02, 0x01})) == expectation);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(empty_string_on_stack)
|
||||||
|
{
|
||||||
|
char const* sourceCode = "contract test {\n"
|
||||||
|
" function run(string0 empty, uint8 inp) returns(uint16 a, string0 b, string4 c) {\n"
|
||||||
|
" var x = \"abc\";\n"
|
||||||
|
" var y = \"\";\n"
|
||||||
|
" var z = inp;\n"
|
||||||
|
" a = z; b = y; c = x;"
|
||||||
|
" }\n"
|
||||||
|
"}\n";
|
||||||
|
compileAndRun(sourceCode);
|
||||||
|
BOOST_CHECK(callContractFunction(0, bytes({0x02})) == bytes({0x00, 0x02, 'a', 'b', 'c', 0x00}));
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(state_smoke_test)
|
BOOST_AUTO_TEST_CASE(state_smoke_test)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = "contract test {\n"
|
||||||
@ -942,6 +984,34 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_with_local_vars)
|
|||||||
BOOST_REQUIRE(callContractFunction(0, a, b) == toBigEndian(a * b + 9));
|
BOOST_REQUIRE(callContractFunction(0, a, b) == toBigEndian(a * b + 9));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(strings_in_calls)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
contract Helper {
|
||||||
|
function invoke(string3 x, bool stop) returns (string4 ret) {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
contract Main {
|
||||||
|
Helper h;
|
||||||
|
function callHelper(string2 x, bool stop) returns (string5 ret) {
|
||||||
|
return h.invoke(x, stop);
|
||||||
|
}
|
||||||
|
function getHelper() returns (address addr) {
|
||||||
|
return address(h);
|
||||||
|
}
|
||||||
|
function setHelper(address addr) {
|
||||||
|
h = Helper(addr);
|
||||||
|
}
|
||||||
|
})";
|
||||||
|
compileAndRun(sourceCode, 0, "Helper");
|
||||||
|
u160 const helperAddress = m_contractAddress;
|
||||||
|
compileAndRun(sourceCode, 0, "Main");
|
||||||
|
BOOST_REQUIRE(callContractFunction(2, helperAddress) == bytes());
|
||||||
|
BOOST_REQUIRE(callContractFunction(1, helperAddress) == toBigEndian(helperAddress));
|
||||||
|
BOOST_CHECK(callContractFunction(0, bytes({0, 'a', 1})) == bytes({0, 'a', 0, 0, 0}));
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ private:
|
|||||||
void sendMessage(bytes const& _data, bool _isCreation, u256 const& _value = 0)
|
void sendMessage(bytes const& _data, bool _isCreation, u256 const& _value = 0)
|
||||||
{
|
{
|
||||||
m_state.addBalance(m_sender, _value); // just in case
|
m_state.addBalance(m_sender, _value); // just in case
|
||||||
eth::Executive executive(m_state);
|
eth::Executive executive(m_state, 0);
|
||||||
eth::Transaction t = _isCreation ? eth::Transaction(_value, m_gasPrice, m_gas, _data, 0, KeyPair::create().sec())
|
eth::Transaction t = _isCreation ? eth::Transaction(_value, m_gasPrice, m_gas, _data, 0, KeyPair::create().sec())
|
||||||
: eth::Transaction(_value, m_gasPrice, m_gas, m_contractAddress, _data, 0, KeyPair::create().sec());
|
: eth::Transaction(_value, m_gasPrice, m_gas, m_contractAddress, _data, 0, KeyPair::create().sec());
|
||||||
bytes transactionRLP = t.rlp();
|
bytes transactionRLP = t.rlp();
|
||||||
@ -137,7 +137,7 @@ private:
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
BOOST_REQUIRE(m_state.addressHasCode(m_contractAddress));
|
BOOST_REQUIRE(m_state.addressHasCode(m_contractAddress));
|
||||||
BOOST_REQUIRE(!executive.call(m_contractAddress, m_sender, _value, m_gasPrice, &_data, m_gas, m_sender));
|
BOOST_REQUIRE(!executive.call(m_contractAddress, m_contractAddress, m_sender, _value, m_gasPrice, &_data, m_gas, m_sender));
|
||||||
}
|
}
|
||||||
BOOST_REQUIRE(executive.go());
|
BOOST_REQUIRE(executive.go());
|
||||||
m_state.noteSending(m_sender);
|
m_state.noteSending(m_sender);
|
||||||
|
@ -226,6 +226,14 @@ BOOST_AUTO_TEST_CASE(type_inference_explicit_conversion)
|
|||||||
BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
|
BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(large_string_literal)
|
||||||
|
{
|
||||||
|
char const* text = "contract test {\n"
|
||||||
|
" function f() { var x = \"123456789012345678901234567890123\"; }"
|
||||||
|
"}\n";
|
||||||
|
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(balance)
|
BOOST_AUTO_TEST_CASE(balance)
|
||||||
{
|
{
|
||||||
char const* text = "contract test {\n"
|
char const* text = "contract test {\n"
|
||||||
|
@ -48,7 +48,7 @@ public:
|
|||||||
m_optimize = true;
|
m_optimize = true;
|
||||||
bytes optimizedBytecode = compileAndRun(_sourceCode, _value, _contractName);
|
bytes optimizedBytecode = compileAndRun(_sourceCode, _value, _contractName);
|
||||||
int sizeDiff = nonOptimizedBytecode.size() - optimizedBytecode.size();
|
int sizeDiff = nonOptimizedBytecode.size() - optimizedBytecode.size();
|
||||||
BOOST_CHECK_MESSAGE(sizeDiff >= _expectedSizeDecrease, "Bytecode did only shrink by "
|
BOOST_CHECK_MESSAGE(sizeDiff == int(_expectedSizeDecrease), "Bytecode did only shrink by "
|
||||||
+ boost::lexical_cast<string>(sizeDiff) + " bytes, expected: "
|
+ boost::lexical_cast<string>(sizeDiff) + " bytes, expected: "
|
||||||
+ boost::lexical_cast<string>(_expectedSizeDecrease));
|
+ boost::lexical_cast<string>(_expectedSizeDecrease));
|
||||||
m_optimizedContract = m_contractAddress;
|
m_optimizedContract = m_contractAddress;
|
||||||
@ -106,7 +106,7 @@ BOOST_AUTO_TEST_CASE(invariants)
|
|||||||
return (((a + (1 - 1)) ^ 0) | 0) & (uint(0) - 1);
|
return (((a + (1 - 1)) ^ 0) | 0) & (uint(0) - 1);
|
||||||
}
|
}
|
||||||
})";
|
})";
|
||||||
compileBothVersions(19, sourceCode);
|
compileBothVersions(28, sourceCode);
|
||||||
compareVersions(0, u256(0x12334664));
|
compareVersions(0, u256(0x12334664));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,6 +124,21 @@ BOOST_AUTO_TEST_CASE(unused_expressions)
|
|||||||
compareVersions(0);
|
compareVersions(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(constant_folding_both_sides)
|
||||||
|
{
|
||||||
|
// if constants involving the same associative and commutative operator are applied from both
|
||||||
|
// sides, the operator should be applied only once, because the expression compiler
|
||||||
|
// (even in non-optimized mode) pushes literals as late as possible
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
contract test {
|
||||||
|
function f(uint x) returns (uint y) {
|
||||||
|
return 98 ^ (7 * ((1 | (x | 1000)) * 40) ^ 102);
|
||||||
|
}
|
||||||
|
})";
|
||||||
|
compileBothVersions(31, sourceCode);
|
||||||
|
compareVersions(0);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ void doStateTests(json_spirit::mValue& v, bool _fillin)
|
|||||||
{
|
{
|
||||||
for (auto& i: v.get_obj())
|
for (auto& i: v.get_obj())
|
||||||
{
|
{
|
||||||
cnote << i.first;
|
cerr << i.first << endl;
|
||||||
mObject& o = i.second.get_obj();
|
mObject& o = i.second.get_obj();
|
||||||
|
|
||||||
BOOST_REQUIRE(o.count("env") > 0);
|
BOOST_REQUIRE(o.count("env") > 0);
|
||||||
|
10
trie.cpp
10
trie.cpp
@ -54,13 +54,12 @@ BOOST_AUTO_TEST_CASE(trie_tests)
|
|||||||
{
|
{
|
||||||
string testPath = test::getTestPath();
|
string testPath = test::getTestPath();
|
||||||
|
|
||||||
|
|
||||||
testPath += "/TrieTests";
|
testPath += "/TrieTests";
|
||||||
|
|
||||||
cnote << "Testing Trie...";
|
cnote << "Testing Trie...";
|
||||||
js::mValue v;
|
js::mValue v;
|
||||||
string s = asString(contents(testPath + "/trietest.json"));
|
string s = asString(contents(testPath + "/trieanyorder.json"));
|
||||||
BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'trietest.json' is empty. Have you cloned the 'tests' repo branch develop?");
|
BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'trieanyorder.json' is empty. Have you cloned the 'tests' repo branch develop?");
|
||||||
js::read_string(s, v);
|
js::read_string(s, v);
|
||||||
for (auto& i: v.get_obj())
|
for (auto& i: v.get_obj())
|
||||||
{
|
{
|
||||||
@ -88,12 +87,11 @@ BOOST_AUTO_TEST_CASE(trie_tests)
|
|||||||
BOOST_REQUIRE(t.check(true));
|
BOOST_REQUIRE(t.check(true));
|
||||||
}
|
}
|
||||||
BOOST_REQUIRE(!o["root"].is_null());
|
BOOST_REQUIRE(!o["root"].is_null());
|
||||||
BOOST_CHECK_EQUAL(o["root"].get_str(), toHex(t.root().asArray()));
|
BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline h256 stringMapHash256(StringMap const& _s)
|
inline h256 stringMapHash256(StringMap const& _s)
|
||||||
{
|
{
|
||||||
return hash256(_s);
|
return hash256(_s);
|
||||||
@ -246,6 +244,7 @@ BOOST_AUTO_TEST_CASE(moreTrieTests)
|
|||||||
BOOST_AUTO_TEST_CASE(trieLowerBound)
|
BOOST_AUTO_TEST_CASE(trieLowerBound)
|
||||||
{
|
{
|
||||||
cnote << "Stress-testing Trie.lower_bound...";
|
cnote << "Stress-testing Trie.lower_bound...";
|
||||||
|
if (0)
|
||||||
{
|
{
|
||||||
MemoryDB dm;
|
MemoryDB dm;
|
||||||
EnforceRefs e(dm, true);
|
EnforceRefs e(dm, true);
|
||||||
@ -291,6 +290,7 @@ BOOST_AUTO_TEST_CASE(trieLowerBound)
|
|||||||
BOOST_AUTO_TEST_CASE(trieStess)
|
BOOST_AUTO_TEST_CASE(trieStess)
|
||||||
{
|
{
|
||||||
cnote << "Stress-testing Trie...";
|
cnote << "Stress-testing Trie...";
|
||||||
|
if (0)
|
||||||
{
|
{
|
||||||
MemoryDB m;
|
MemoryDB m;
|
||||||
MemoryDB dm;
|
MemoryDB dm;
|
||||||
|
16
vm.cpp
16
vm.cpp
@ -21,6 +21,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
#include <libethereum/Executive.h>
|
||||||
|
#include <libevm/VMFactory.h>
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -32,18 +34,18 @@ using namespace dev::test;
|
|||||||
FakeExtVM::FakeExtVM(eth::BlockInfo const& _previousBlock, eth::BlockInfo const& _currentBlock, unsigned _depth): /// TODO: XXX: remove the default argument & fix.
|
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, _depth) {}
|
ExtVMFace(Address(), Address(), Address(), 0, 1, bytesConstRef(), bytes(), _previousBlock, _currentBlock, _depth) {}
|
||||||
|
|
||||||
h160 FakeExtVM::create(u256 _endowment, u256* _gas, bytesConstRef _init, OnOpFunc const&)
|
h160 FakeExtVM::create(u256 _endowment, u256& io_gas, bytesConstRef _init, OnOpFunc const&)
|
||||||
{
|
{
|
||||||
Address na = right160(sha3(rlpList(myAddress, get<1>(addresses[myAddress]))));
|
Address na = right160(sha3(rlpList(myAddress, get<1>(addresses[myAddress]))));
|
||||||
|
|
||||||
Transaction t(_endowment, gasPrice, *_gas, _init.toBytes());
|
Transaction t(_endowment, gasPrice, io_gas, _init.toBytes());
|
||||||
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& io_gas, bytesRef _out, OnOpFunc const&, Address _myAddressOverride, Address _codeAddressOverride)
|
||||||
{
|
{
|
||||||
Transaction t(_value, gasPrice, *_gas, _receiveAddress, _data.toVector());
|
Transaction t(_value, gasPrice, io_gas, _receiveAddress, _data.toVector());
|
||||||
callcreates.push_back(t);
|
callcreates.push_back(t);
|
||||||
(void)_out;
|
(void)_out;
|
||||||
(void)_myAddressOverride;
|
(void)_myAddressOverride;
|
||||||
@ -298,14 +300,14 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bytes output;
|
bytes output;
|
||||||
VM vm(fev.gas);
|
auto vm = eth::VMFactory::create(fev.gas);
|
||||||
|
|
||||||
u256 gas;
|
u256 gas;
|
||||||
bool vmExceptionOccured = false;
|
bool vmExceptionOccured = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
output = vm.go(fev, fev.simpleTrace()).toBytes();
|
output = vm->go(fev, fev.simpleTrace()).toBytes();
|
||||||
gas = vm.gas();
|
gas = vm->gas();
|
||||||
}
|
}
|
||||||
catch (VMException const& _e)
|
catch (VMException const& _e)
|
||||||
{
|
{
|
||||||
|
4
vm.h
4
vm.h
@ -55,8 +55,8 @@ public:
|
|||||||
virtual u256 txCount(Address _a) override { return std::get<1>(addresses[_a]); }
|
virtual u256 txCount(Address _a) override { return std::get<1>(addresses[_a]); }
|
||||||
virtual void suicide(Address _a) override { std::get<0>(addresses[_a]) += std::get<0>(addresses[myAddress]); addresses.erase(myAddress); }
|
virtual void suicide(Address _a) override { std::get<0>(addresses[_a]) += std::get<0>(addresses[myAddress]); addresses.erase(myAddress); }
|
||||||
virtual bytes const& codeAt(Address _a) override { return std::get<3>(addresses[_a]); }
|
virtual bytes const& codeAt(Address _a) override { return std::get<3>(addresses[_a]); }
|
||||||
virtual h160 create(u256 _endowment, u256* _gas, bytesConstRef _init, eth::OnOpFunc const&) override;
|
virtual h160 create(u256 _endowment, u256& io_gas, bytesConstRef _init, eth::OnOpFunc const&) override;
|
||||||
virtual bool call(Address _receiveAddress, u256 _value, bytesConstRef _data, u256* _gas, bytesRef _out, eth::OnOpFunc const&, Address, Address) override;
|
virtual bool call(Address _receiveAddress, u256 _value, bytesConstRef _data, u256& io_gas, bytesRef _out, eth::OnOpFunc const&, Address, Address) override;
|
||||||
void setTransaction(Address _caller, u256 _value, u256 _gasPrice, bytes const& _data);
|
void setTransaction(Address _caller, u256 _value, u256 _gasPrice, bytes const& _data);
|
||||||
void setContract(Address _myAddress, u256 _myBalance, u256 _myNonce, std::map<u256, u256> const& _storage, bytes const& _code);
|
void setContract(Address _myAddress, u256 _myBalance, u256 _myNonce, std::map<u256, u256> const& _storage, bytes const& _code);
|
||||||
void set(Address _a, u256 _myBalance, u256 _myNonce, std::map<u256, u256> const& _storage, bytes const& _code);
|
void set(Address _a, u256 _myBalance, u256 _myNonce, std::map<u256, u256> const& _storage, bytes const& _code);
|
||||||
|
@ -32,7 +32,9 @@ BOOST_AUTO_TEST_SUITE(whisper)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(topic)
|
BOOST_AUTO_TEST_CASE(topic)
|
||||||
{
|
{
|
||||||
g_logVerbosity = 20;
|
cnote << "Testing Whisper...";
|
||||||
|
auto oldLogVerbosity = g_logVerbosity;
|
||||||
|
g_logVerbosity = 0;
|
||||||
|
|
||||||
bool started = false;
|
bool started = false;
|
||||||
unsigned result = 0;
|
unsigned result = 0;
|
||||||
@ -80,7 +82,7 @@ BOOST_AUTO_TEST_CASE(topic)
|
|||||||
}
|
}
|
||||||
|
|
||||||
listener.join();
|
listener.join();
|
||||||
g_logVerbosity = 0;
|
g_logVerbosity = oldLogVerbosity;
|
||||||
|
|
||||||
BOOST_REQUIRE_EQUAL(result, 1 + 9 + 25 + 49 + 81);
|
BOOST_REQUIRE_EQUAL(result, 1 + 9 + 25 + 49 + 81);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user