moved common code to helpers

This commit is contained in:
Nikolay Volf 2016-01-29 13:16:53 +04:00
parent d9e8a59cd2
commit 53c2cbc631
2 changed files with 16 additions and 22 deletions

View File

@ -44,6 +44,21 @@ pub fn create_test_block(header: &Header) -> Bytes {
rlp.out()
}
pub fn create_test_block_with_data(header: &Header, transactions: &[&Transaction], uncles: &[Header]) -> Bytes {
let mut rlp = RlpStream::new_list(3);
rlp.append(header);
rlp.append_list(transactions.len());
for t in transactions {
rlp.append_raw(&t.rlp_bytes_opt(Seal::With), 1);
}
rlp.append_list(uncles.len());
for h in uncles {
rlp.append(h);
}
rlp.out()
}
pub fn generate_dummy_client(block_number: usize) -> Arc<Client> {
let dir = RandomTempPath::new();

View File

@ -221,28 +221,7 @@ mod tests {
use spec::*;
use transaction::*;
use basic_types::*;
fn create_test_block(header: &Header) -> Bytes {
let mut rlp = RlpStream::new_list(3);
rlp.append(header);
rlp.append_raw(&rlp::EMPTY_LIST_RLP, 1);
rlp.append_raw(&rlp::EMPTY_LIST_RLP, 1);
rlp.out()
}
fn create_test_block_with_data(header: &Header, transactions: &[&Transaction], uncles: &[Header]) -> Bytes {
let mut rlp = RlpStream::new_list(3);
rlp.append(header);
rlp.append_list(transactions.len());
for t in transactions {
rlp.append_raw(&t.rlp_bytes_opt(Seal::With), 1);
}
rlp.append_list(uncles.len());
for h in uncles {
rlp.append(h);
}
rlp.out()
}
use tests::helpers::*;
fn check_ok(result: Result<(), Error>) {
result.unwrap_or_else(|e| panic!("Block verification failed: {:?}", e));