rpctest executable

This commit is contained in:
debris
2016-03-17 11:50:31 +01:00
parent 5e44769f82
commit f92a0c8df2
8 changed files with 115 additions and 1 deletions

View File

@@ -31,6 +31,13 @@ pub struct Block {
uncles: Vec<Header>,
}
impl Block {
/// Returns block rlp.
pub fn rlp(&self) -> Vec<u8> {
self.rlp.clone().into()
}
}
#[cfg(test)]
mod tests {
use serde_json;

View File

@@ -35,6 +35,18 @@ pub struct BlockChain {
pre_state: State,
}
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()
}
}
#[cfg(test)]
mod tests {
use serde_json;

View File

@@ -23,3 +23,11 @@ pub mod header;
pub mod state;
pub mod transaction;
pub mod test;
pub use self::account::Account;
pub use self::block::Block;
pub use self::blockchain::BlockChain;
pub use self::header::Header;
pub use self::state::State;
pub use self::test::Test;
pub use self::transaction::Transaction;

View File

@@ -21,6 +21,7 @@ use std::ops::Deref;
use blockchain::blockchain::BlockChain;
/// Blockchain test deserializer.
#[derive(Debug, PartialEq, Deserialize)]
pub struct Test(BTreeMap<String, BlockChain>);
impl Deref for Test {

View File

@@ -21,7 +21,7 @@ use serde::{Deserialize, Deserializer, Error};
use serde::de::Visitor;
/// Lenient bytes json deserialization for test json files.
#[derive(Default, Debug, PartialEq)]
#[derive(Default, Debug, PartialEq, Clone)]
pub struct Bytes(Vec<u8>);
impl Into<Vec<u8>> for Bytes {