Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Simplifying more engine derefs
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz Drwięga committed Aug 10, 2016
1 parent 1da4d3e commit f3aa210
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions ethcore/src/client/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,15 @@ pub fn get_temp_journal_db() -> GuardedTempResult<Box<JournalDB>> {

impl MiningBlockChainClient for TestBlockChainClient {
fn prepare_open_block(&self, author: Address, gas_range_target: (U256, U256), extra_data: Bytes) -> OpenBlock {
let engine = &self.spec.engine;
let engine = &*self.spec.engine;
let genesis_header = self.spec.genesis_header();
let mut db_result = get_temp_journal_db();
let mut db = db_result.take();
self.spec.ensure_db_good(db.as_hashdb_mut()).unwrap();

let last_hashes = vec![genesis_header.hash()];
let mut open_block = OpenBlock::new(
&**engine,
engine,
self.vm_factory(),
Default::default(),
false,
Expand Down
6 changes: 3 additions & 3 deletions ethcore/src/engines/basic_authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,16 @@ mod tests {
tap.unlock_account_permanently(addr, "".into()).unwrap();

let spec = new_test_authority();
let engine = &spec.engine;
let engine = &*spec.engine;
let genesis_header = spec.genesis_header();
let mut db_result = get_temp_journal_db();
let mut db = db_result.take();
spec.ensure_db_good(db.as_hashdb_mut()).unwrap();
let last_hashes = Arc::new(vec![genesis_header.hash()]);
let vm_factory = Default::default();
let b = OpenBlock::new(&**engine, &vm_factory, Default::default(), false, db, &genesis_header, last_hashes, addr, (3141562.into(), 31415620.into()), vec![]).unwrap();
let b = OpenBlock::new(engine, &vm_factory, Default::default(), false, db, &genesis_header, last_hashes, addr, (3141562.into(), 31415620.into()), vec![]).unwrap();
let b = b.close_and_lock();
let seal = engine.generate_seal(b.block(), Some(&tap)).unwrap();
assert!(b.try_seal(&**engine, seal).is_ok());
assert!(b.try_seal(engine, seal).is_ok());
}
}
6 changes: 3 additions & 3 deletions ethcore/src/engines/instant_seal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,18 @@ mod tests {
let addr = tap.insert_account("".sha3(), "").unwrap();

let spec = new_test_instant();
let engine = &spec.engine;
let engine = &*spec.engine;
let genesis_header = spec.genesis_header();
let mut db_result = get_temp_journal_db();
let mut db = db_result.take();
spec.ensure_db_good(db.as_hashdb_mut()).unwrap();
let last_hashes = Arc::new(vec![genesis_header.hash()]);
let vm_factory = Default::default();
let b = OpenBlock::new(&**engine, &vm_factory, Default::default(), false, db, &genesis_header, last_hashes, addr, (3141562.into(), 31415620.into()), vec![]).unwrap();
let b = OpenBlock::new(engine, &vm_factory, Default::default(), false, db, &genesis_header, last_hashes, addr, (3141562.into(), 31415620.into()), vec![]).unwrap();
let b = b.close_and_lock();
// Seal with empty AccountProvider.
let seal = engine.generate_seal(b.block(), Some(&tap)).unwrap();
assert!(b.try_seal(&**engine, seal).is_ok());
assert!(b.try_seal(engine, seal).is_ok());
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/ethereum/ethash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ mod tests {
spec.ensure_db_good(db.as_hashdb_mut()).unwrap();
let last_hashes = Arc::new(vec![genesis_header.hash()]);
let vm_factory = Default::default();
let b = OpenBlock::new(&*engine, &vm_factory, Default::default(), false, db, &genesis_header, last_hashes, Address::zero(), (3141562.into(), 31415620.into()), vec![]).unwrap();
let b = OpenBlock::new(engine, &vm_factory, Default::default(), false, db, &genesis_header, last_hashes, Address::zero(), (3141562.into(), 31415620.into()), vec![]).unwrap();
let b = b.close();
assert_eq!(b.state().balance(&Address::zero()), U256::from_str("4563918244f40000").unwrap());
}
Expand All @@ -372,7 +372,7 @@ mod tests {
spec.ensure_db_good(db.as_hashdb_mut()).unwrap();
let last_hashes = Arc::new(vec![genesis_header.hash()]);
let vm_factory = Default::default();
let mut b = OpenBlock::new(&*engine, &vm_factory, Default::default(), false, db, &genesis_header, last_hashes, Address::zero(), (3141562.into(), 31415620.into()), vec![]).unwrap();
let mut b = OpenBlock::new(engine, &vm_factory, Default::default(), false, db, &genesis_header, last_hashes, Address::zero(), (3141562.into(), 31415620.into()), vec![]).unwrap();
let mut uncle = Header::new();
let uncle_author: Address = "ef2d6d194084c2de36e0dabfce45d046b37d1106".into();
uncle.author = uncle_author.clone();
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/json_tests/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
state.commit()
.expect(&format!("State test {} failed due to internal error.", name));
let vm_factory = Default::default();
let res = state.apply(&env, &*engine, &vm_factory, &transaction, false);
let res = state.apply(&env, engine, &vm_factory, &transaction, false);

if fail_unless(state.root() == &post_state_root) {
println!("!!! {}: State mismatch (got: {}, expect: {}):", name, state.root(), post_state_root);
Expand Down
16 changes: 8 additions & 8 deletions ethcore/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ fn should_trace_call_transaction_to_builtin() {

let mut info = EnvInfo::default();
info.gas_limit = 1_000_000.into();
let engine = Spec::new_test().engine;
let engine = &*Spec::new_test().engine;

let t = Transaction {
nonce: 0.into(),
Expand All @@ -642,7 +642,7 @@ fn should_trace_call_transaction_to_builtin() {
}.sign(&"".sha3());

let vm_factory = Default::default();
let result = state.apply(&info, &*engine, &vm_factory, &t, true).unwrap();
let result = state.apply(&info, engine, &vm_factory, &t, true).unwrap();

let expected_trace = vec![FlatTrace {
trace_address: Default::default(),
Expand Down Expand Up @@ -673,7 +673,7 @@ fn should_not_trace_subcall_transaction_to_builtin() {

let mut info = EnvInfo::default();
info.gas_limit = 1_000_000.into();
let engine = Spec::new_test().engine;
let engine = &*Spec::new_test().engine;

let t = Transaction {
nonce: 0.into(),
Expand All @@ -686,7 +686,7 @@ fn should_not_trace_subcall_transaction_to_builtin() {

state.init_code(&0xa.into(), FromHex::from_hex("600060006000600060006001610be0f1").unwrap());
let vm_factory = Default::default();
let result = state.apply(&info, &*engine, &vm_factory, &t, true).unwrap();
let result = state.apply(&info, engine, &vm_factory, &t, true).unwrap();

let expected_trace = vec![FlatTrace {
trace_address: Default::default(),
Expand Down Expand Up @@ -717,7 +717,7 @@ fn should_not_trace_callcode() {

let mut info = EnvInfo::default();
info.gas_limit = 1_000_000.into();
let engine = Spec::new_test().engine;
let engine = &*Spec::new_test().engine;

let t = Transaction {
nonce: 0.into(),
Expand All @@ -731,7 +731,7 @@ fn should_not_trace_callcode() {
state.init_code(&0xa.into(), FromHex::from_hex("60006000600060006000600b611000f2").unwrap());
state.init_code(&0xb.into(), FromHex::from_hex("6000").unwrap());
let vm_factory = Default::default();
let result = state.apply(&info, &*engine, &vm_factory, &t, true).unwrap();
let result = state.apply(&info, engine, &vm_factory, &t, true).unwrap();

let expected_trace = vec![FlatTrace {
trace_address: Default::default(),
Expand Down Expand Up @@ -778,7 +778,7 @@ fn should_not_trace_delegatecall() {
let mut info = EnvInfo::default();
info.gas_limit = 1_000_000.into();
info.number = 0x789b0;
let engine = Spec::new_test().engine;
let engine = &*Spec::new_test().engine;

println!("schedule.have_delegate_call: {:?}", engine.schedule(&info).have_delegate_call);

Expand All @@ -794,7 +794,7 @@ fn should_not_trace_delegatecall() {
state.init_code(&0xa.into(), FromHex::from_hex("6000600060006000600b618000f4").unwrap());
state.init_code(&0xb.into(), FromHex::from_hex("6000").unwrap());
let vm_factory = Default::default();
let result = state.apply(&info, &*engine, &vm_factory, &t, true).unwrap();
let result = state.apply(&info, engine, &vm_factory, &t, true).unwrap();

let expected_trace = vec![FlatTrace {
trace_address: Default::default(),
Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub fn generate_dummy_client_with_spec_and_data<F>(get_test_spec: F, block_numbe

// forge block.
let mut b = OpenBlock::new(
&*test_engine,
test_engine,
&vm_factory,
Default::default(),
false,
Expand Down Expand Up @@ -183,7 +183,7 @@ pub fn generate_dummy_client_with_spec_and_data<F>(get_test_spec: F, block_numbe
n += 1;
}

let b = b.close_and_lock().seal(&*test_engine, vec![]).unwrap();
let b = b.close_and_lock().seal(test_engine, vec![]).unwrap();

if let Err(e) = client.import_block(b.rlp_bytes()) {
panic!("error importing block which is valid by definition: {:?}", e);
Expand Down

0 comments on commit f3aa210

Please sign in to comment.