Merge pull request #406 from ethcore/net
Fixed block_bodies not returning a list
This commit is contained in:
commit
50a6e90e3d
@ -350,7 +350,7 @@ impl BlockChainClient for Client {
|
|||||||
fn block_body(&self, hash: &H256) -> Option<Bytes> {
|
fn block_body(&self, hash: &H256) -> Option<Bytes> {
|
||||||
self.chain.read().unwrap().block(hash).map(|bytes| {
|
self.chain.read().unwrap().block(hash).map(|bytes| {
|
||||||
let rlp = Rlp::new(&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(1).as_raw(), 1);
|
||||||
body.append_raw(rlp.at(2).as_raw(), 1);
|
body.append_raw(rlp.at(2).as_raw(), 1);
|
||||||
body.out()
|
body.out()
|
||||||
|
@ -76,6 +76,19 @@ fn returns_chain_info() {
|
|||||||
assert_eq!(info.best_block_hash, block.header().hash());
|
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]
|
#[test]
|
||||||
fn imports_block_sequence() {
|
fn imports_block_sequence() {
|
||||||
let client_result = generate_dummy_client(6);
|
let client_result = generate_dummy_client(6);
|
||||||
|
Loading…
Reference in New Issue
Block a user