diff options
author | CJentzsch <jentzsch.software@gmail.com> | 2015-01-07 03:57:33 +0800 |
---|---|---|
committer | CJentzsch <jentzsch.software@gmail.com> | 2015-01-07 03:57:33 +0800 |
commit | a8d472f5ab83cc7e11cf838e335b8b26f658927b (patch) | |
tree | c8e51e41df93a704139f4e3b52b04ca9baa942d3 | |
parent | ecf3c0bb324b328b562408a5605aa33c6bfca9f4 (diff) | |
download | dexon-solidity-a8d472f5ab83cc7e11cf838e335b8b26f658927b.tar dexon-solidity-a8d472f5ab83cc7e11cf838e335b8b26f658927b.tar.gz dexon-solidity-a8d472f5ab83cc7e11cf838e335b8b26f658927b.tar.bz2 dexon-solidity-a8d472f5ab83cc7e11cf838e335b8b26f658927b.tar.lz dexon-solidity-a8d472f5ab83cc7e11cf838e335b8b26f658927b.tar.xz dexon-solidity-a8d472f5ab83cc7e11cf838e335b8b26f658927b.tar.zst dexon-solidity-a8d472f5ab83cc7e11cf838e335b8b26f658927b.zip |
Blockhash tests
-rw-r--r-- | stBlockHashTestFiller.json | 103 | ||||
-rw-r--r-- | state.cpp | 15 |
2 files changed, 117 insertions, 1 deletions
diff --git a/stBlockHashTestFiller.json b/stBlockHashTestFiller.json new file mode 100644 index 00000000..ccbff5d2 --- /dev/null +++ b/stBlockHashTestFiller.json @@ -0,0 +1,103 @@ +{ + "blockhash0" : { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "5", + "currentGasLimit" : "1000000", + "currentDifficulty" : "256", + "currentTimestamp" : 1, + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000000", + "nonce" : 0, + "code" : "{ [[ 0 ]] (BLOCKHASH 0) [[ 1 ]] (BLOCKHASH 5) [[ 2 ]] (BLOCKHASH 4) }", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "100000", + "nonce" : 0, + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "8500", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "blockhashOutOfRange" : { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "257", + "currentGasLimit" : "1000000", + "currentDifficulty" : "256", + "currentTimestamp" : 1, + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000000", + "nonce" : 0, + "code" : "{ [[ 0 ]] (BLOCKHASH 0) [[ 1 ]] (BLOCKHASH 257) [[ 2 ]] (BLOCKHASH 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "100000", + "nonce" : 0, + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "8500", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "blockhashInRange" : { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "257", + "currentGasLimit" : "1000000", + "currentDifficulty" : "256", + "currentTimestamp" : 1, + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "1000000000000000000", + "nonce" : 0, + "code" : "{ [[ 0 ]] (BLOCKHASH 1) [[ 1 ]] (BLOCKHASH 2) [[ 2 ]] (BLOCKHASH 256) }", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "100000", + "nonce" : 0, + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "8500", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + } +} @@ -39,6 +39,14 @@ using namespace dev::eth; 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) @@ -62,7 +70,7 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) try { - theState.execute(LastHashes(), tx, &output); + theState.execute(lastHashes(importer.m_environment.currentBlock.number), tx, &output); } catch (Exception const& _e) { @@ -157,6 +165,11 @@ BOOST_AUTO_TEST_CASE(stRefundTest) dev::test::executeTests("stRefundTest", "/StateTests", dev::test::doStateTests); } +BOOST_AUTO_TEST_CASE(stBlockHashTest) +{ + dev::test::executeTests("stBlockHashTest", "/StateTests", dev::test::doStateTests); +} + BOOST_AUTO_TEST_CASE(stCreateTest) { for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) |