aboutsummaryrefslogtreecommitdiffstats
path: root/TestHelper.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-04-17 22:24:23 +0800
committerchriseth <c@ethdev.com>2015-04-17 22:24:23 +0800
commit6b08b99b5ef319837f9293cca6fd74803fe4688d (patch)
treefe3e39ec2f14e1c52137c9734da36766ba57ba53 /TestHelper.cpp
parent6753e0a8e6796e99ee826c28c7bcbde55348b07d (diff)
parent7571971ca05fd12e3603531044e094ffc0000fb2 (diff)
downloaddexon-solidity-6b08b99b5ef319837f9293cca6fd74803fe4688d.tar
dexon-solidity-6b08b99b5ef319837f9293cca6fd74803fe4688d.tar.gz
dexon-solidity-6b08b99b5ef319837f9293cca6fd74803fe4688d.tar.bz2
dexon-solidity-6b08b99b5ef319837f9293cca6fd74803fe4688d.tar.lz
dexon-solidity-6b08b99b5ef319837f9293cca6fd74803fe4688d.tar.xz
dexon-solidity-6b08b99b5ef319837f9293cca6fd74803fe4688d.tar.zst
dexon-solidity-6b08b99b5ef319837f9293cca6fd74803fe4688d.zip
Merge remote-tracking branch 'ethereum/develop' into sol_overloadingFunctions
Diffstat (limited to 'TestHelper.cpp')
-rw-r--r--TestHelper.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/TestHelper.cpp b/TestHelper.cpp
index 93c564e6..92a8258a 100644
--- a/TestHelper.cpp
+++ b/TestHelper.cpp
@@ -119,6 +119,32 @@ ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller):
}
}
+json_spirit::mObject& ImportTest::makeAllFieldsHex(json_spirit::mObject& _o)
+{
+ static const set<string> hashes {"bloom" , "coinbase", "hash", "mixHash", "parentHash", "receiptTrie",
+ "stateRoot", "transactionsTrie", "uncleHash", "currentCoinbase",
+ "previousHash", "to", "address", "caller", "origin", "secretKey"};
+
+ for (auto& i: _o)
+ {
+ std::string key = i.first;
+ if (hashes.count(key))
+ continue;
+
+ std::string str;
+ json_spirit::mValue value = i.second;
+
+ if (value.type() == json_spirit::int_type)
+ str = toString(value.get_int());
+ else if (value.type() == json_spirit::str_type)
+ str = value.get_str();
+ else continue;
+
+ _o[key] = (str.substr(0, 2) == "0x") ? str : "0x" + toHex(toCompactBigEndian(toInt(str)));
+ }
+ return _o;
+}
+
void ImportTest::importEnv(json_spirit::mObject& _o)
{
assert(_o.count("previousHash") > 0);
@@ -325,6 +351,8 @@ void ImportTest::exportTest(bytes const& _output, State const& _statePost)
// export pre state
m_TestObject["pre"] = fillJsonWithState(m_statePre);
+ m_TestObject["env"] = makeAllFieldsHex(m_TestObject["env"].get_obj());
+ m_TestObject["transaction"] = makeAllFieldsHex(m_TestObject["transaction"].get_obj());
}
json_spirit::mObject fillJsonWithState(State _state)
@@ -335,8 +363,8 @@ json_spirit::mObject fillJsonWithState(State _state)
for (auto const& a: _state.addresses())
{
json_spirit::mObject o;
- o["balance"] = toString(_state.balance(a.first));
- o["nonce"] = toString(_state.transactionsFrom(a.first));
+ o["balance"] = "0x" + toHex(toCompactBigEndian(_state.balance(a.first)));
+ o["nonce"] = "0x" + toHex(toCompactBigEndian(_state.transactionsFrom(a.first)));
{
json_spirit::mObject store;
for (auto const& s: _state.storage(a.first))