Browse Source

Even numbers of hex digits for Jeff (Go can't handle odd numbers).

Everything a string in VM tests.
cl-refactor
Gav Wood 10 years ago
parent
commit
a94a559d64
  1. 2
      alethzero/MainWin.cpp
  2. 4
      libethential/CommonData.h
  3. 13
      test/vm.cpp

2
alethzero/MainWin.cpp

@ -1338,7 +1338,7 @@ void Main::on_dumpTrace_triggered()
ofstream f(fn.toStdString());
if (f.is_open())
for (WorldState const& ws: m_history)
f << ws.cur << " " << hex << (int)ws.curPC << " " << hex << (int)(byte)ws.inst << " " << hex << (uint64_t)ws.gas << endl;
f << ws.cur << " " << hex << toHex(eth::toCompactBigEndian(ws.curPC, 1)) << " " << hex << toHex(eth::toCompactBigEndian((int)(byte)ws.inst, 1)) << " " << hex << toHex(eth::toCompactBigEndian((uint64_t)ws.gas, 1)) << endl;
}
void Main::on_callStack_currentItemChanged()

4
libethential/CommonData.h

@ -108,11 +108,11 @@ inline bytes toBigEndian(u160 _val) { bytes ret(20); toBigEndian(_val, ret); ret
/// Convenience function for toBigEndian.
/// @returns a byte array just big enough to represent @a _val.
template <class _T>
inline bytes toCompactBigEndian(_T _val)
inline bytes toCompactBigEndian(_T _val, unsigned _min = 0)
{
int i = 0;
for (_T v = _val; v; ++i, v >>= 8) {}
bytes ret(i, 0);
bytes ret(std::max<unsigned>(_min, i), 0);
toBigEndian(_val, ret);
return ret;
}

13
test/vm.cpp

@ -154,17 +154,17 @@ public:
static void push(mObject& o, string const& _n, u256 _v)
{
if (_v < (u256)1 << 64)
o[_n] = (uint64_t)_v;
else
// if (_v < (u256)1 << 64)
// o[_n] = (uint64_t)_v;
// else
o[_n] = toString(_v);
}
static void push(mArray& a, u256 _v)
{
if (_v < (u256)1 << 64)
a.push_back((uint64_t)_v);
else
// if (_v < (u256)1 << 64)
// a.push_back((uint64_t)_v);
// else
a.push_back(toString(_v));
}
@ -405,6 +405,7 @@ void doTests(json_spirit::mValue& v, bool _fillin)
if (_fillin)
{
o["env"] = mValue(fev.exportEnv());
o["exec"] = mValue(fev.exportExec());
o["post"] = mValue(fev.exportState());
o["callcreates"] = fev.exportCallCreates();

Loading…
Cancel
Save