diff options
author | CJentzsch <jentzsch.software@gmail.com> | 2015-04-06 14:52:20 +0800 |
---|---|---|
committer | CJentzsch <jentzsch.software@gmail.com> | 2015-04-06 14:52:20 +0800 |
commit | 8921dc0de43536cf94c43647282fb379a57888e9 (patch) | |
tree | 6962afc549ff26fc201e46b679e4372e6b79b261 /blockchain.cpp | |
parent | 24ffe848054aa1908c47af3da9bbe598f609b672 (diff) | |
download | dexon-solidity-8921dc0de43536cf94c43647282fb379a57888e9.tar dexon-solidity-8921dc0de43536cf94c43647282fb379a57888e9.tar.gz dexon-solidity-8921dc0de43536cf94c43647282fb379a57888e9.tar.bz2 dexon-solidity-8921dc0de43536cf94c43647282fb379a57888e9.tar.lz dexon-solidity-8921dc0de43536cf94c43647282fb379a57888e9.tar.xz dexon-solidity-8921dc0de43536cf94c43647282fb379a57888e9.tar.zst dexon-solidity-8921dc0de43536cf94c43647282fb379a57888e9.zip |
uncle with same block number + uncle header validity
Diffstat (limited to 'blockchain.cpp')
-rw-r--r-- | blockchain.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/blockchain.cpp b/blockchain.cpp index ffb55da3..619f1665 100644 --- a/blockchain.cpp +++ b/blockchain.cpp @@ -126,6 +126,12 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) vBiUncles.push_back(vBiBlocks[(size_t)toInt(uncleHeaderObj["sameAsBlock"])]); continue; } + string overwrite = "false"; + if (uncleHeaderObj.count("overwriteAndRedoPoW")) + { + overwrite = uncleHeaderObj["overwriteAndRedoPoW"].get_str(); + uncleHeaderObj.erase("overwriteAndRedoPoW"); + } BlockInfo uncleBlockFromFields = constructBlock(uncleHeaderObj); @@ -141,6 +147,17 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) else continue; + if (overwrite != "false") + { + cout << "overwrite:" << overwrite << endl; + uncleBlockFromFields.difficulty = overwrite == "difficulty" ? toInt(uncleHeaderObj["difficulty"]) : uncleBlockFromFields.difficulty; + uncleBlockFromFields.gasLimit = overwrite == "gasLimit" ? toInt(uncleHeaderObj["gasLimit"]) : uncleBlockFromFields.gasLimit; + uncleBlockFromFields.gasUsed = overwrite == "gasUsed" ? toInt(uncleHeaderObj["gasUsed"]) : uncleBlockFromFields.gasUsed; + uncleBlockFromFields.parentHash = overwrite == "parentHash" ? h256(uncleHeaderObj["parentHash"].get_str()) : uncleBlockFromFields.parentHash; + uncleBlockFromFields.stateRoot = overwrite == "stateRoot" ? h256(uncleHeaderObj["stateRoot"].get_str()) : uncleBlockFromFields.stateRoot; + uncleBlockFromFields.timestamp = overwrite == "timestamp" ? toInt(uncleHeaderObj["timestamp"]) : uncleBlockFromFields.timestamp; + } + updatePoW(uncleBlockFromFields); writeBlockHeaderToJson(uncleHeaderObj, uncleBlockFromFields); @@ -148,8 +165,16 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) vBiUncles.push_back(uncleBlockFromFields); cnote << "import uncle in blockQueue"; + RLPStream uncle = createFullBlockFromHeader(uncleBlockFromFields); - uncleBlockQueue.import(&uncle.out(), bc); + try + { + uncleBlockQueue.import(&uncle.out(), bc); + } + catch(...) + { + cout << "error in importing uncle" << endl; + } uncleHeaderObj_pre = uncleHeaderObj; } @@ -402,7 +427,6 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) for (auto const& uBlHeaderObj: blObj["uncleHeaders"].get_array()) { mObject uBlH = uBlHeaderObj.get_obj(); - cout << "uBlH.size(): " << uBlH.size() << endl; BOOST_REQUIRE(uBlH.size() == 16); bytes uncleRLP = createBlockRLPFromFields(uBlH); const RLP c_uRLP(uncleRLP); @@ -664,6 +688,11 @@ BOOST_AUTO_TEST_CASE(bcUncleTest) dev::test::executeTests("bcUncleTest", "/BlockTests", dev::test::doBlockchainTests); } +BOOST_AUTO_TEST_CASE(bcUncleHeaderValiditiy) +{ + dev::test::executeTests("bcUncleHeaderValiditiy", "/BlockTests", dev::test::doBlockchainTests); +} + BOOST_AUTO_TEST_CASE(userDefinedFile) { dev::test::userDefinedTest("--singletest", dev::test::doBlockchainTests); |