Tabs corrected
This commit is contained in:
parent
9374e31072
commit
e8095826bf
@ -9,7 +9,7 @@
|
|||||||
"maximumExtraDataSize": "0x20",
|
"maximumExtraDataSize": "0x20",
|
||||||
"minGasLimit": "0x1388",
|
"minGasLimit": "0x1388",
|
||||||
"networkID" : "0x2",
|
"networkID" : "0x2",
|
||||||
"applyReward": false
|
"applyReward": false
|
||||||
},
|
},
|
||||||
"genesis": {
|
"genesis": {
|
||||||
"seal": {
|
"seal": {
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
"maximumExtraDataSize": "0x20",
|
"maximumExtraDataSize": "0x20",
|
||||||
"minGasLimit": "0x1388",
|
"minGasLimit": "0x1388",
|
||||||
"networkID" : "0x2",
|
"networkID" : "0x2",
|
||||||
"applyReward": true
|
"applyReward": true
|
||||||
},
|
},
|
||||||
"genesis": {
|
"genesis": {
|
||||||
"seal": {
|
"seal": {
|
||||||
|
@ -37,15 +37,15 @@ use trace::trace::Action::Reward;
|
|||||||
#[test]
|
#[test]
|
||||||
fn can_trace_block_and_uncle_reward() {
|
fn can_trace_block_and_uncle_reward() {
|
||||||
let dir = RandomTempPath::new();
|
let dir = RandomTempPath::new();
|
||||||
let spec = Spec::new_test_with_reward();
|
let spec = Spec::new_test_with_reward();
|
||||||
let engine = &*spec.engine;
|
let engine = &*spec.engine;
|
||||||
|
|
||||||
// Create client
|
// Create client
|
||||||
let db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS);
|
let db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS);
|
||||||
let mut client_config = ClientConfig::default();
|
let mut client_config = ClientConfig::default();
|
||||||
client_config.tracing.enabled = true;
|
client_config.tracing.enabled = true;
|
||||||
let client_db = Arc::new(Database::open(&db_config, dir.as_path().to_str().unwrap()).unwrap());
|
let client_db = Arc::new(Database::open(&db_config, dir.as_path().to_str().unwrap()).unwrap());
|
||||||
let client = Client::new(
|
let client = Client::new(
|
||||||
client_config,
|
client_config,
|
||||||
&spec,
|
&spec,
|
||||||
client_db,
|
client_db,
|
||||||
@ -62,8 +62,8 @@ fn can_trace_block_and_uncle_reward() {
|
|||||||
// |
|
// |
|
||||||
// block with transaction and uncle
|
// block with transaction and uncle
|
||||||
|
|
||||||
let genesis_header = spec.genesis_header();
|
let genesis_header = spec.genesis_header();
|
||||||
let mut db = spec.ensure_db_good(get_temp_state_db(), &Default::default()).unwrap();
|
let mut db = spec.ensure_db_good(get_temp_state_db(), &Default::default()).unwrap();
|
||||||
let mut rolling_timestamp = 40;
|
let mut rolling_timestamp = 40;
|
||||||
let mut last_hashes = vec![];
|
let mut last_hashes = vec![];
|
||||||
let mut last_header = genesis_header.clone();
|
let mut last_header = genesis_header.clone();
|
||||||
@ -130,7 +130,7 @@ fn can_trace_block_and_uncle_reward() {
|
|||||||
last_hashes.push(last_header.hash());
|
last_hashes.push(last_header.hash());
|
||||||
|
|
||||||
// Add testing block with transaction and uncle
|
// Add testing block with transaction and uncle
|
||||||
let mut block = OpenBlock::new(
|
let mut block = OpenBlock::new(
|
||||||
engine,
|
engine,
|
||||||
Default::default(),
|
Default::default(),
|
||||||
true,
|
true,
|
||||||
@ -159,35 +159,34 @@ fn can_trace_block_and_uncle_reward() {
|
|||||||
n += 1;
|
n += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut uncle = Header::new();
|
let mut uncle = Header::new();
|
||||||
let uncle_author: Address = "ef2d6d194084c2de36e0dabfce45d046b37d1106".into();
|
let uncle_author: Address = "ef2d6d194084c2de36e0dabfce45d046b37d1106".into();
|
||||||
uncle.set_author(uncle_author);
|
uncle.set_author(uncle_author);
|
||||||
uncle.set_parent_hash(root_header.hash());
|
uncle.set_parent_hash(root_header.hash());
|
||||||
uncle.set_gas_limit(U256::from(50_000));
|
uncle.set_gas_limit(U256::from(50_000));
|
||||||
uncle.set_number(root_header.number() + 1);
|
uncle.set_number(root_header.number() + 1);
|
||||||
uncle.set_timestamp(rolling_timestamp);
|
uncle.set_timestamp(rolling_timestamp);
|
||||||
block.push_uncle(uncle).unwrap();
|
block.push_uncle(uncle).unwrap();
|
||||||
|
|
||||||
let block = block.close_and_lock().seal(engine, vec![]).unwrap();
|
let block = block.close_and_lock().seal(engine, vec![]).unwrap();
|
||||||
|
|
||||||
let res = client.import_block(block.rlp_bytes());
|
let res = client.import_block(block.rlp_bytes());
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
panic!("error importing block: {:#?}", res.err().unwrap());
|
panic!("error importing block: {:#?}", res.err().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
block.drain();
|
block.drain();
|
||||||
|
|
||||||
client.flush_queue();
|
client.flush_queue();
|
||||||
client.import_verified_blocks();
|
client.import_verified_blocks();
|
||||||
|
|
||||||
// Test0. Check overall filter
|
// Test0. Check overall filter
|
||||||
let filter = TraceFilter {
|
let filter = TraceFilter {
|
||||||
range: (BlockId::Number(1)..BlockId::Number(3)),
|
range: (BlockId::Number(1)..BlockId::Number(3)),
|
||||||
from_address: vec![],
|
from_address: vec![],
|
||||||
to_address: vec![],
|
to_address: vec![],
|
||||||
};
|
};
|
||||||
|
|
||||||
let traces = client.filter_traces(filter);
|
let traces = client.filter_traces(filter);
|
||||||
assert!(traces.is_some(), "Filtered traces should be present");
|
assert!(traces.is_some(), "Filtered traces should be present");
|
||||||
let traces_vec = traces.unwrap();
|
let traces_vec = traces.unwrap();
|
||||||
let block_reward_traces: Vec<LocalizedTrace> = traces_vec.clone().into_iter().filter(|trace| match (trace).action {
|
let block_reward_traces: Vec<LocalizedTrace> = traces_vec.clone().into_iter().filter(|trace| match (trace).action {
|
||||||
@ -204,4 +203,4 @@ fn can_trace_block_and_uncle_reward() {
|
|||||||
// Test1. Check block filter
|
// Test1. Check block filter
|
||||||
let traces = client.block_traces(BlockId::Number(3));
|
let traces = client.block_traces(BlockId::Number(3));
|
||||||
assert_eq!(traces.unwrap().len(), 3);
|
assert_eq!(traces.unwrap().len(), 3);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user