44 BOOST_REQUIRE(
string(chat.
name()).find(
"◌") != string::npos);
45 BOOST_REQUIRE(
string(trace.
name()).find(
"◎") != string::npos);
46 BOOST_REQUIRE(
string(details.
name()).find(
"◌") != string::npos);
47 BOOST_REQUIRE(
string(exeptions.
name()).find(
"ℹ") != string::npos);
57 TestBlockChain testBlockchain(TestBlockChain::defaultGenesisBlock());
70 testBlock.
mine(testBlockchain);
80 BOOST_REQUIRE(ImportTest::compareStates(stateBofore, stateAfterInsert) == 0);
83 BOOST_REQUIRE(ImportTest::compareStates(stateAfterInsert, stateAfterInsert1,
eth::AccountMaskMap(), WhenError::DontThrow) == 1);
86 BOOST_REQUIRE(ImportTest::compareStates(stateBofore, stateAfterInsert2,
eth::AccountMaskMap(), WhenError::DontThrow) == 1);
87 BOOST_REQUIRE(ImportTest::compareStates(stateAfterInsert1, stateAfterInsert2,
eth::AccountMaskMap(), WhenError::DontThrow) == 1);
90 BOOST_REQUIRE(block1.
info() == block2.
info());
91 block2.
sync(blockchain);
92 BOOST_REQUIRE(block1.
info() != block2.
info());
96 Block block(Block::Null);
100 catch (std::exception
const& _e)
102 BOOST_REQUIRE(
string(_e.what()).find(
"InvalidStateRoot") != string::npos);
107 BOOST_ERROR(
"Failed test with Exception: " << diagnostic_information(_e));
109 catch (std::exception
const& _e)
111 BOOST_ERROR(
"Failed test with Exception: " << _e.what());
115 BOOST_ERROR(
"Exception thrown when trying to mine or import a block!");
121 TestBlockChain testBlockchain(TestBlockChain::defaultGenesisBlock(63000));
127 TestTransaction transaction1 = TestTransaction::defaultTransaction(1, 1, 21000);
129 TestTransaction transaction2 = TestTransaction::defaultTransaction(2, 1, 21000);
136 block.
sync(blockchain);
154 TestTransaction transaction = TestTransaction::defaultTransaction(3, 1, 1500000);
159 block.
sync(blockchain);
167 TestTransaction transaction = TestTransaction::defaultTransaction(3, 1, 25000,
importByteArray(
"238479601324597364057623047523945623847562387450234857263485723459273645345234689563486749"));
172 block.
sync(blockchain);
180 TestTransaction transaction = TestTransaction::defaultTransaction(12, 1, 21000);
185 block.
sync(blockchain);
193 TestTransaction transaction = TestTransaction::defaultTransaction(0, 1, 21000);
198 block.
sync(blockchain);
208 TestBlockChain testBlockchain(TestBlockChain::defaultGenesisBlock());
217 Block block2 = block;
218 BOOST_REQUIRE(ImportTest::compareStates(block.
state(), block2.
state()) == 0);
221 BOOST_REQUIRE(block2.
info() == block.
info());
225 testBlock.addTransaction(transaction1);
226 testBlock.mine(testBlockchain);
231 BOOST_REQUIRE(block3.
info() == testBlock.blockHeader());
239 auto is_critical = []( std::exception
const& _e) {
return string(_e.what()).find(
"BlockNotFound") != string::npos; };
240 BOOST_CHECK_EXCEPTION(block32.populateFromChain(blockchain,
h256(
"0x0000000000000000000000000000000000000000000000000000000000000001")), BlockNotFound, is_critical);
244 BOOST_ERROR(
"Failed test with Exception: " << diagnostic_information(_e));
246 catch (std::exception
const& _e)
248 BOOST_ERROR(
"Failed test with Exception: " << _e.what());
252 BOOST_ERROR(
"Exception thrown when trying to mine or import a block!");
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
TestBlock const & topBlock()
State const & state() const
Get the backing state object.
std::pair< TransactionReceipts, bool > sync(BlockChain const &_bc, TransactionQueue &_tq, GasPricer const &_gp, unsigned _msTimeout=100)
Sync our transactions, killing those from the queue that we have and assimilating those that we don't...
static Options const & get(int argc=0, char **argv=0)
Get reference to options The first time used, options are parsed with argc, argv. ...
State fromPending(unsigned _i) const
Get the State immediately after the given number of pending transactions have been applied...
static const char * name()
Implements the blockchain database.
BlockChain const & interface() const
BOOST_AUTO_TEST_CASE(bStructures)
Block genesisBlock(OverlayDB const &_db) const
Get a pre-made genesis State object.
static const char * name()
std::hash for asio::adress
BlockHeader const & blockHeader() const
Model of an Ethereum state, essentially a facade for the trie.
OverlayDB const & db() const
Transactions topTransactions(unsigned _limit, h256Hash const &_avoid=h256Hash()) const
Get top transactions from the queue.
Active model of a block within the block chain.
TestBlock const & testGenesis() const
Base class for all exceptions.
PopulationStatistics populateFromChain(BlockChain const &_bc, h256 const &_hash, ImportRequirements::value _ir=ImportRequirements::None)
Construct state object from arbitrary point in blockchain.
Transactions const & pending() const
Get the list of pending transactions.
std::unordered_map< Address, AccountMask > AccountMaskMap
bool addBlock(TestBlock const &_block)
Address author() const
Get the author address for any transactions we do and rewards we get.
void mine(TestBlockChain const &_bc)
void setAuthor(Address const &_id)
Set the author address for any transactions we do and rewards we get.
static const char * name()
TransactionQueue const & transactionQueue() const
State const & state() const
#define BOOST_FIXTURE_TEST_SUITE(a, b)
static const char * name()
#define BOOST_AUTO_TEST_SUITE_END()
void addTransaction(TestTransaction const &_tr)
bytes importByteArray(std::string const &_str)
Address const & beneficiary() const
BlockHeader const & info() const
Get the header information on the present block.
Helper functions to work with json::spirit and test files.