mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #760 from CJentzsch/blockhash
add blockhash test as vm tests
This commit is contained in:
commit
577220185f
@ -489,4 +489,12 @@ void processCommandLineOptions()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LastHashes lastHashes(u256 _currentBlockNumber)
|
||||||
|
{
|
||||||
|
LastHashes ret;
|
||||||
|
for (u256 i = 1; i <= 256 && i <= _currentBlockNumber; ++i)
|
||||||
|
ret.push_back(sha3(toString(_currentBlockNumber - i)));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
} } // namespaces
|
} } // namespaces
|
||||||
|
@ -77,6 +77,7 @@ void executeTests(const std::string& _name, const std::string& _testPathAppendix
|
|||||||
std::string getTestPath();
|
std::string getTestPath();
|
||||||
void userDefinedTest(std::string testTypeFlag, std::function<void(json_spirit::mValue&, bool)> doTests);
|
void userDefinedTest(std::string testTypeFlag, std::function<void(json_spirit::mValue&, bool)> doTests);
|
||||||
void processCommandLineOptions();
|
void processCommandLineOptions();
|
||||||
|
eth::LastHashes lastHashes(u256 _currentBlockNumber);
|
||||||
|
|
||||||
template<typename mapType>
|
template<typename mapType>
|
||||||
void checkAddresses(mapType& _expectedAddrs, mapType& _resultAddrs)
|
void checkAddresses(mapType& _expectedAddrs, mapType& _resultAddrs)
|
||||||
|
10
state.cpp
10
state.cpp
@ -39,16 +39,6 @@ using namespace dev::eth;
|
|||||||
|
|
||||||
namespace dev { namespace test {
|
namespace dev { namespace test {
|
||||||
|
|
||||||
LastHashes lastHashes(u256 _currentBlockNumber)
|
|
||||||
{
|
|
||||||
LastHashes ret;
|
|
||||||
for (u256 i = 1; i <= 256 && i <= _currentBlockNumber; ++i)
|
|
||||||
ret.push_back(sha3(toString(_currentBlockNumber - i)));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void doStateTests(json_spirit::mValue& v, bool _fillin)
|
void doStateTests(json_spirit::mValue& v, bool _fillin)
|
||||||
{
|
{
|
||||||
processCommandLineOptions();
|
processCommandLineOptions();
|
||||||
|
3
vm.cpp
3
vm.cpp
@ -33,7 +33,7 @@ using namespace dev::eth;
|
|||||||
using namespace dev::test;
|
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, LastHashes(), _depth) {}
|
ExtVMFace(Address(), Address(), Address(), 0, 1, bytesConstRef(), bytes(), _previousBlock, _currentBlock, test::lastHashes(_currentBlock.number), _depth) {}
|
||||||
|
|
||||||
h160 FakeExtVM::create(u256 _endowment, u256& io_gas, bytesConstRef _init, OnOpFunc const&)
|
h160 FakeExtVM::create(u256 _endowment, u256& io_gas, bytesConstRef _init, OnOpFunc const&)
|
||||||
{
|
{
|
||||||
@ -117,6 +117,7 @@ void FakeExtVM::importEnv(mObject& _o)
|
|||||||
|
|
||||||
previousBlock.hash = h256(_o["previousHash"].get_str());
|
previousBlock.hash = h256(_o["previousHash"].get_str());
|
||||||
currentBlock.number = toInt(_o["currentNumber"]);
|
currentBlock.number = toInt(_o["currentNumber"]);
|
||||||
|
lastHashes = test::lastHashes(currentBlock.number);
|
||||||
currentBlock.gasLimit = toInt(_o["currentGasLimit"]);
|
currentBlock.gasLimit = toInt(_o["currentGasLimit"]);
|
||||||
currentBlock.difficulty = toInt(_o["currentDifficulty"]);
|
currentBlock.difficulty = toInt(_o["currentDifficulty"]);
|
||||||
currentBlock.timestamp = toInt(_o["currentTimestamp"]);
|
currentBlock.timestamp = toInt(_o["currentTimestamp"]);
|
||||||
|
@ -111,6 +111,62 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"blockhashInRange": {
|
||||||
|
"env" : {
|
||||||
|
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
|
||||||
|
"currentNumber" : "257",
|
||||||
|
"currentGasLimit" : "1000000",
|
||||||
|
"currentDifficulty" : "256",
|
||||||
|
"currentTimestamp" : 1,
|
||||||
|
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
|
||||||
|
},
|
||||||
|
"pre" : {
|
||||||
|
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
|
||||||
|
"balance" : "1000000000000000000",
|
||||||
|
"nonce" : 0,
|
||||||
|
"code" : "{ [[ 0 ]] (BLOCKHASH 1) [[ 1 ]] (BLOCKHASH 2) [[ 2 ]] (BLOCKHASH 256) }",
|
||||||
|
"storage": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"exec" : {
|
||||||
|
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
|
||||||
|
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
|
||||||
|
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
|
||||||
|
"value" : "1000000000000000000",
|
||||||
|
"data" : "",
|
||||||
|
"gasPrice" : "100000000000000",
|
||||||
|
"gas" : "10000"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"blockhashOutOfRange": {
|
||||||
|
"env" : {
|
||||||
|
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
|
||||||
|
"currentNumber" : "257",
|
||||||
|
"currentGasLimit" : "1000000",
|
||||||
|
"currentDifficulty" : "256",
|
||||||
|
"currentTimestamp" : 1,
|
||||||
|
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
|
||||||
|
},
|
||||||
|
"pre" : {
|
||||||
|
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
|
||||||
|
"balance" : "1000000000000000000",
|
||||||
|
"nonce" : 0,
|
||||||
|
"code" : "{ [[ 0 ]] (BLOCKHASH 0) [[ 1 ]] (BLOCKHASH 257) [[ 2 ]] (BLOCKHASH 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }",
|
||||||
|
"storage": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"exec" : {
|
||||||
|
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
|
||||||
|
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
|
||||||
|
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
|
||||||
|
"value" : "1000000000000000000",
|
||||||
|
"data" : "",
|
||||||
|
"gasPrice" : "100000000000000",
|
||||||
|
"gas" : "10000"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
"coinbase": {
|
"coinbase": {
|
||||||
"env" : {
|
"env" : {
|
||||||
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
|
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
|
||||||
|
Loading…
Reference in New Issue
Block a user