22 #include <boost/test/unit_test.hpp> 38 test::TestOutputHelper::initTest();
41 auto compareState = [&_client](
Json::Value const& _o,
string const& _name,
BlockNumber _blockNumber) ->
void 56 for (
string const& pos: _o[
"storage"].getMemberNames())
67 code.begin(), code.end());
70 for (
string const&
name: _json[
"postState"].getMemberNames())
73 compareState(o,
name, PendingBlock);
76 for (
string const&
name: _json[
"pre"].getMemberNames())
79 compareState(o,
name, 0);
83 unsigned expectedNumber = _json[
"blocks"].size();
84 unsigned number = _client.
number();
87 u256 totalDifficulty =
u256(_json[
"genesisBlockHeader"][
"difficulty"].
asString());
128 expectedBlockInfoExtraData.begin(),
129 expectedBlockInfoExtraData.end(),
130 _blockInfo.extraData().begin(),
131 _blockInfo.extraData().end()
136 ETH_CHECK_EQUAL(expectedBlockInfoMixHash, Ethash::mixHash(_blockInfo));
140 ETH_CHECK_EQUAL(expectedBlockInfoReceiptsRoot, _blockInfo.receiptsRoot());
142 ETH_CHECK_EQUAL(expectedBlockInfoTransactionsRoot, _blockInfo.transactionsRoot());
147 compareBlockInfos(blockHeader, blockInfo);
150 unsigned expectedBlockDetailsNumber =
jsToInt(blockHeader[
"number"].
asString());
151 totalDifficulty +=
u256(blockHeader[
"difficulty"].
asString());
167 expectedTransactionData.begin(),
168 expectedTransactionData.end(),
169 _transaction.data().begin(),
170 _transaction.data().end()
175 ETH_CHECK_EQUAL(expectedTransactionSignatureR, _transaction.signature().r);
176 ETH_CHECK_EQUAL(expectedTransactionSignatureS, _transaction.signature().s);
185 ETH_REQUIRE(transactions.size() == tHashes.size());
190 for (
unsigned i = 0; i < tsCount; i++)
196 compareTransactions(t, transaction);
200 compareTransactions(t, transactionByHash);
203 compareTransactions(t, ts[i]);
210 unsigned usCount = _client.
uncleCount(blockHash);
213 for (
unsigned i = 0; i < usCount; i++)
219 compareBlockInfos(u, uncle);
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
struct evm_uint256be balance(struct evm_env *env, struct evm_uint160be address)
virtual u256 countAt(Address _a, BlockNumber _block) const override
h160 Address
An Ethereum address: 20 bytes.
std::vector< Transaction > Transactions
Nice name for vector of Transaction.
virtual bytes codeAt(Address _a, BlockNumber _block) const override
virtual BlockDetails blockDetails(h256 _hash) const override
virtual unsigned transactionCount(h256 _blockHash) const override
std::hash for asio::adress
virtual u256 balanceAt(Address _a, BlockNumber _block) const override
#define ETH_CHECK_EQUAL(x, y)
virtual Transactions transactions(h256 _blockHash) const override
bytes fromHex(std::string const &_s, WhenError _throw=WhenError::DontThrow)
virtual u256 stateAt(Address _a, u256 _l, BlockNumber _block) const override
std::vector< byte > bytes
Fixed-size raw-byte array container type, with an API optimised for storing hashes.
BOOST_AUTO_TEST_CASE(blocks)
h256 sha3(IncludeSignature _sig=WithSignature) const
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
#define ETH_CHECK_EQUAL_COLLECTIONS(xb, xe, yb, ye)
Encodes a transaction, ready to be exported to or freshly imported from RLP.
virtual h256 hashFromNumber(BlockNumber _number) const override
#define BOOST_FIXTURE_TEST_SUITE(a, b)
#define BOOST_AUTO_TEST_SUITE_END()
virtual TransactionHashes transactionHashes(h256 _blockHash) const override
virtual unsigned uncleCount(h256 _blockHash) const override
h2048 LogBloom
The log bloom's size (2048-bit).
virtual unsigned number() const override
struct evm_uint160be address(struct evm_env *env)
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< N *8, N *8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void > > jsToInt(std::string const &_s)
Convert a string representation of a number to an int String can be a normal decimal number...
virtual Transaction transaction(h256 _transactionHash) const override
std::string asString(bytes const &_b)
Converts byte array to a string containing the same (binary) data.
virtual BlockHeader uncle(h256 _blockHash, unsigned _i) const override
Helper functions to work with json::spirit and test files.