From f791f90e1260fb55fe77a666d8a25d87224d2608 Mon Sep 17 00:00:00 2001 From: arkpar Date: Fri, 24 Jul 2015 19:53:23 +0200 Subject: [PATCH] more tests fixed --- test/TestHelper.cpp | 2 ++ test/libethereum/blockchain.cpp | 31 +++++++++++++++++-------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/test/TestHelper.cpp b/test/TestHelper.cpp index d7c8d3333..ab9a17495 100644 --- a/test/TestHelper.cpp +++ b/test/TestHelper.cpp @@ -69,6 +69,7 @@ void mine(State& s, BlockChain const& _bc) sealer->onSealGenerated([&](bytes const& sealedHeader){ sealed = sealedHeader; }); sealer->generateSeal(s.info()); sealed.waitNot({}); + sealer.reset(); s.sealBlock(sealed); } @@ -79,6 +80,7 @@ void mine(Ethash::BlockHeader& _bi) sealer->onSealGenerated([&](bytes const& sealedHeader){ sealed = sealedHeader; }); sealer->generateSeal(_bi); sealed.waitNot({}); + sealer.reset(); _bi = Ethash::BlockHeader(sealed, IgnoreSeal, h256{}, HeaderData); } diff --git a/test/libethereum/blockchain.cpp b/test/libethereum/blockchain.cpp index 13ee52af1..6363da14f 100644 --- a/test/libethereum/blockchain.cpp +++ b/test/libethereum/blockchain.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -135,6 +136,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) for (size_t i = 1; i < importBlockNumber; i++) //0 block is genesis { BlockQueue uncleQueue; + uncleQueue.setChain(bc); uncleList uncles = blockSets.at(i).second; for (size_t j = 0; j < uncles.size(); j++) uncleQueue.import(&uncles.at(j), false); @@ -163,6 +165,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) blObj["uncleHeaders"] = importUncles(blObj, vBiUncles, vBiBlocks, blockSets); BlockQueue uncleBlockQueue; + uncleBlockQueue.setChain(bc); uncleList uncleBlockQueueList; cnote << "import uncle in blockQueue"; for (size_t i = 0; i < vBiUncles.size(); i++) @@ -208,7 +211,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) txList.push_back(txi); blObj["transactions"] = writeTransactionsToJson(txList); - BlockHeader current_BlockHeader = state.info(); + BlockHeader current_BlockHeader(state.blockData()); RLPStream uncleStream; uncleStream.appendList(vBiUncles.size()); @@ -667,19 +670,19 @@ void overwriteBlockHeader(BlockHeader& _header, mObject& _blObj) if (ho.size() != 14) { BlockHeader tmp = constructHeader( - ho.count("parentHash") ? h256(ho["parentHash"].get_str()) : h256{}, - ho.count("uncleHash") ? h256(ho["uncleHash"].get_str()) : EmptyListSHA3, - ho.count("coinbase") ? Address(ho["coinbase"].get_str()) : Address{}, - ho.count("stateRoot") ? h256(ho["stateRoot"].get_str()): h256{}, - ho.count("transactionsTrie") ? h256(ho["transactionsTrie"].get_str()) : EmptyTrie, - ho.count("receiptTrie") ? h256(ho["receiptTrie"].get_str()) : EmptyTrie, - ho.count("bloom") ? LogBloom(ho["bloom"].get_str()) : LogBloom{}, - ho.count("difficulty") ? toInt(ho["difficulty"]) : u256(0), - ho.count("number") ? toInt(ho["number"]) : u256(0), - ho.count("gasLimit") ? toInt(ho["gasLimit"]) : u256(0), - ho.count("gasUsed") ? toInt(ho["gasUsed"]) : u256(0), - ho.count("timestamp") ? toInt(ho["timestamp"]) : u256(0), - ho.count("extraData") ? importByteArray(ho["extraData"].get_str()) : bytes{}); + ho.count("parentHash") ? h256(ho["parentHash"].get_str()) : _header.parentHash(), + ho.count("uncleHash") ? h256(ho["uncleHash"].get_str()) : _header.sha3Uncles(), + ho.count("coinbase") ? Address(ho["coinbase"].get_str()) : _header.coinbaseAddress(), + ho.count("stateRoot") ? h256(ho["stateRoot"].get_str()): _header.stateRoot(), + ho.count("transactionsTrie") ? h256(ho["transactionsTrie"].get_str()) : _header.transactionsRoot(), + ho.count("receiptTrie") ? h256(ho["receiptTrie"].get_str()) : _header.receiptsRoot(), + ho.count("bloom") ? LogBloom(ho["bloom"].get_str()) : _header.logBloom(), + ho.count("difficulty") ? toInt(ho["difficulty"]) : _header.difficulty(), + ho.count("number") ? toInt(ho["number"]) : _header.number(), + ho.count("gasLimit") ? toInt(ho["gasLimit"]) : _header.gasLimit(), + ho.count("gasUsed") ? toInt(ho["gasUsed"]) : _header.gasUsed(), + ho.count("timestamp") ? toInt(ho["timestamp"]) : _header.timestamp(), + ho.count("extraData") ? importByteArray(ho["extraData"].get_str()) : _header.extraData()); // find new valid nonce if (static_cast(tmp) != static_cast(_header) && tmp.difficulty())