mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
AllFieldsHex: State Tests
This commit is contained in:
parent
968ebf6dbc
commit
bfa1e9b7b9
@ -102,7 +102,6 @@ struct ValueTooLarge: virtual Exception {};
|
||||
struct MissingFields : virtual Exception {};
|
||||
|
||||
bigint const c_max256plus1 = bigint(1) << 256;
|
||||
|
||||
ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller):
|
||||
m_statePre(OverlayDB(), eth::BaseState::Empty, Address(_o["env"].get_obj()["currentCoinbase"].get_str())),
|
||||
m_statePost(OverlayDB(), eth::BaseState::Empty, Address(_o["env"].get_obj()["currentCoinbase"].get_str())),
|
||||
@ -119,6 +118,27 @@ ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller):
|
||||
}
|
||||
}
|
||||
|
||||
json_spirit::mObject& ImportTest::makeAllFieldsHex(json_spirit::mObject& _o)
|
||||
{
|
||||
for (json_spirit::mObject::iterator it = _o.begin(); it != _o.end(); it++)
|
||||
{
|
||||
string key = (*it).first;
|
||||
if (key == "to")
|
||||
continue;
|
||||
|
||||
string str = (*it).second.get_str();
|
||||
_o[key] = (str.substr(0, 2) == "0x" ||
|
||||
str.find("a") != string::npos ||
|
||||
str.find("b") != string::npos ||
|
||||
str.find("c") != string::npos ||
|
||||
str.find("d") != string::npos ||
|
||||
str.find("e") != string::npos ||
|
||||
str.find("f") != string::npos
|
||||
) ? str : "0x" + toHex(toCompactBigEndian(toInt(str)));
|
||||
}
|
||||
return _o;
|
||||
}
|
||||
|
||||
void ImportTest::importEnv(json_spirit::mObject& _o)
|
||||
{
|
||||
assert(_o.count("previousHash") > 0);
|
||||
@ -325,6 +345,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 +357,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))
|
||||
|
@ -121,6 +121,7 @@ public:
|
||||
static void importState(json_spirit::mObject& _o, eth::State& _state);
|
||||
static void importState(json_spirit::mObject& _o, eth::State& _state, stateOptionsMap& _stateOptionsMap);
|
||||
void importTransaction(json_spirit::mObject& _o);
|
||||
static json_spirit::mObject& makeAllFieldsHex(json_spirit::mObject& _o);
|
||||
|
||||
void exportTest(bytes const& _output, eth::State const& _statePost);
|
||||
static void checkExpectedState(eth::State const& _stateExpect, eth::State const& _statePost, stateOptionsMap const _expectedStateOptions = stateOptionsMap(), WhenError _throw = WhenError::Throw);
|
||||
|
@ -5,7 +5,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "1000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -42,7 +42,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "1000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -85,7 +85,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "1000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -128,7 +128,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "1000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -167,7 +167,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "1000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -207,7 +207,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "1000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -280,7 +280,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "1100",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -316,7 +316,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "22000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -370,7 +370,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "47766",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -424,7 +424,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "220000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -479,7 +479,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "21100",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -515,7 +515,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "21100",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -552,7 +552,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "10000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -609,7 +609,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "100000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -678,7 +678,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "1000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -761,7 +761,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "1000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -834,7 +834,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "10000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -925,7 +925,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "10000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -1003,7 +1003,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "1000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -1056,7 +1056,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "1000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -1110,7 +1110,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "1000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -1170,7 +1170,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "10000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -1226,7 +1226,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "100000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -1284,7 +1284,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "1000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -1333,7 +1333,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "1000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"post" : {
|
||||
@ -1381,7 +1381,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "1000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -1417,7 +1417,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "100000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -1453,7 +1453,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "10000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -1490,7 +1490,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "10000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -1533,7 +1533,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "100000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -1570,7 +1570,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "10000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -1613,7 +1613,7 @@
|
||||
"currentGasLimit" : "(2**256)-1",
|
||||
"currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -1655,7 +1655,7 @@
|
||||
"currentGasLimit" : "(2**256)-1",
|
||||
"currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -1695,7 +1695,7 @@
|
||||
"currentGasLimit" : "(2**256)-1",
|
||||
"currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -1733,7 +1733,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "100000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -1769,7 +1769,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "1000000000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -1806,7 +1806,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "1000000000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -1846,7 +1846,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "1000000000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
@ -1894,7 +1894,7 @@
|
||||
"currentDifficulty" : "45678256",
|
||||
"currentGasLimit" : "1000000000000",
|
||||
"currentNumber" : "0",
|
||||
"currentTimestamp" : 1,
|
||||
"currentTimestamp" : "1",
|
||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"expect" : {
|
||||
|
@ -40,6 +40,7 @@ void doTransactionTests(json_spirit::mValue& _v, bool _fillin)
|
||||
{
|
||||
BOOST_REQUIRE(o.count("transaction") > 0);
|
||||
mObject tObj = o["transaction"].get_obj();
|
||||
o["transaction"] = ImportTest::makeAllFieldsHex(tObj);
|
||||
|
||||
//Construct Rlp of the given transaction
|
||||
RLPStream rlpStream = createRLPStreamFromTransactionFields(tObj);
|
||||
|
Loading…
Reference in New Issue
Block a user