aboutsummaryrefslogtreecommitdiffstats
path: root/TestHelper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TestHelper.cpp')
-rw-r--r--TestHelper.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/TestHelper.cpp b/TestHelper.cpp
index 355a5080..5a579702 100644
--- a/TestHelper.cpp
+++ b/TestHelper.cpp
@@ -115,7 +115,7 @@ void ImportTest::importState(json_spirit::mObject& _o, State& _state)
if (code.size())
{
_state.m_cache[address] = Account(toInt(o["balance"]), Account::ContractConception);
- _state.m_cache[address].setCode(bytesConstRef(&code));
+ _state.m_cache[address].setCode(code);
}
else
_state.m_cache[address] = Account(toInt(o["balance"]), Account::NormalCreation);
@@ -228,18 +228,19 @@ byte toByte(json_spirit::mValue const& _v)
return 0;
}
+bytes importByteArray(std::string const& _str)
+{
+ return fromHex(_str.substr(0, 2) == "0x" ? _str.substr(2) : _str);
+}
+
bytes importData(json_spirit::mObject& _o)
{
bytes data;
if (_o["data"].type() == json_spirit::str_type)
- if (_o["data"].get_str().find_first_of("0x") == 0)
- data = fromHex(_o["data"].get_str().substr(2));
- else
- data = fromHex(_o["data"].get_str());
+ data = importByteArray(_o["data"].get_str());
else
for (auto const& j: _o["data"].get_array())
data.push_back(toByte(j));
-
return data;
}