use ethjson module to load chain json tests

This commit is contained in:
debris
2016-03-19 18:13:14 +01:00
committed by arkpar
parent 49be60e984
commit a10160bd56
8 changed files with 36 additions and 33 deletions

View File

@@ -17,6 +17,7 @@
//! Blockchain deserialization.
use bytes::Bytes;
use hash::H256;
use blockchain::state::State;
use blockchain::header::Header;
use blockchain::block::Block;
@@ -30,7 +31,7 @@ pub struct BlockChain {
pub genesis_block: Header,
/// Genesis block rlp.
#[serde(rename="genesisRLP")]
pub genesis_rlp: Bytes,
pub genesis_rlp: Option<Bytes>,
/// Blocks.
pub blocks: Vec<Block>,
/// Post state.
@@ -39,14 +40,12 @@ pub struct BlockChain {
/// Pre state.
#[serde(rename="pre")]
pub pre_state: State,
/// Hash of best block.
#[serde(rename="lastblockhash")]
pub best_block: H256
}
impl BlockChain {
/// Returns genesis block rlp.
pub fn genesis_rlp(&self) -> Vec<u8> {
self.genesis_rlp.clone().into()
}
/// Returns blocks rlp.
pub fn blocks_rlp(&self) -> Vec<Vec<u8>> {
self.blocks.iter().map(|block| block.rlp()).collect()