23 #include <boost/filesystem/operations.hpp> 24 #include <boost/test/unit_test.hpp> 25 #include <boost/filesystem.hpp> 42 eth::Network TestBlockChain::s_sealEngineNetwork = eth::Network::FrontierTest;
47 void reset() { blockchain.reset(importedBlocks.at(0)); }
51 for (
size_t i = 1; i < importedBlocks.size(); i++)
52 if (i < _importBlockNumber)
53 blockchain.addBlock(importedBlocks.at(i));
58 size_t originalSize = importedBlocks.size();
59 for (
size_t i = _importBlockNumber; i < originalSize; i++)
60 importedBlocks.pop_back();
68 if (chainname ==
"Frontier")
70 else if (chainname ==
"Homestead")
72 else if (chainname ==
"EIP150")
74 else if (chainname ==
"TestFtoH5")
76 else if (chainname ==
"Metropolis")
89 eth::Network ChainBranch::s_tempBlockchainNetwork = eth::Network::MainNetwork;
104 if (!Options::get().fillchain)
105 TestOutputHelper::initTest(_v);
108 string testname = i.first;
111 if (!Options::get().fillchain)
112 if (!TestOutputHelper::passTest(o, testname))
115 BOOST_REQUIRE(o.count(
"genesisBlockHeader"));
116 BOOST_REQUIRE(o.count(
"pre"));
117 if (o.count(
"network"))
120 TestBlock genesisBlock(o[
"genesisBlockHeader"].get_obj(), o[
"pre"].get_obj());
132 BOOST_REQUIRE(o.count(
"blocks"));
135 size_t importBlockNumber = 0;
136 string chainname =
"default";
137 string chainnetwork =
"default";
138 std::map<string, ChainBranch*> chainMap = { {chainname ,
new ChainBranch(genesisBlock)}};
140 for (
auto const& bl: o[
"blocks"].get_array())
143 if (blObj.count(
"blocknumber") > 0)
144 importBlockNumber =
max((
int)
toInt(blObj[
"blocknumber"]), 1);
148 if (blObj.count(
"chainname") > 0)
149 chainname = blObj[
"chainname"].
get_str();
151 chainname =
"default";
153 if (blObj.count(
"chainnetwork") > 0)
154 chainnetwork = blObj[
"chainnetwork"].
get_str();
156 chainnetwork =
"default";
158 if (chainMap.count(chainname) > 0)
160 if (o.count(
"noBlockChainHistory") == 0)
162 ChainBranch::forceBlockchain(chainnetwork);
163 chainMap[chainname]->reset();
164 ChainBranch::resetBlockchain();
165 chainMap[chainname]->restoreFromHistory(importBlockNumber);
170 ChainBranch::forceBlockchain(chainnetwork);
171 chainMap[chainname] =
new ChainBranch(genesisBlock);
172 ChainBranch::resetBlockchain();
177 vector<TestBlock>& importedBlocks = chainMap[chainname]->importedBlocks;
180 BOOST_REQUIRE(blObj.count(
"transactions"));
181 for (
auto const& txObj: blObj[
"transactions"].get_array())
188 for (
auto const& uHObj: blObj.at(
"uncleHeaders").get_array())
190 cnote <<
"Generating uncle block at test " << testname;
192 mObject uncleHeaderObj = uHObj.get_obj();
193 string uncleChainName = chainname;
194 if (uncleHeaderObj.count(
"chainname") > 0)
195 uncleChainName = uncleHeaderObj[
"chainname"].
get_str();
204 if (blObj.count(
"blockHeaderPremine"))
207 blObj.erase(
"blockHeaderPremine");
210 cnote <<
"Mining block" << importBlockNumber <<
"for chain" << chainname <<
"at test " << testname;
211 block.
mine(blockchain);
212 cnote <<
"Block mined with...";
219 if (blObj.count(
"blockHeader"))
226 for (
size_t i = 0; i < alterBlock.
uncles().size(); i++)
229 aUncleList.push_back(uncleHeaderObj);
231 blObj[
"uncleHeaders"] = aUncleList;
239 cnote <<
"The most recent best Block now is " << importBlockNumber <<
"in chain" << chainname <<
"at test " << testname;
241 if (test::Options::get().checkstate ==
true)
242 BOOST_REQUIRE_MESSAGE(blObj.count(
"expectException") == 0,
"block import expected exception, but no exeption was thrown!");
243 if (o.count(
"noBlockChainHistory") == 0)
245 importedBlocks.push_back(alterBlock);
246 importedBlocks.at(importedBlocks.size()-1).clearState();
251 cnote << testname +
"block import throw an exception: " << diagnostic_information(_e);
255 catch (std::exception
const& _e)
257 cnote << testname +
"block import throw an exception: " << _e.what();
258 cout << testname +
"block import thrown std exeption" << std::endl;
263 cout << testname +
"block import thrown unknown exeption" << std::endl;
267 blArray.push_back(blObj);
268 this_thread::sleep_for(chrono::seconds(1));
271 if (o.count(
"expect") > 0)
274 State stateExpect(State::Null);
275 ImportTest::importState(o[
"expect"].get_obj(), stateExpect, expectStateMap);
276 if (ImportTest::compareStates(stateExpect, testChain.
topBlock().
state(), expectStateMap, Options::get().checkstate ? WhenError::Throw : WhenError::DontThrow))
277 if (Options::get().checkstate)
278 cerr << testname << endl;
279 o.erase(o.find(
"expect"));
282 o[
"blocks"] = blArray;
287 State prestate(State::Null);
288 ImportTest::importState(o[
"pre"].get_obj(), prestate);
291 for (
auto iterator = chainMap.begin(); iterator != chainMap.end(); iterator++)
292 delete iterator->second;
299 if (o.count(
"genesisRLP") > 0)
302 checkBlocks(genesisBlock, genesisFromRLP, testname);
305 for (
auto const& bl: o[
"blocks"].get_array())
312 blockFromRlp = blRlp;
313 if (blObj.count(
"blockHeader") == 0)
320 cnote << testname +
"state sync or block import did throw an exception: " << diagnostic_information(_e);
324 catch (std::exception
const& _e)
326 cnote << testname +
"state sync or block import did throw an exception: " << _e.what();
332 cnote << testname +
"state sync or block import did throw an exception\n";
338 BOOST_REQUIRE(blObj.count(
"blockHeader"));
342 TestBlock blockFromFields(blObj[
"blockHeader"].get_obj(), emptyState);
344 BOOST_REQUIRE(blObj.count(
"transactions"));
345 for (
auto const& txObj: blObj[
"transactions"].get_array())
353 for (
auto const& uBlHeaderObj: blObj[
"uncleHeaders"].get_array())
355 mObject uBlH = uBlHeaderObj.get_obj();
356 BOOST_REQUIRE((uBlH.size() == 16));
363 checkBlocks(blockFromFields, blockFromRlp, testname);
367 blockchain.
addBlock(blockFromFields);
371 cerr << testname +
"Error importing block from fields to blockchain: " << diagnostic_information(_e);
378 checkBlocks(inchainBlock, blockFromFields, testname);
381 string blockChainName =
"default";
382 if (blObj.count(
"chainname") > 0)
383 blockChainName = blObj[
"chainname"].
get_str();
384 if (blObj.count(
"blocknumber") > 0)
385 blockNumber = blObj[
"blocknumber"].
get_str();
387 cnote <<
"Tested topblock number" << blockNumber <<
"for chain " << blockChainName << testname;
392 BOOST_REQUIRE((o.count(
"lastblockhash") > 0));
394 BOOST_CHECK_MESSAGE(lastTrueBlockHash == o[
"lastblockhash"].
get_str(),
395 testname +
"Boost check: lastblockhash does not match " + lastTrueBlockHash +
" expected: " + o[
"lastblockhash"].
get_str());
400 testname +
"State root in chain from RLP blocks != State root in chain from Field blocks!");
402 State postState(State::Null);
403 BOOST_REQUIRE((o.count(
"postState") > 0));
404 ImportTest::importState(o[
"postState"].get_obj(), postState);
405 ImportTest::compareStates(postState, testChain.
topBlock().
state());
406 ImportTest::compareStates(postState, blockchain.
topBlock().
state());
409 TestOutputHelper::finishTest();
419 vector<TestBlock>
const& importedBlocks = _chainBranch.
importedBlocks;
435 ho.count(
"difficulty") ?
toInt(ho[
"difficulty"]) :
437 ho.count(
"number") ?
toInt(ho[
"number"]) : header.
number(),
438 ho.count(
"gasLimit") ?
toInt(ho[
"gasLimit"]) : header.
gasLimit(),
439 ho.count(
"gasUsed") ?
toInt(ho[
"gasUsed"]) : header.
gasUsed(),
440 ho.count(
"timestamp") ?
toInt(ho[
"timestamp"]) : header.
timestamp(),
444 _block.
setPremine(ho.count(
"parentHash") ?
"parentHash" :
"");
445 _block.
setPremine(ho.count(
"uncleHash") ?
"uncleHash" :
"");
446 _block.
setPremine(ho.count(
"coinbase") ?
"coinbase" :
"");
447 _block.
setPremine(ho.count(
"stateRoot") ?
"stateRoot" :
"");
448 _block.
setPremine(ho.count(
"transactionsTrie") ?
"transactionsTrie" :
"");
449 _block.
setPremine(ho.count(
"receiptTrie") ?
"receiptTrie" :
"");
450 _block.
setPremine(ho.count(
"bloom") ?
"bloom" :
"");
451 _block.
setPremine(ho.count(
"difficulty") ?
"difficulty" :
"");
452 _block.
setPremine(ho.count(
"number") ?
"number" :
"");
453 _block.
setPremine(ho.count(
"gasLimit") ?
"gasLimit" :
"");
454 _block.
setPremine(ho.count(
"gasUsed") ?
"gasUsed" :
"");
455 _block.
setPremine(ho.count(
"timestamp") ?
"timestamp" :
"");
456 _block.
setPremine(ho.count(
"extraData") ?
"extraData" :
"");
458 if (ho.count(
"RelTimestamp"))
460 BlockHeader parentHeader = importedBlocks.at(importedBlocks.size() - 1).blockHeader();
463 this_thread::sleep_for(chrono::seconds((
int)
toInt(ho[
"RelTimestamp"])));
466 Ethash::setMixHash(tmp, ho.count(
"mixHash") ?
h256(ho[
"mixHash"].
get_str()) : Ethash::mixHash(header));
467 Ethash::setNonce(tmp, ho.count(
"nonce") ?
Nonce(ho[
"nonce"].
get_str()) : Ethash::nonce(header));
477 if (ho.count(
"populateFromBlock"))
479 size_t number = (size_t)
toInt(ho.at(
"populateFromBlock"));
480 ho.erase(
"populateFromBlock");
481 if (number < importedBlocks.size())
483 BlockHeader parentHeader = importedBlocks.at(number).blockHeader();
488 cerr << TestOutputHelper::testName() +
"Could not populate blockHeader from block: there are no block with number!" << TestOutputHelper::testName() << endl;
492 if (ho.count(
"mixHash") || ho.count(
"nonce") || !ho.count(
"updatePoW"))
510 vector<TestBlock>
const& importedBlocks = _chainBranch.
importedBlocks;
513 if (uncleHeaderObj.count(
"sameAsPreviousSibling"))
515 uncleHeaderObj.erase(
"sameAsPreviousSibling");
517 uncle = uncles.at(uncles.size() - 1);
519 cerr << TestOutputHelper::testName() +
"Could not create uncle sameAsPreviousSibling: there are no siblings!";
523 if (uncleHeaderObj.count(
"sameAsBlock"))
525 size_t number = (size_t)
toInt(uncleHeaderObj.at(
"sameAsBlock"));
526 uncleHeaderObj.erase(
"sameAsBlock");
528 if (number < importedBlocks.size())
529 uncle = importedBlocks.at(number);
531 cerr << TestOutputHelper::testName() +
"Could not create uncle sameAsBlock: there are no block with number " << number;
535 if (uncleHeaderObj.count(
"sameAsPreviousBlockUncle"))
537 size_t number = (size_t)
toInt(uncleHeaderObj.at(
"sameAsPreviousBlockUncle"));
538 uncleHeaderObj.erase(
"sameAsPreviousBlockUncle");
539 if (number < importedBlocks.size())
541 vector<TestBlock> prevBlockUncles = importedBlocks.at(number).uncles();
542 if (prevBlockUncles.size())
543 uncle = prevBlockUncles[0];
545 cerr << TestOutputHelper::testName() +
"Could not create uncle sameAsPreviousBlockUncle: previous block has no uncles!" << TestOutputHelper::testName() << endl;
548 cerr << TestOutputHelper::testName() +
"Could not create uncle sameAsPreviousBlockUncle: there are no block imported!" << TestOutputHelper::testName() << endl;
552 string overwrite =
"false";
553 if (uncleHeaderObj.count(
"overwriteAndRedoPoW"))
555 overwrite = uncleHeaderObj.at(
"overwriteAndRedoPoW").get_str();
556 uncleHeaderObj.erase(
"overwriteAndRedoPoW");
561 if (uncleHeaderObj.count(
"populateFromBlock"))
564 size_t number = (size_t)
toInt(uncleHeaderObj.at(
"populateFromBlock"));
565 uncleHeaderObj.erase(
"populateFromBlock");
566 if (number < importedBlocks.size())
571 uncleHeader.
setRoots((
h256)
fromHex(
"56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"),
572 (
h256)
fromHex(
"56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"),
573 (
h256)
fromHex(
"1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"),
577 if (uncleHeaderObj.count(
"RelTimestamp"))
579 BlockHeader parentHeader = importedBlocks.at(number).blockHeader();
581 uncleHeader.
setDifficulty(((
const Ethash*)sealEngine)->calculateDifficulty(uncleHeader, parentHeader));
583 uncleHeaderObj.erase(
"RelTimestamp");
587 cerr << TestOutputHelper::testName() +
"Could not create uncle populateFromBlock: there are no block with number " << number << TestOutputHelper::testName() << endl;
592 uncle =
TestBlock(uncleHeaderObj, emptyState);
596 if (overwrite !=
"false")
599 overwrite ==
"parentHash" ?
h256(uncleHeaderObj.at(
"parentHash").get_str()) : uncleHeader.
parentHash(),
601 overwrite ==
"coinbase" ?
Address(uncleHeaderObj.at(
"coinbase").get_str()) : uncleHeader.
author(),
602 overwrite ==
"stateRoot" ?
h256(uncleHeaderObj.at(
"stateRoot").get_str()) : uncleHeader.
stateRoot(),
606 overwrite ==
"difficulty" ?
toInt(uncleHeaderObj.at(
"difficulty"))
607 : overwrite ==
"timestamp" ? ((
const Ethash*)sealEngine)->calculateDifficulty(uncleHeader, importedBlocks.at((
size_t)uncleHeader.
number() - 1).blockHeader())
609 overwrite ==
"number" ?
toInt(uncleHeaderObj.at(
"number")) : uncleHeader.
number(),
610 overwrite ==
"gasLimit" ?
toInt(uncleHeaderObj.at(
"gasLimit")) : uncleHeader.
gasLimit(),
611 overwrite ==
"gasUsed" ?
toInt(uncleHeaderObj.at(
"gasUsed")) : uncleHeader.
gasUsed(),
612 overwrite ==
"timestamp" ?
toInt(uncleHeaderObj.at(
"timestamp")) : uncleHeader.
timestamp(),
613 overwrite ==
"extraData" ?
fromHex(uncleHeaderObj.at(
"extraData").get_str()) : uncleHeader.
extraData());
619 if (overwrite ==
"nonce" || overwrite ==
"mixHash")
621 if (overwrite ==
"nonce")
622 Ethash::setNonce(uncleHeader,
Nonce(uncleHeaderObj[
"nonce"].
get_str()));
623 if (overwrite ==
"mixHash")
624 Ethash::setMixHash(uncleHeader,
h256(uncleHeaderObj[
"mixHash"].
get_str()));
634 cnote <<
"block header mismatch\n";
639 cnote <<
"txs mismatch\n";
649 for (
auto const& txi: txs)
652 txArray.push_back(txObject);
673 o[
"mixHash"] =
toString(Ethash::mixHash(_bi));
674 o[
"nonce"] =
toString(Ethash::nonce(_bi));
681 if (!test::Options::get().checkstate)
684 string exWhat { _e.
what() };
685 BOOST_REQUIRE_MESSAGE(_blObj.count(
"expectException") > 0, TestOutputHelper::testName() +
"block import thrown unexpected Excpetion! (" + exWhat +
")");
687 string exExpect = _blObj.at(
"expectException").get_str();
688 BOOST_REQUIRE_MESSAGE(exWhat.find(exExpect) != string::npos, TestOutputHelper::testName() +
"block import expected another exeption: " + exExpect);
689 _blObj.erase(_blObj.find(
"expectException"));
702 cnote << TestOutputHelper::testName() +
"block is invalid!\n";
703 _blObj.erase(_blObj.find(
"blockHeader"));
704 _blObj.erase(_blObj.find(
"uncleHeaders"));
705 _blObj.erase(_blObj.find(
"transactions"));
713 BOOST_CHECK_MESSAGE(blockHeaderFromFields.
hash(
WithoutSeal) == blockFromRlp.
hash(
WithoutSeal), _testname +
"hash in given RLP not matching the block hash!");
714 BOOST_CHECK_MESSAGE(blockHeaderFromFields.
parentHash() == blockFromRlp.
parentHash(), _testname +
"parentHash in given RLP not matching the block parentHash!");
715 BOOST_CHECK_MESSAGE(blockHeaderFromFields.
sha3Uncles() == blockFromRlp.
sha3Uncles(), _testname +
"sha3Uncles in given RLP not matching the block sha3Uncles!");
716 BOOST_CHECK_MESSAGE(blockHeaderFromFields.
author() == blockFromRlp.
author(), _testname +
"author in given RLP not matching the block author!");
717 BOOST_CHECK_MESSAGE(blockHeaderFromFields.
stateRoot() == blockFromRlp.
stateRoot(), _testname +
"stateRoot in given RLP not matching the block stateRoot!");
718 BOOST_CHECK_MESSAGE(blockHeaderFromFields.
transactionsRoot() == blockFromRlp.
transactionsRoot(), _testname +
"transactionsRoot in given RLP not matching the block transactionsRoot!");
719 BOOST_CHECK_MESSAGE(blockHeaderFromFields.
receiptsRoot() == blockFromRlp.
receiptsRoot(), _testname +
"receiptsRoot in given RLP not matching the block receiptsRoot!");
720 BOOST_CHECK_MESSAGE(blockHeaderFromFields.
logBloom() == blockFromRlp.
logBloom(), _testname +
"logBloom in given RLP not matching the block logBloom!");
721 BOOST_CHECK_MESSAGE(blockHeaderFromFields.
difficulty() == blockFromRlp.
difficulty(), _testname +
"difficulty in given RLP not matching the block difficulty!");
722 BOOST_CHECK_MESSAGE(blockHeaderFromFields.
number() == blockFromRlp.
number(), _testname +
"number in given RLP not matching the block number!");
723 BOOST_CHECK_MESSAGE(blockHeaderFromFields.
gasLimit() == blockFromRlp.
gasLimit(),
"testname + gasLimit in given RLP not matching the block gasLimit!");
724 BOOST_CHECK_MESSAGE(blockHeaderFromFields.
gasUsed() == blockFromRlp.
gasUsed(), _testname +
"gasUsed in given RLP not matching the block gasUsed!");
725 BOOST_CHECK_MESSAGE(blockHeaderFromFields.
timestamp() == blockFromRlp.
timestamp(), _testname +
"timestamp in given RLP not matching the block timestamp!");
726 BOOST_CHECK_MESSAGE(blockHeaderFromFields.
extraData() == blockFromRlp.
extraData(), _testname +
"extraData in given RLP not matching the block extraData!");
730 BOOST_CHECK_MESSAGE(blockHeaderFromFields == blockFromRlp, _testname +
"However, blockHeaderFromFields != blockFromRlp!");
732 vector<TestTransaction>
const& txsFromField = _blockFromFields.
testTransactions();
733 vector<TestTransaction>
const& txsFromRlp = _blockFromRlp.
testTransactions();
734 BOOST_CHECK_MESSAGE(txsFromRlp.size() == txsFromField.size(), _testname +
"transaction list size does not match");
736 for (
size_t i = 0; i < txsFromField.size(); ++i)
738 Transaction const& trField = txsFromField.at(i).transaction();
739 Transaction const& trRlp = txsFromRlp.at(i).transaction();
741 BOOST_CHECK_MESSAGE(trField.
data() == trRlp.
data(), _testname +
"transaction data in rlp and in field do not match");
742 BOOST_CHECK_MESSAGE(trField.
gas() == trRlp.
gas(), _testname +
"transaction gasLimit in rlp and in field do not match");
743 BOOST_CHECK_MESSAGE(trField.
gasPrice() == trRlp.
gasPrice(), _testname +
"transaction gasPrice in rlp and in field do not match");
744 BOOST_CHECK_MESSAGE(trField.
nonce() == trRlp.
nonce(), _testname +
"transaction nonce in rlp and in field do not match");
745 BOOST_CHECK_MESSAGE(trField.
signature().
r == trRlp.
signature().
r, _testname +
"transaction r in rlp and in field do not match");
746 BOOST_CHECK_MESSAGE(trField.
signature().
s == trRlp.
signature().
s, _testname +
"transaction s in rlp and in field do not match");
747 BOOST_CHECK_MESSAGE(trField.
signature().
v == trRlp.
signature().
v, _testname +
"transaction v in rlp and in field do not match");
748 BOOST_CHECK_MESSAGE(trField.
receiveAddress() == trRlp.
receiveAddress(), _testname +
"transaction receiveAddress in rlp and in field do not match");
749 BOOST_CHECK_MESSAGE(trField.
value() == trRlp.
value(), _testname +
"transaction receiveAddress in rlp and in field do not match");
751 BOOST_CHECK_MESSAGE(trField == trRlp, _testname +
"transactions from rlp and transaction from field do not match");
752 BOOST_CHECK_MESSAGE(trField.
rlp() == trRlp.
rlp(), _testname +
"transactions rlp do not match");
755 vector<TestBlock>
const& unclesFromField = _blockFromFields.
uncles();
756 vector<TestBlock>
const& unclesFromRlp = _blockFromRlp.
uncles();
757 BOOST_REQUIRE_EQUAL(unclesFromField.size(), unclesFromRlp.size());
758 for (
size_t i = 0; i < unclesFromField.size(); ++i)
759 BOOST_CHECK_MESSAGE(unclesFromField.at(i).blockHeader() == unclesFromRlp.at(i).blockHeader(), _testname +
"block header in rlp and in field do not match at uncles");
void checkExpectedException(mObject &_blObj, Exception const &_e)
const Object & get_obj() const
std::string toCompactHex(u256 val, HexPrefix prefix=HexPrefix::DontAdd, unsigned _min=0)
void compareBlocks(TestBlock const &_a, TestBlock const &_b)
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
TestBlock const & topBlock()
vector< TestBlock > importedBlocks
std::string toHex(T const &_data, int _w=2, HexPrefix _prefix=HexPrefix::DontAdd)
A queue of Transactions, each stored as RLP.
void checkBlocks(TestBlock const &_blockFromFields, TestBlock const &_blockFromRlp, string const &_testname)
void overwriteUncleHeaderForTest(mObject &uncleHeaderObj, TestBlock &uncle, std::vector< TestBlock > const &uncles, ChainBranch const &_chainBranch)
BlockChain const & interface() const
const char * what() const noexceptoverride
h160 Address
An Ethereum address: 20 bytes.
std::vector< Transaction > Transactions
Nice name for vector of Transaction.
std::hash for asio::adress
assert(len-trim+(2 *lenIndices)<=WIDTH)
int Add(word *C, const word *A, const word *B, size_t N)
std::string toString(string32 const &_s)
Make normal string from fixed-length string.
BlockHeader const & blockHeader() const
mObject writeBlockHeaderToJson(BlockHeader const &_bi)
static eth::Network s_sealEngineNetwork
Model of an Ethereum state, essentially a facade for the trie.
void eraseJsonSectionForInvalidBlock(mObject &_blObj)
SignatureStruct const & signature() const
json_spirit::mObject fillJsonWithTransaction(Transaction const &_txn)
void updateNonce(TestBlockChain const &_bc)
bytes rlp(IncludeSignature _sig=WithSignature) const
Transactions topTransactions(unsigned _limit, h256Hash const &_avoid=h256Hash()) const
Get top transactions from the queue.
bytes fromHex(std::string const &_s, WhenError _throw=WhenError::DontThrow)
Base class for all exceptions.
mConfig::Array_type mArray
dev::eth::BlockHeader constructHeader(h256 const &_parentHash, h256 const &_sha3Uncles, Address const &_author, h256 const &_stateRoot, h256 const &_transactionsRoot, h256 const &_receiptsRoot, dev::eth::LogBloom const &_logBloom, u256 const &_difficulty, u256 const &_number, u256 const &_gasLimit, u256 const &_gasUsed, u256 const &_timestamp, bytes const &_extraData)
vector< TestTransaction > const & testTransactions() const
unsigned number(h256 const &_hash) const
Get a number for the given hash (or the most recent mined if none given). Thread-safe.
std::vector< byte > bytes
void overwriteBlockHeaderForTest(mObject const &_blObj, TestBlock &_block, ChainBranch const &_chainBranch)
static void forceBlockchain(string const &chainname)
bytes const & data() const
json_spirit::mObject fillJsonWithState(State const &_state)
static eth::Network s_tempBlockchainNetwork
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
bool isKnown(h256 const &_hash, bool _isCurrent=true) const
Returns true if the given block is known (though not necessarily a part of the canon chain)...
Encodes a transaction, ready to be exported to or freshly imported from RLP.
mArray writeTransactionsToJson(TransactionQueue const &_txsQueue)
std::unordered_map< Address, AccountMask > AccountMaskMap
mConfig::Object_type mObject
void restoreFromHistory(size_t _importBlockNumber)
bool addBlock(TestBlock const &_block)
h256 rootHash() const
The hash of the root of our state tree.
void setPremine(std::string const &_parameter)
void mine(TestBlockChain const &_bc)
void checkJsonSectionForInvalidBlock(mObject &_blObj)
TransactionQueue const & transactionQueue() const
State const & state() const
vector< TestBlock > const & uncles() const
dev::bytes const & bytes() const
PlatformStyle::TableColorType type
void setUncles(vector< TestBlock > const &_uncles)
bool sha3(bytesConstRef _input, bytesRef o_output)
Calculate SHA3-256 hash of the given input and load it into the given output.
TestBlockChain blockchain
void addTransaction(TestTransaction const &_tr)
virtual void populateFromParent(BlockHeader &_bi, BlockHeader const &_parent) const
Don't forget to call Super::populateFromParent when subclassing & overriding.
void doBlockchainTests(json_spirit::mValue &_v, bool _fillin)
h2048 LogBloom
The log bloom's size (2048-bit).
bytes block(h256 const &_hash) const
Get a block (RLP format) for the given hash (or the most recent mined if none given). Thread-safe.
dev::WithExisting max(dev::WithExisting _a, dev::WithExisting _b)
static void resetBlockchain()
bytes importByteArray(std::string const &_str)
vector< TestBlock > syncUncles(vector< TestBlock > const &_uncles)
void addUncle(TestBlock const &_uncle)
std::string get_str(std::string::const_iterator begin, std::string::const_iterator end)
eth::Network stringToNetId(string const &_netname)
Class for interpreting Recursive Linear-Prefix Data.
void setBlockHeader(BlockHeader const &_header)
u256 toInt(json_spirit::mValue const &_v)
SealEngineFace * sealEngine() const
Helper functions to work with json::spirit and test files.
#define BOOST_CHECK(expr)
Address receiveAddress() const
ChainBranch(TestBlock const &_genesis)