Browse Source

BlockTests: restore corelibs and mining

cl-refactor
Dimitry 10 years ago
parent
commit
795521291a
  1. 2
      libethereum/Block.cpp
  2. 5
      libethereum/Block.h
  3. 2
      test/TestHelper.cpp
  4. 8
      test/libethereum/blockchain.cpp

2
libethereum/Block.cpp

@ -709,7 +709,7 @@ bool Block::sealBlock(bytesConstRef _header)
ret.appendRaw(m_currentTxs); ret.appendRaw(m_currentTxs);
ret.appendRaw(m_currentUncles); ret.appendRaw(m_currentUncles);
ret.swapOut(m_currentBytes); ret.swapOut(m_currentBytes);
m_currentBlock = Ethash::BlockHeader(_header, CheckNothing, h256(), HeaderData); m_currentBlock = BlockInfo(_header, CheckNothing, h256(), HeaderData);
cnote << "Mined " << m_currentBlock.hash() << "(parent: " << m_currentBlock.parentHash() << ")"; cnote << "Mined " << m_currentBlock.hash() << "(parent: " << m_currentBlock.parentHash() << ")";
// TODO: move into Sealer // TODO: move into Sealer
StructuredLogger::minedNewBlock( StructuredLogger::minedNewBlock(

5
libethereum/Block.h

@ -29,7 +29,6 @@
#include <libdevcrypto/OverlayDB.h> #include <libdevcrypto/OverlayDB.h>
#include <libethcore/Exceptions.h> #include <libethcore/Exceptions.h>
#include <libethcore/BlockInfo.h> #include <libethcore/BlockInfo.h>
#include <libethcore/Ethash.h>
#include <libethcore/Miner.h> #include <libethcore/Miner.h>
#include <libevm/ExtVMFace.h> #include <libevm/ExtVMFace.h>
#include "Account.h" #include "Account.h"
@ -253,7 +252,7 @@ public:
bytes const& blockData() const { return m_currentBytes; } bytes const& blockData() const { return m_currentBytes; }
/// Get the header information on the present block. /// Get the header information on the present block.
Ethash::BlockHeader const& info() const { return m_currentBlock; } BlockInfo const& info() const { return m_currentBlock; }
private: private:
@ -289,7 +288,7 @@ private:
State m_precommit; ///< State at the point immediately prior to rewards. State m_precommit; ///< State at the point immediately prior to rewards.
BlockInfo m_previousBlock; ///< The previous block's information. BlockInfo m_previousBlock; ///< The previous block's information.
Ethash::BlockHeader m_currentBlock; ///< The current block's information. BlockInfo m_currentBlock; ///< The current block's information.
bytes m_currentBytes; ///< The current block. bytes m_currentBytes; ///< The current block.
bool m_committedToMine = false; ///< Have we committed to mine on the present m_currentBlock? bool m_committedToMine = false; ///< Have we committed to mine on the present m_currentBlock?

2
test/TestHelper.cpp

@ -269,7 +269,7 @@ int ImportTest::compareStates(State const& _stateExpect, State const& _statePost
for (auto const& a: _stateExpect.addresses()) for (auto const& a: _stateExpect.addresses())
{ {
CHECK(_statePost.addressInUse(a.first), "Filling Test: " << a.first << " missing expected address!"); CHECK(_statePost.addressInUse(a.first), "Check State: " << a.first << " missing expected address!");
if (_statePost.addressInUse(a.first)) if (_statePost.addressInUse(a.first))
{ {
AccountMask addressOptions(true); AccountMask addressOptions(true);

8
test/libethereum/blockchain.cpp

@ -73,7 +73,6 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
BlockHeader biGenesisBlock = constructBlock(o["genesisBlockHeader"].get_obj(), h256{}); BlockHeader biGenesisBlock = constructBlock(o["genesisBlockHeader"].get_obj(), h256{});
State trueState(OverlayDB(State::openDB(tdStateDB.path(), h256{}, WithExisting::Kill)), BaseState::Empty); State trueState(OverlayDB(State::openDB(tdStateDB.path(), h256{}, WithExisting::Kill)), BaseState::Empty);
Block trueBlock; //lastBlock of trueBlockchain
ImportTest::importState(o["pre"].get_obj(), trueState); ImportTest::importState(o["pre"].get_obj(), trueState);
o["pre"] = fillJsonWithState(trueState); //convert all fields to hex o["pre"] = fillJsonWithState(trueState); //convert all fields to hex
trueState.commit(); trueState.commit();
@ -218,7 +217,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
txList.push_back(txi); txList.push_back(txi);
blObj["transactions"] = writeTransactionsToJson(txList); blObj["transactions"] = writeTransactionsToJson(txList);
BlockHeader current_BlockHeader = block.info(); BlockHeader current_BlockHeader(block.blockData());
RLPStream uncleStream; RLPStream uncleStream;
uncleStream.appendList(vBiUncles.size()); uncleStream.appendList(vBiUncles.size());
@ -284,6 +283,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
//attempt to import new block to the true blockchain //attempt to import new block to the true blockchain
trueBc.sync(uncleBlockQueue, trueState.db(), 4); trueBc.sync(uncleBlockQueue, trueState.db(), 4);
trueBc.attemptImport(blockRLP.out(), trueState.db()); trueBc.attemptImport(blockRLP.out(), trueState.db());
if (block.blockData() == trueBc.block())
trueState = block.state(); trueState = block.state();
blockSet newBlock; blockSet newBlock;
@ -316,7 +317,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
AccountMaskMap expectStateMap; AccountMaskMap expectStateMap;
State stateExpect(OverlayDB(), BaseState::Empty); State stateExpect(OverlayDB(), BaseState::Empty);
ImportTest::importState(o["expect"].get_obj(), stateExpect, expectStateMap); ImportTest::importState(o["expect"].get_obj(), stateExpect, expectStateMap);
ImportTest::compareStates(stateExpect, trueBlock.state(), expectStateMap, Options::get().checkState ? WhenError::Throw : WhenError::DontThrow); if (ImportTest::compareStates(stateExpect, trueState, expectStateMap, Options::get().checkState ? WhenError::Throw : WhenError::DontThrow))
cerr << testname << endl;
o.erase(o.find("expect")); o.erase(o.find("expect"));
} }

Loading…
Cancel
Save