Browse Source

more tests fixed

cl-refactor
arkpar 10 years ago
parent
commit
f791f90e12
  1. 2
      test/TestHelper.cpp
  2. 31
      test/libethereum/blockchain.cpp

2
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);
}

31
test/libethereum/blockchain.cpp

@ -23,6 +23,7 @@
#include <boost/filesystem.hpp>
#include <libdevcore/FileSystem.h>
#include <libdevcore/TransientDirectory.h>
#include <libethcore/Params.h>
#include <libethereum/CanonBlockChain.h>
#include <libethereum/TransactionQueue.h>
#include <test/TestHelper.h>
@ -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<BlockInfo>(tmp) != static_cast<BlockInfo>(_header) && tmp.difficulty())

Loading…
Cancel
Save