Fixed block_bodies not returning a list

This commit is contained in:
arkpar 2016-02-11 02:07:46 +01:00
parent 61c8f7b00b
commit 7bb661e21c
2 changed files with 14 additions and 1 deletions

View File

@ -350,7 +350,7 @@ impl BlockChainClient for Client {
fn block_body(&self, hash: &H256) -> Option<Bytes> {
self.chain.read().unwrap().block(hash).map(|bytes| {
let rlp = Rlp::new(&bytes);
let mut body = RlpStream::new();
let mut body = RlpStream::new_list(2);
body.append_raw(rlp.at(1).as_raw(), 1);
body.append_raw(rlp.at(2).as_raw(), 1);
body.out()

View File

@ -76,6 +76,19 @@ fn returns_chain_info() {
assert_eq!(info.best_block_hash, block.header().hash());
}
#[test]
fn returns_block_body() {
let dummy_block = get_good_dummy_block();
let client_result = get_test_client_with_blocks(vec![dummy_block.clone()]);
let client = client_result.reference();
let block = BlockView::new(&dummy_block);
let body = client.block_body(&block.header().hash()).unwrap();
let body = Rlp::new(&body);
assert_eq!(body.item_count(), 2);
assert_eq!(body.at(0).as_raw()[..], block.rlp().at(1).as_raw()[..]);
assert_eq!(body.at(1).as_raw()[..], block.rlp().at(2).as_raw()[..]);
}
#[test]
fn imports_block_sequence() {
let client_result = generate_dummy_client(6);