Merge branch 'master' of github.com:ethcore/parity into sync
This commit is contained in:
@@ -10,7 +10,7 @@ use crossbeam;
|
||||
/// Max depth to avoid stack overflow (when it's reached we start a new thread with VM)
|
||||
/// TODO [todr] We probably need some more sophisticated calculations here (limit on my machine 132)
|
||||
/// Maybe something like here: https://github.com/ethereum/libethereum/blob/4db169b8504f2b87f7d5a481819cfb959fc65f6c/libethereum/ExtVM.cpp
|
||||
const MAX_VM_DEPTH_FOR_THREAD: usize = 128;
|
||||
const MAX_VM_DEPTH_FOR_THREAD: usize = 64;
|
||||
|
||||
/// Returns new address created from address and given nonce.
|
||||
pub fn contract_address(address: &Address, nonce: &U256) -> Address {
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
use std::env;
|
||||
use log::{LogLevelFilter};
|
||||
use env_logger::LogBuilder;
|
||||
use super::test_common::*;
|
||||
use client::{BlockChainClient,Client};
|
||||
use pod_state::*;
|
||||
@@ -13,24 +10,8 @@ pub enum ChainEra {
|
||||
Homestead,
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref LOG_DUMMY: bool = {
|
||||
let mut builder = LogBuilder::new();
|
||||
builder.filter(None, LogLevelFilter::Info);
|
||||
|
||||
if let Ok(log) = env::var("RUST_LOG") {
|
||||
builder.parse(&log);
|
||||
}
|
||||
|
||||
if let Ok(_) = builder.init() {
|
||||
println!("logger initialized");
|
||||
}
|
||||
true
|
||||
};
|
||||
}
|
||||
|
||||
pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
|
||||
let _ = LOG_DUMMY.deref();
|
||||
init_log();
|
||||
let json = Json::from_str(::std::str::from_utf8(json_data).unwrap()).expect("Json is invalid");
|
||||
let mut failed = Vec::new();
|
||||
|
||||
|
||||
@@ -86,6 +86,20 @@ fn create_unverifiable_block(order: u32, parent_hash: H256) -> Bytes {
|
||||
create_test_block(&create_unverifiable_block_header(order, parent_hash))
|
||||
}
|
||||
|
||||
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: u32) -> GuardedTempResult<Arc<Client>> {
|
||||
let dir = RandomTempPath::new();
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ fn do_json_test(json_data: &[u8]) -> Vec<String> {
|
||||
let schedule = match test.find("blocknumber")
|
||||
.and_then(|j| j.as_string())
|
||||
.and_then(|s| BlockNumber::from_str(s).ok())
|
||||
.unwrap_or(0) { x if x < 900000 => &old_schedule, _ => &new_schedule };
|
||||
.unwrap_or(0) { x if x < 1_000_000 => &old_schedule, _ => &new_schedule };
|
||||
let rlp = Bytes::from_json(&test["rlp"]);
|
||||
let res = UntrustedRlp::new(&rlp).as_val().map_err(From::from).and_then(|t: Transaction| t.validate(schedule, schedule.have_delegate_call));
|
||||
fail_unless(test.find("transaction").is_none() == res.is_err());
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user